Principle:Eventual Inc Daft Session SQL Execution
| Knowledge Sources | |
|---|---|
| Domains | Data_Engineering, SQL |
| Last Updated | 2026-02-08 00:00 GMT |
Overview
Technique for executing SQL statements within a session context for catalog-aware queries.
Description
Session SQL execution processes SQL statements (DQL, DDL, DML) with full catalog awareness, resolving table references through the session's attached catalogs and namespaces. Unlike the standalone daft.sql() function, session SQL does not auto-register global Python variables as table references. It operates purely against the session's internal state: temp tables, attached catalogs, and configured namespaces. Supports CREATE TABLE, INSERT, and SELECT operations.
Usage
Use session SQL execution when you need catalog-aware SQL execution that resolves table names through attached catalogs. This is the preferred approach for production pipelines where explicit table management through catalogs is required.
Theoretical Basis
Session-scoped SQL execution with name resolution through the catalog hierarchy:
sess.sql(sql_string):
1. Parse SQL via Rust sql_exec engine
2. Resolve table references using session state:
a. Session temp tables
b. Current catalog + current namespace
c. Attached catalogs (fully qualified references)
3. Return:
- DataFrame for data statements (SELECT, etc.)
- None for non-data statements (DDL operations)