Implementation:Eventual Inc Daft Session Set Catalog
| Knowledge Sources | |
|---|---|
| Domains | Data_Engineering, Catalog_Management |
| Last Updated | 2026-02-08 00:00 GMT |
Overview
Concrete tool for setting the active catalog and namespace context on a Daft Session provided by the Daft library.
Description
This implementation page documents both set_catalog and set_namespace methods on the Session class, as they together serve the single principle of catalog context setting. The set_catalog method sets the current catalog for the session (or unsets it with None), while set_namespace sets the current namespace for table resolution. Both methods delegate to the underlying Rust PySession. The set_catalog method raises a ValueError if the specified catalog does not exist.
Usage
Call sess.set_catalog("my_catalog") and sess.set_namespace("my_namespace") on a Session instance to configure the default scope for table name resolution.
Code Reference
Source Location
- Repository: Daft
- File:
daft/session.py - Lines: L575-594
Signature
def set_catalog(self, identifier: str | None) -> None
def set_namespace(self, identifier: Identifier | str | None) -> None
Import
from daft.session import Session
sess = Session()
sess.set_catalog("my_catalog")
sess.set_namespace("my_namespace")
I/O Contract
Inputs (set_catalog)
| Name | Type | Required | Description |
|---|---|---|---|
| identifier | None | Yes | Catalog name to set as current, or None to unset the current catalog. |
Inputs (set_namespace)
| Name | Type | Required | Description |
|---|---|---|---|
| identifier | str | None | Yes | Namespace identifier to set as current, or None to unset the current namespace. |
Outputs
| Name | Type | Description |
|---|---|---|
| return | None | Both methods return None and modify session state in place. |
Usage Examples
Basic Usage
from daft.session import Session
sess = Session()
# Attach and set a catalog
sess.attach_catalog(my_catalog, "analytics")
sess.set_catalog("analytics")
# Set the namespace
sess.set_namespace("production")
# Now unqualified table names resolve as analytics.production.<table_name>
tables = sess.list_tables()
# Unset the catalog
sess.set_catalog(None)