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 Create Temp Table

From Leeroopedia


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

Overview

Concrete tool for creating temporary tables scoped to a session's lifetime provided by the Daft library.

Description

The create_temp_table method on Session creates a temporary table from either a Schema or DataFrame source. If a Schema is provided, a PyTableSource is created from the schema. If a DataFrame is provided, the source is created from the DataFrame's logical plan builder. The method delegates to the Rust PySession.create_temp_table with replace=True, meaning that creating a temp table with an existing name silently replaces it.

Usage

Call sess.create_temp_table("name", df) on a Session instance. Use when you need to reference a DataFrame by name in SQL queries.

Code Reference

Source Location

  • Repository: Daft
  • File: daft/session.py
  • Lines: L327-361

Signature

def create_temp_table(self, identifier: str, source: Schema | DataFrame) -> Table

Import

from daft.session import Session
import daft

sess = Session()
sess.create_temp_table("my_table", daft.from_pydict({"x": [1, 2, 3]}))

I/O Contract

Inputs

Name Type Required Description
identifier str Yes Table name for the temporary table.
source DataFrame Yes Table data source. A Schema defines structure only; a DataFrame provides both structure and data.

Outputs

Name Type Description
return Table A Table instance scoped to the session's lifetime.

Usage Examples

Basic Usage

import daft
from daft.session import Session

sess = Session()

# Register DataFrames as temp tables
sess.create_temp_table("T", daft.from_pydict({"x": [1, 2, 3]}))
sess.create_temp_table("S", daft.from_pydict({"y": [4, 5, 6]}))

# List all temp tables
sess.list_tables()
# [Identifier('T'), Identifier('S')]

# Query using SQL
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