Skip to content

Commit

Permalink
fix: duckdb timestamp mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
donotpush committed Aug 14, 2024
1 parent 0a6a948 commit 8c1128f
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions dlt/destinations/impl/duckdb/duck.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,17 @@ def to_db_datetime_type(

if timezone:
return "TIMESTAMP WITH TIME ZONE"

# map precision to the appropriate TIMESTAMP type
precision_map = {
None: super().to_db_datetime_type(column, table),
6: super().to_db_datetime_type(column, table),
0: "TIMESTAMP_S",
3: "TIMESTAMP_MS",
9: "TIMESTAMP_NS",
}
if precision in precision_map:
return precision_map[precision]
elif timezone is not None: # condition for when timezone is False given that none is falsy
return "TIMESTAMP"

if precision is None or precision == 6:
return super().to_db_datetime_type(column, table)
elif precision == 0:
return "TIMESTAMP_S"
elif precision == 3:
return "TIMESTAMP_MS"
elif precision == 9:
return "TIMESTAMP_NS"

raise TerminalValueError(
f"Precision '{precision}' decimals after seconds cannot be mapped to a DuckDB TIMESTAMP"
Expand Down

0 comments on commit 8c1128f

Please sign in to comment.