Skip to content

Commit

Permalink
handle case when schema is passed to from_pandas
Browse files Browse the repository at this point in the history
Signed-off-by: Nikolay Ulmasov <[email protected]>
  • Loading branch information
r3stl355 committed Nov 18, 2023
1 parent bf73969 commit 9b5cd1a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions python/deltalake/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")
Expand Down

0 comments on commit 9b5cd1a

Please sign in to comment.