MCPcopy Create free account
hub / github.com/PostHog/duckgres / TestMapDuckDBType

Function TestMapDuckDBType

server/types_test.go:33–115  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

31}
32
33func TestMapDuckDBType(t *testing.T) {
34 tests := []struct {
35 name string
36 typeName string
37 expectedOID int32
38 expectedSize int16
39 }{
40 // Boolean types
41 {"BOOLEAN", "BOOLEAN", OidBool, 1},
42 {"BOOL", "BOOL", OidBool, 1},
43 {"boolean lowercase", "boolean", OidBool, 1},
44
45 // Integer types
46 {"TINYINT", "TINYINT", OidInt2, 2},
47 {"INT1", "INT1", OidInt2, 2},
48 {"SMALLINT", "SMALLINT", OidInt2, 2},
49 {"INT2", "INT2", OidInt2, 2},
50 {"INTEGER", "INTEGER", OidInt4, 4},
51 {"INT4", "INT4", OidInt4, 4},
52 {"INT", "INT", OidInt4, 4},
53 {"BIGINT", "BIGINT", OidInt8, 8},
54 {"INT8", "INT8", OidInt8, 8},
55 {"HUGEINT", "HUGEINT", OidNumeric, -1},
56 {"INT128", "INT128", OidNumeric, -1},
57
58 // Unsigned integers
59 {"UTINYINT", "UTINYINT", OidInt4, 4},
60 {"USMALLINT", "USMALLINT", OidInt4, 4},
61 {"UINTEGER", "UINTEGER", OidOid, 4}, // Maps to PostgreSQL oid type for pg_catalog columns
62 {"UBIGINT", "UBIGINT", OidNumeric, -1},
63
64 // Float types
65 {"REAL", "REAL", OidFloat4, 4},
66 {"FLOAT4", "FLOAT4", OidFloat4, 4},
67 {"FLOAT", "FLOAT", OidFloat4, 4},
68 {"DOUBLE", "DOUBLE", OidFloat8, 8},
69 {"FLOAT8", "FLOAT8", OidFloat8, 8},
70
71 // Decimal/Numeric types
72 {"DECIMAL", "DECIMAL", OidNumeric, -1},
73 {"DECIMAL(10,2)", "DECIMAL(10,2)", OidNumeric, -1},
74 {"NUMERIC", "NUMERIC", OidNumeric, -1},
75 {"NUMERIC(18,4)", "NUMERIC(18,4)", OidNumeric, -1},
76
77 // String types
78 {"VARCHAR", "VARCHAR", OidVarchar, -1},
79 {"VARCHAR(255)", "VARCHAR(255)", OidVarchar, -1},
80 {"TEXT", "TEXT", OidText, -1},
81 {"STRING", "STRING", OidText, -1},
82
83 // Binary types
84 {"BLOB", "BLOB", OidBytea, -1},
85 {"BYTEA", "BYTEA", OidBytea, -1},
86
87 // Date/Time types
88 {"DATE", "DATE", OidDate, 4},
89 {"TIME", "TIME", OidTime, 8},
90 {"TIMESTAMP", "TIMESTAMP", OidTimestamp, 8},

Callers

nothing calls this directly

Calls 2

mapDuckDBTypeFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected