From 9b5cd1ab4b8fa4324fbd6b3ecd44d861fa781c8d Mon Sep 17 00:00:00 2001 From: Nikolay Ulmasov Date: Sat, 18 Nov 2023 16:23:35 +0000 Subject: [PATCH] handle case when schema is passed to from_pandas Signed-off-by: Nikolay Ulmasov --- python/deltalake/writer.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/deltalake/writer.py b/python/deltalake/writer.py index 6b11ce6a0c..e5059f976b 100644 --- a/python/deltalake/writer.py +++ b/python/deltalake/writer.py @@ -161,6 +161,9 @@ def write_deltalake( partition_filters: the partition filters that will be used for partition overwrite. large_dtypes: If True, the table schema is checked against large_dtypes """ + if isinstance(schema, Schema): + schema = schema.to_pyarrow() + if _has_pandas and isinstance(data, pd.DataFrame): if schema is not None: data = pa.Table.from_pandas(data, schema=schema) @@ -180,8 +183,6 @@ def write_deltalake( raise ValueError("You must provide schema if data is Iterable") else: schema = data.schema - elif isinstance(schema, Schema): - schema = schema.to_pyarrow() if filesystem is not None: raise NotImplementedError("Filesystem support is not yet implemented. #570")