From ba8b94af6e92466aae0169c01af5324699b15250 Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Tue, 21 Jan 2025 13:25:21 -0500 Subject: [PATCH] fix(duckdb): ensure that duckdb columns argument to read_csv accepts duckdb syntax not ibis syntax --- ibis/backends/duckdb/__init__.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ibis/backends/duckdb/__init__.py b/ibis/backends/duckdb/__init__.py index 992a5f967c80..9c9ea99a7e24 100644 --- a/ibis/backends/duckdb/__init__.py +++ b/ibis/backends/duckdb/__init__.py @@ -667,14 +667,17 @@ def read_csv( def make_struct_argument(obj: Mapping[str, str | dt.DataType]) -> sge.Struct: expressions = [] geospatial = False - type_mapper = self.compiler.type_mapper + dialect = self.compiler.dialect for name, typ in obj.items(): - typ = dt.dtype(typ) - geospatial |= typ.is_geospatial() - sgtype = type_mapper.from_ibis(typ) + sgtype = sg.parse_one(typ, read=dialect, into=sge.DataType) + geospatial |= sgtype.this in ( + sge.DataType.Type.GEOGRAPHY, + sge.DataType.Type.GEOMETRY, + ) prop = sge.PropertyEQ( - this=sge.to_identifier(name), expression=sge.convert(sgtype) + this=sge.to_identifier(name), + expression=sge.convert(sgtype.sql(dialect)), ) expressions.append(prop)