Skip to content

Commit

Permalink
fix(duckdb): add missing types
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Sep 13, 2022
1 parent 05561e0 commit 59bad07
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
13 changes: 10 additions & 3 deletions ibis/backends/duckdb/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
int16,
int32,
int64,
json,
spaceless,
spaceless_string,
string,
Expand Down Expand Up @@ -63,9 +64,14 @@ def parse(text: str, default_decimal_parameters=(18, 3)) -> DataType:
| spaceless_string("double", "float8").result(float64)
| spaceless_string("real", "float4", "float").result(float32)
| spaceless_string("smallint", "int2", "short").result(int16)
| spaceless_string("timestamp", "datetime").result(
Timestamp(timezone="UTC")
)
| spaceless_string(
"timestamp_tz",
"timestamp_sec",
"timestamp_ms",
"timestamp_ns",
"timestamp",
"datetime",
).result(Timestamp(timezone="UTC"))
| spaceless_string("date").result(date)
| spaceless_string("time").result(time)
| spaceless_string("tinyint", "int1").result(int8)
Expand All @@ -82,6 +88,7 @@ def parse(text: str, default_decimal_parameters=(18, 3)) -> DataType:
"text",
"string",
).result(string)
| spaceless_string("json").result(json)
)

@p.generate
Expand Down
10 changes: 10 additions & 0 deletions ibis/backends/duckdb/tests/test_datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
),
T=dt.Array(dt.Array(dt.int32)),
U=dt.Array(dt.Array(dt.int32)),
V=dt.Timestamp("UTC"),
W=dt.Timestamp("UTC"),
X=dt.Timestamp("UTC"),
Y=dt.Timestamp("UTC"),
Z=dt.json,
)


Expand Down Expand Up @@ -113,6 +118,11 @@
("S", "STRUCT(a INT, b TEXT, c LIST<MAP<TEXT, LIST<FLOAT8>>>)"),
("T", "LIST<LIST<INTEGER>>"),
("U", "INTEGER[][]"),
("V", "TIMESTAMP_TZ"),
("W", "TIMESTAMP_SEC"),
("X", "TIMESTAMP_MS"),
("Y", "TIMESTAMP_NS"),
("Z", "JSON"),
]
],
)
Expand Down

0 comments on commit 59bad07

Please sign in to comment.