Skip to content

Writing Tables with Append mode errors if the schema metadata is different #2419

Closed as not planned
@evancurtin

Description

@evancurtin

Environment

Delta-rs version: 0.16.4

Binding: python

Environment:

  • Cloud provider: azure
  • OS: linux64

Bug

What happened: When writing to a delta table, the metadata is checked when evaluating if the table can be written. I am using unity catalog from databricks and it is storing field-level comments in the field metadata. When I am appending new data to an existing table that I wrote comments for, I cannot write the data because my local table does not have the comment information in the field metadata.

What you expected to happen: The data is appended if the fields and datatypes of the fields match. If schema mode is not overwrite, then the existing metadata is unchanged and the new data is added to the table.

How to reproduce it:

  • write a delta table with metadata
  • Try to write new data with mode="append" with a compatible local table
  • You will see ValueError: Schema of data does not match table schema

More details:
I believe the check occurs here, where if there are any differences at all in the schema there is an error. I would think if the field names/types match then the data could be written.

if table: # already exists
if sort_arrow_schema(schema) != sort_arrow_schema(
table.schema().to_pyarrow(as_large_types=large_dtypes)
) and not (mode == "overwrite" and schema_mode == "overwrite"):
raise ValueError(
"Schema of data does not match table schema\n"
f"Data schema:\n{schema}\nTable Schema:\n{table.schema().to_pyarrow(as_large_types=large_dtypes)}"
)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions