Skip to content

Commit e24c9da

Browse files
authored
Fix: Make the implicit dependency on PyArrow optional (#4442)
1 parent 1a6cd33 commit e24c9da

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

sqlmesh/utils/pandas.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,17 @@
2727
pd.Float32Dtype(): exp.DataType.build("float"),
2828
pd.Float64Dtype(): exp.DataType.build("double"),
2929
pd.StringDtype(): exp.DataType.build("text"), # type: ignore
30-
pd.StringDtype("pyarrow"): exp.DataType.build("text"),
3130
pd.BooleanDtype(): exp.DataType.build("boolean"),
3231
}
3332

33+
try:
34+
import pyarrow # type: ignore # noqa
35+
36+
# Only add this if pyarrow is installed
37+
PANDAS_TYPE_MAPPINGS[pd.StringDtype("pyarrow")] = exp.DataType.build("text")
38+
except ImportError:
39+
pass
40+
3441

3542
def columns_to_types_from_df(df: pd.DataFrame) -> t.Dict[str, exp.DataType]:
3643
return columns_to_types_from_dtypes(df.dtypes.items())

0 commit comments

Comments
 (0)