Implementation:Eventual Inc Daft Session Write Table
| Knowledge Sources | |
|---|---|
| Domains | Data_Engineering, Catalog_Management |
| Last Updated | 2026-02-08 00:00 GMT |
Overview
Concrete tool for writing DataFrame data to a named catalog table through a Daft Session provided by the Daft library.
Description
The write_table method on Session writes a DataFrame to a table identified by name. It first resolves the string identifier to an Identifier object if necessary, then looks up the table via self._session.get_table(identifier._ident), and finally calls the table's write method with the DataFrame, mode, and any additional options. The write mode defaults to "append".
Usage
Call sess.write_table("table_name", df) on a Session instance. Use for writing data to catalog-managed tables.
Code Reference
Source Location
- Repository: Daft
- File:
daft/session.py - Lines: L627-645
Signature
def write_table(
self,
identifier: Identifier | str,
df: DataFrame,
mode: Literal["append", "overwrite"] = "append",
**options: dict[str, Any],
) -> None
Import
from daft.session import Session
sess = Session()
sess.write_table("my_table", df, mode="append")
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| identifier | str | Yes | Table name or fully qualified identifier for the target table. |
| df | DataFrame | Yes | The DataFrame containing the data to write. |
| mode | Literal["append", "overwrite"] | No | Write mode. "append" adds data to the existing table; "overwrite" replaces all existing data. Defaults to "append". |
| **options | dict[str, Any] | No | Additional format-specific write options passed through to the table implementation. |
Outputs
| Name | Type | Description |
|---|---|---|
| return | None | No return value. Data is written to the catalog table as a side effect. |
Usage Examples
Basic Usage
from daft.session import Session
import daft
sess = Session()
sess.attach_catalog(my_catalog, "warehouse")
sess.set_catalog("warehouse")
sess.set_namespace("analytics")
df = daft.from_pydict({"id": [1, 2, 3], "value": ["a", "b", "c"]})
# Append data to an existing table
sess.write_table("events", df, mode="append")
# Overwrite all data in a table
sess.write_table("events", df, mode="overwrite")