Skip to content

API Reference parrot.tools.dataset_manager.sources.deltatable

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.tools.dataset_manager.sources.deltatable

View source

DeltaTableSource — DataSource subclass for Delta Lake tables.

On registration, prefetch_schema() opens a connection via the asyncdb delta driver and calls conn.schema() to retrieve column names and types from the Delta table metadata without fetching any rows.

At fetch time, supports:

  • DuckDB SQL queries (sql param) via conn.query(sentence=sql, tablename=...)
  • Column selection (columns param) via conn.to_df(columns=...)
  • Filter expressions (filter param) via conn.query(sentence=filter_expr)
  • Full-table read (no params) via conn.to_df()

Supports local paths, s3:// (with AWSInterface credential resolution), and gs://. Row count estimation is available for LLM size warnings.

A static helper create_from_parquet() enables creating a new Delta table from an existing Parquet file.

Alias DataSource

Re-exported from parrot.tools.dataset_manager.sources.base.DataSource.

Class DeltaTableSource

DataSource for Delta Lake tables via asyncdb's delta driver.

Supports local paths, S3 (s3://), and GCS (gs://) via asyncdb's built-in storage support. For S3 paths, credentials are resolved via AWSInterface from parrot/interfaces/aws.py.

Parameter Type Default Description
path str Path to the Delta table. Can be a local filesystem path, an S3 URI (s3://bucket/path), or a GCS URI (gs://bucket/path).
name str Dataset name/identifier for this source.
table_name Optional[str] None DuckDB alias used for SQL queries (e.g. in SELECT * FROM {table_name} WHERE ...). Defaults to the uppercased name.
mode str 'error' Write mode for creation operations: overwrite, append, error, ignore. Defaults to "error".
credentials Optional[Dict[str, Any]] None Optional credentials dict for cloud storage access. For S3, AWSInterface is used automatically when this is None.

Attributes:

Attribute Type Description
cache_key str Stable Redis cache key for this Delta table source. Format: delta:{md5(path)[:12]}

Method DeltaTableSource.prefetch_schema

Retrieve column→type mapping from Delta table metadata.

Opens a connection via the asyncdb delta driver and calls conn.schema() to get column names and types without fetching any rows.

prefetch_schema() -> Dict[str, str]

Returns: Dict[str, str] — Dict mapping column_name → type string.

Raises:

  • RuntimeError — If the table cannot be opened or schema is unavailable.

Method DeltaTableSource.prefetch_row_count

Estimate the row count for this Delta table.

Uses a COUNT(*) SQL query. The result is stored in self._row_count_estimate.

prefetch_row_count() -> Optional[int]

Returns: Optional[int] — Estimated row count, or None if the query fails.

Method DeltaTableSource.fetch

Query the Delta table and return a DataFrame.

Priority of fetch modes:

  1. sql — DuckDB SQL query via conn.query(sentence=sql, tablename=...)
  2. columns — selective column fetch via conn.to_df(columns=...)
  3. filter — filter expression via conn.query(sentence=filter_expr)
  4. (default) full table via conn.to_df()

fetch(**params) -> pd.DataFrame

Parameter Type Default Description
**params {} sql (str, optional): DuckDB SQL statement. The table can be referenced by self._table_name (DuckDB alias). columns (list, optional): List of column names to select. filter (str, optional): SQL filter expression, e.g. "fare_amount > 30.0".

Returns: pd.DataFrame — DataFrame with the query results.

Raises:

  • RuntimeError — If the query fails.

Method DeltaTableSource.describe

Return a human-readable description for the LLM guide.

describe() -> str

Returns: str — String describing the Delta table path, DuckDB alias, and column count.

Method DeltaTableSource.create_from_parquet

Create a Delta table from a Parquet file.

create_from_parquet(delta_path: str, parquet_path: str, table_name: Optional[str] = None, mode: str = 'overwrite', credentials: Optional[Dict[str, Any]] = None) -> None

Parameter Type Default Description
delta_path str Target path for the new Delta table (local, s3://, gs://).
parquet_path str Path to the source Parquet file.
table_name Optional[str] None Optional name alias for the table (used in DuckDB queries).
mode str 'overwrite' Write mode: overwrite, append, error, ignore. Defaults to "overwrite".
credentials Optional[Dict[str, Any]] None Optional credentials dict for cloud storage.

Raises:

  • RuntimeError — If the Delta table creation fails.

Alias lazy_import

Re-exported from parrot._imports.lazy_import.

Attribute logger

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally