Skip to content

Commit

Permalink
feat: expose target_file_size in python
Browse files Browse the repository at this point in the history
  • Loading branch information
ion-elgreco committed Aug 22, 2024
1 parent 42f73b1 commit aee6132
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions python/deltalake/_internal.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ def write_to_deltalake(
table: Optional[RawDeltaTable],
schema_mode: Optional[str],
predicate: Optional[str],
target_file_size: Optional[int],
name: Optional[str],
description: Optional[str],
configuration: Optional[Mapping[str, Optional[str]]],
Expand Down
6 changes: 5 additions & 1 deletion python/deltalake/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ def write_deltalake(
schema_mode: Optional[Literal["merge", "overwrite"]] = ...,
storage_options: Optional[Dict[str, str]] = ...,
predicate: Optional[str] = ...,
target_file_size: Optional[int] = ...,
large_dtypes: bool = ...,
engine: Literal["rust"] = ...,
writer_properties: WriterProperties = ...,
Expand Down Expand Up @@ -214,6 +215,7 @@ def write_deltalake(
storage_options: Optional[Dict[str, str]] = None,
partition_filters: Optional[List[Tuple[str, str, Any]]] = None,
predicate: Optional[str] = None,
target_file_size: Optional[int] = None,
large_dtypes: bool = False,
engine: Literal["pyarrow", "rust"] = "rust",
writer_properties: Optional[WriterProperties] = None,
Expand Down Expand Up @@ -267,7 +269,8 @@ def write_deltalake(
configuration: A map containing configuration options for the metadata action.
schema_mode: If set to "overwrite", allows replacing the schema of the table. Set to "merge" to merge with existing schema.
storage_options: options passed to the native delta filesystem.
predicate: When using `Overwrite` mode, replace data that matches a predicate. Only used in rust engine.
predicate: When using `Overwrite` mode, replace data that matches a predicate. Only used in rust engine.'
target_file_size: Override for target file size for data files written to the delta table. If not passed, it's taken from `delta.targetFileSize`.
partition_filters: the partition filters that will be used for partition overwrite. Only used in pyarrow engine.
large_dtypes: Only used for pyarrow engine
engine: writer engine to write the delta table. PyArrow engine is deprecated, and will be removed in v1.0.
Expand Down Expand Up @@ -308,6 +311,7 @@ def write_deltalake(
table=table._table if table is not None else None,
schema_mode=schema_mode,
predicate=predicate,
target_file_size=target_file_size,
name=name,
description=description,
configuration=configuration,
Expand Down
5 changes: 5 additions & 0 deletions python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1739,6 +1739,7 @@ fn write_to_deltalake(
schema_mode: Option<String>,
partition_by: Option<Vec<String>>,
predicate: Option<String>,
target_file_size: Option<usize>,
name: Option<String>,
description: Option<String>,
configuration: Option<HashMap<String, Option<String>>>,
Expand Down Expand Up @@ -1787,6 +1788,10 @@ fn write_to_deltalake(
builder = builder.with_replace_where(predicate);
};

if let Some(target_file_size) = target_file_size {
builder = builder.with_target_file_size(target_file_size)
};

if let Some(config) = configuration {
builder = builder.with_configuration(config);
};
Expand Down

0 comments on commit aee6132

Please sign in to comment.