Data Engine Operations
Data operations execute directly in the Query Engine (SQLite locally, ClickHouse in Studio). They never spin up Python runtimes, never download files, and scale to millions or billions of records.
The rule: if it can be expressed as a data operation, it should be. Never materialize a chain with to_pandas() or to_list() just to run aggregation or grouping in Python; use native operations instead.
Native vs Non-Native
Non-native (pulls data into Python, iterates manually):
Native (runs entirely in the Query Engine):
Aggregate Analytics on Nested Objects
The Query Engine reaches into Pydantic models serialized in the database, including deeply nested fields:
response.usage.prompt_tokens traverses two levels of Pydantic nesting. The sum runs entirely in SQL: no Python runtime, no deserialization.
Operations Catalog
Every operation returns a new chain. Chains are immutable and composable.
Reading and Combining
- merge: join two chains on shared keys (like SQL JOIN)
- union: vertical concatenation (also the
|operator) - subtract: set difference, rows in left chain not in right
- distinct: deduplicate rows
Filtering and Selecting
- filter: keep rows matching a condition
- select: keep only named columns
- select_except: drop named columns
- limit / offset: pagination
- sample: random subset
Sorting and Grouping
- order_by: sort by columns (ascending or descending)
- group_by: partition rows and apply aggregate functions
- shuffle: randomize row order
Mutate
mutate adds or replaces columns using native expressions that run at warehouse speed. It accepts dc.func.* expressions, column arithmetic, and column comparisons:
Mutate does NOT accept lambdas or Python callables; use map() for those. See the mutate vs map comparison below.
Comparing
- diff: compare two chains and surface differences (A/D/M/S status)
- file_diff: compare file-level changes between chains
Configuring
- settings: set
parallel,cache,namespace,project, and other execution parameters - setup: run initialization code on each worker before processing
- chunk: split chain into fixed-size chunks for batch processing
Terminal Operations
- Persist:
save(named dataset),persist(anonymous cache) - Export:
to_pandas,to_parquet,to_csv,to_json,to_jsonl,to_pytorch,to_storage,to_database - Inspect:
show,collect,count,sum,avg,min,max
Mutate vs Map
Complete Examples
Merging Files with Metadata
The most common pattern: files in storage, annotations in a sidecar format. Read both, derive a join key, merge, filter, and export:
LLM Cost Tracking
Compute API costs across thousands of calls using aggregate analytics on nested Pydantic fields, no deserialization, no Python runtime: