Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Eventual Inc Daft Session Constructor

From Leeroopedia
Revision as of 14:53, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Eventual_Inc_Daft_Session_Constructor.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Knowledge Sources
Domains Data_Engineering, Session_Management
Last Updated 2026-02-08 00:00 GMT

Overview

Concrete tool for constructing a Daft Session instance for managing catalogs, tables, and SQL execution provided by the Daft library.

Description

The Session class constructor creates a new session backed by a Rust PySession. The session starts empty with no catalogs, namespaces, or providers. It supports context manager usage (with statement) for scoped session state, where the session is automatically set as the current session on entry and restored on exit. The session provides methods for attaching/detaching catalogs, creating tables, executing SQL, and managing catalog/namespace context.

Usage

Import from daft.session and instantiate directly, or use daft.session() as a context manager. Use when you need explicit session control for catalog operations.

Code Reference

Source Location

  • Repository: Daft
  • File: daft/session.py
  • Lines: L77-104

Signature

class Session:
    def __init__(self) -> None

Import

from daft.session import Session

sess = Session()

I/O Contract

Inputs

Name Type Required Description
(none) -- -- The constructor takes no arguments. An empty session is created.

Outputs

Name Type Description
return Session A new Session instance for managing catalogs, tables, providers, and SQL execution.

Usage Examples

Basic Usage

from daft.session import Session
import daft

sess = Session()

# Create a temporary table from a DataFrame
sess.create_temp_table("T", daft.from_pydict({"x": [1, 2, 3]}))

# Execute an SQL query
sess.sql("SELECT * FROM T").show()

Context Manager Usage

import daft

with daft.session() as sess:
    sess.create_temp_table("T", daft.from_pydict({"x": [1, 2, 3]}))
    sess.sql("SELECT * FROM T").show()

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment