A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: ibis data types, from upgrade (#4847)
Myles Scolnickd692a735b7bb
diff --git a/marimo/_sql/engines/ibis.py b/marimo/_sql/engines/ibis.pyindex 0acb0e1c54..00fb5fa272 100644--- a/marimo/_sql/engines/ibis.py+++ b/marimo/_sql/engines/ibis.py@@ -356,25 +356,40 @@ class IbisEngine(SQLEngine):# numeric is a superset of integer, so we evaluate after is_integerelif ibis_dtype.is_numeric():return "number"-elif ibis_dtype.is_date():return "date"-elif ibis_dtype.is_timestamp():return "datetime"-elif ibis_dtype.is_time():return "time"-+ elif ibis_dtype.is_temporal():+ return "datetime"+ elif ibis_dtype.is_interval():+ return "string"elif ibis_dtype.is_boolean():return "boolean"-elif ibis_dtype.is_string():return "string"-elif ibis_dtype.is_binary():return "string"-+ elif ibis_dtype.is_array():+ return "unknown"+ elif ibis_dtype.is_map():+ return "unknown"+ elif ibis_dtype.is_struct():+ return "unknown"+ elif ibis_dtype.is_json():+ return "unknown"+ elif ibis_dtype.is_uuid():+ return "string"+ elif ibis_dtype.is_macaddr():+ return "string"+ elif ibis_dtype.is_inet():+ return "string"+ elif ibis_dtype.is_linestring():+ return "string"+ elif ibis_dtype.is_multilinestring():+ return "string"else:raise IbisToMarimoConversionErrordiff --git a/tests/_sql/test_ibis.py b/tests/_sql/test_ibis.pyindex da8ad69140..365d16c7e9 100644--- a/tests/_sql/test_ibis.py+++ b/tests/_sql/test_ibis.py@@ -244,7 +244,7 @@ def test_ibis_sql_types() -> None:str(dt.String()): "string",str(dt.Date()): "date",str(dt.Time()): "time",- str(dt.Timestamp()): "timestamp(6)", # duckdb sets default precision+ str(dt.Timestamp()): "timestamp", # duckdb sets default precisionstr(dt.Interval(unit="D")): "interval('us')",str(dt.Array(value_type=dt.Int32())): "array<int32>",str(@@ -275,12 +275,10 @@ def test_ibis_sql_types() -> None:str(dt.Time()): "time",str(dt.Timestamp()): "datetime",str(dt.Interval(unit="D")): "string", # default case- str(dt.Array(value_type=dt.Int32())): "string", # default case- str(- dt.Map(key_type=dt.String(), value_type=dt.Int32())- ): "string", # default case- str(dt.Struct(fields={"foo": dt.Int32()})): "string", # default case- str(dt.JSON()): "string", # default case+ str(dt.Array(value_type=dt.Int32())): "unknown",+ str(dt.Map(key_type=dt.String(), value_type=dt.Int32())): "unknown",+ str(dt.Struct(fields={"foo": dt.Int32()})): "unknown",+ str(dt.JSON()): "unknown", # default casestr(dt.MACADDR()): "string", # default casestr(dt.UUID()): "string", # default case}@@ -303,8 +301,12 @@ def test_ibis_sql_types() -> None:for column in table.columns:assert column.name in expected_marimo_type.keys()- assert column.type == expected_marimo_type[column.name]- assert column.external_type == expected_external_type[column.name]+ assert column.type == expected_marimo_type[column.name], (+ f"{column.name} {column.type} {expected_marimo_type[column.name]}"+ )+ assert column.external_type == expected_external_type[column.name], (+ f"{column.name} {column.external_type} {expected_external_type[column.name]}"+ )@pytest.mark.skipif(not HAS_IBIS, reason="Ibis not installed")@@ -345,24 +347,7 @@ def test_ibis_type_conversion() -> None:assert to_marimo(dt.Time()) == "time"assert to_marimo(dt.Timestamp()) == "datetime"- # unhandled cases will be converted to string- with pytest.raises(IbisToMarimoConversionError):- to_marimo(dt.Interval(unit="D"))-- # nested types- with pytest.raises(IbisToMarimoConversionError):- to_marimo(dt.Array(value_type=dt.Int32()))-- with pytest.raises(IbisToMarimoConversionError):- to_marimo(dt.Map(key_type=dt.String(), value_type=dt.Int32()))-- with pytest.raises(IbisToMarimoConversionError):- to_marimo(dt.Struct(fields={"foo": dt.Int32()}))-# geometry- with pytest.raises(IbisToMarimoConversionError):- to_marimo(dt.MultiLineString())-with pytest.raises(IbisToMarimoConversionError):to_marimo(dt.MultiPoint())@@ -378,16 +363,6 @@ def test_ibis_type_conversion() -> None:with pytest.raises(IbisToMarimoConversionError):to_marimo(dt.Polygon())- # special types- with pytest.raises(IbisToMarimoConversionError):- to_marimo(dt.JSON())-- with pytest.raises(IbisToMarimoConversionError):- to_marimo(dt.MACADDR())-- with pytest.raises(IbisToMarimoConversionError):- to_marimo(dt.UUID())-@pytest.mark.skipif(not HAS_IBIS, reason="Ibis not installed")def test_ibis_engine_get_table_details(ibis_backend: SQLBackend) -> None: