Schema.write_delta#

classmethod Schema.write_delta(
df: DataFrame[Self],
/,
target: str | Path | deltalake.DeltaTable,
**kwargs: Any,
) None[source]#

Write a typed data frame with this schema to a Delta Lake table.

This method automatically adds a serialization of this schema to the Delta Lake table as metadata. The metadata can be leveraged by read_delta() and scan_delta() for efficient reading or by external tools.

Parameters:
  • df – The data frame to write to the Delta Lake table.

  • target – The path or DeltaTable object to which to write the data.

  • kwargs – Additional keyword arguments passed directly to polars.write_delta().

Attention

This method suffers from the same limitations as serialize().

Schema metadata is stored as custom commit metadata. Only the schema information from the last commit is used, so any table modifications that are not through dataframely will result in losing the metadata.

Be aware that appending to an existing table via mode=”append” may result in violation of group constraints that dataframely cannot catch without re-validating. Only use appends if you are certain that they do not break your schema.