Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions duckdbservice/arrow_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,16 @@ func DuckDBTypeToArrow(dbType string) arrow.DataType {
// irrecoverably lost at the driver level.
return arrow.FixedWidthTypes.Time64us

// Timestamps (no timezone → empty TimeZone string)
case "TIMESTAMP":
case "TIMESTAMP", "TIMESTAMP WITHOUT TIME ZONE":
// No timezone means an empty Arrow TimeZone string.
return &arrow.TimestampType{Unit: arrow.Microsecond}
case "TIMESTAMP_S":
return &arrow.TimestampType{Unit: arrow.Second}
case "TIMESTAMP_MS":
return &arrow.TimestampType{Unit: arrow.Millisecond}
case "TIMESTAMP_NS":
return &arrow.TimestampType{Unit: arrow.Nanosecond}
case "TIMESTAMPTZ":
case "TIMESTAMPTZ", "TIMESTAMP WITH TIME ZONE":
return &arrow.TimestampType{Unit: arrow.Microsecond, TimeZone: "UTC"}

// Interval
Expand Down
14 changes: 9 additions & 5 deletions duckdbservice/arrow_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,15 @@ func TestDuckDBTypeToArrow(t *testing.T) {

// Timestamps — plain TIMESTAMP must NOT have timezone
{"TIMESTAMP", &arrow.TimestampType{Unit: arrow.Microsecond}},
{"TIMESTAMP WITHOUT TIME ZONE", &arrow.TimestampType{Unit: arrow.Microsecond}},
{"timestamp without time zone", &arrow.TimestampType{Unit: arrow.Microsecond}},
{"TIMESTAMP_S", &arrow.TimestampType{Unit: arrow.Second}},
{"TIMESTAMP_MS", &arrow.TimestampType{Unit: arrow.Millisecond}},
{"TIMESTAMP_NS", &arrow.TimestampType{Unit: arrow.Nanosecond}},
// TIMESTAMPTZ must have UTC timezone
{"TIMESTAMPTZ", &arrow.TimestampType{Unit: arrow.Microsecond, TimeZone: "UTC"}},
{"TIMESTAMP WITH TIME ZONE", &arrow.TimestampType{Unit: arrow.Microsecond, TimeZone: "UTC"}},
{"timestamp with time zone", &arrow.TimestampType{Unit: arrow.Microsecond, TimeZone: "UTC"}},

// Interval
{"INTERVAL", arrow.FixedWidthTypes.MonthDayNanoInterval},
Expand Down Expand Up @@ -171,11 +175,11 @@ func TestParseDecimalParams(t *testing.T) {
{"DECIMAL(10,5)", 10, 5},
{"DECIMAL(38,0)", 38, 0},
{"NUMERIC(5,3)", 5, 3},
{"DECIMAL", 18, 3}, // default fallback
{"DECIMAL()", 18, 3}, // empty parens
{"DECIMAL(abc,def)", 18, 3}, // non-numeric
{"DECIMAL(18,)", 18, 3}, // missing scale
{"DECIMAL(,2)", 18, 3}, // missing precision
{"DECIMAL", 18, 3}, // default fallback
{"DECIMAL()", 18, 3}, // empty parens
{"DECIMAL(abc,def)", 18, 3}, // non-numeric
{"DECIMAL(18,)", 18, 3}, // missing scale
{"DECIMAL(,2)", 18, 3}, // missing precision
}

for _, tt := range tests {
Expand Down
Loading