Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] Scaffolding for df.write_table #3323

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions daft/dataframe/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,35 @@
}
)

@DataframePublicAPI
def write_table(
self,
name: str,
mode: Literal["append", "overwrite"] = "append", # TODO: add dynamic-partition-overwrite
catalog_name: Optional[str] = None,
create_table: bool = True,
# TODO: Add table-specific options such as "iceberg.partition_columns". These should be properly and heavily documented.
# I think it is fair to assume that each catalog will dictate what table format to use, and we don't need to account for
# multi-table-format catalogs. If users want that, they can register multiple named catalogs (e.g. `"glue-iceberg"` and `"glue-delta"`).
# table_options: Optional[dict[str, Any]] = None,
# TODO: Add "upsert" into `mode`, and add UpsertOptions
# upsert_options: Optional["UpsertOptions"] = None,
) -> "DataFrame":
"""Finds a table with the specified name, in the specified catalog, and writes to it.

If the table does not exist, Daft will attempt to create it unless explicitly instructed not to do so via `create_table=False`.

.. NOTE::
This call is **blocking** and will execute the DataFrame when called

Args:
name: The name of the table to write to.
mode: Operation mode of the write. `append` will append new data, `overwrite` will replace table with new data. Defaults to "append".
catalog_name: Name of the catalog where this table should be found/created. Defaults to `None` which indicates to use the configured default catalog.
create_table: Whether or not to create the table if it does not yet exist.
"""
return None # type: ignore

Check warning on line 683 in daft/dataframe/dataframe.py

View check run for this annotation

Codecov / codecov/patch

daft/dataframe/dataframe.py#L683

Added line #L683 was not covered by tests

@DataframePublicAPI
def write_iceberg(self, table: "pyiceberg.table.Table", mode: str = "append") -> "DataFrame":
"""Writes the DataFrame to an `Iceberg <https://iceberg.apache.org/docs/nightly/>`__ table, returning a new DataFrame with the operations that occurred.
Expand Down
Loading