Introducing a new way to review your PRs.

Read the announcement

eventual-inc / daft

High-performance data engine for AI and multimodal workloads. Process images, audio, video, and structured data at any scale

View on GitHub

19 documents · Updated Nov 11, 2026

docs / data-model-and-micropartitions

Data model and micropartitions

Daft represents tabular data as typed columns grouped into row-aligned record batches and then into micropartitions. This model gives the DataFrame engine a common way to describe data, apply expressions, move data between execution stages, and exchange data with Arrow and Python systems. See DataFrame API for the user-facing query model.

Data model

Data types

DataType defines the type of every value in a column or expression. Daft supports scalar types such as numbers, booleans, strings, binary values, UUIDs, decimals, and nulls. It also supports temporal values with an explicit time unit, plus nested and domain types for lists, maps, structs, files, images, tensors, sparse tensors, and embeddings.

Types describe both the value domain and useful shape information. For example, a list can have a variable or fixed length, while a tensor or image can have a variable or fixed shape. Daft can infer types from Python values and type hints, or convert them from Arrow and SQL types. A Python type remains available for values that do not fit a Daft-native type.

Type groupRole
ScalarRepresents one value such as an integer, string, boolean, binary value, or decimal.
TemporalRepresents dates, times, timestamps, physical durations, or calendar intervals.
NestedRepresents lists, fixed-size lists, maps, and structs with child types.
LogicalAdds meaning or shape to values, such as images, tensors, embeddings, and files.
InteroperabilityRepresents extension values and Python objects that must cross the Arrow or Python boundary.

Logical types preserve their meaning while using a physical representation for storage and exchange. This lets the engine use a compact representation when the shape is known and a more flexible one when values vary.

References: daft/datatype.py• L148-157 daft/datatype.py• L521-731 src/…/dtype.rs• L16-152 src/…/field.rs• L97-162

Literal values

A Literal is one constant value used by queries and computations. It gives the expression system a typed value that can move between scalar forms and Series, while nested values such as lists, structs, maps, tensors, and images retain their related data and shape information. The literal type is derived from its value and can be cast when an expression needs a compatible type.

Literal values also form a boundary between query expressions and SQL output. Supported scalar values can be rendered as SQL literals with the required quoting and temporal or decimal formatting, while values without a direct SQL form remain unavailable for that translation path.

References: src/…/mod.rs• L33-125 src/…/mod.rs• L304-361 src/…/mod.rs• L418-470 src/…/mod.rs• L673-687

Fields and schemas

A Field binds a column name to a DataType and optional field metadata. A Schema is an ordered set of fields that defines the columns and types for a tabular value. It is the contract shared by record batches, micropartitions, file readers, and expression planning.

The schema also supports inspection without reading all values. It can be created from field names and types or derived from an Arrow schema or file source. Operations that add, remove, rename, or change columns produce a corresponding schema so later stages know the shape of their input.

Schema equality matters when data is combined. Record batches require matching schemas for concatenation, while an empty schema can still describe an empty result. Column names can be inspected as an ordered list, and field lookup exposes the name and type used by downstream operations.

References: daft/schema.py• L29-181 daft/schema.py• L196-235 daft/schema.py• L237-319 src/…/schema.rs• L20-113 src/…/lib.rs• L606-640

Column and batch abstractions

Series

A Series is a one-dimensional, typed array of values. It normally represents one DataFrame column, and its field keeps the column name and type together. Series provide the value-level operations used by expressions and by row selection, such as casting, filtering, sorting, slicing, and taking indexed values.

Series can be created from Python lists, Arrow arrays, NumPy arrays, or pandas series. Daft infers a native type when it can, and callers can choose a type or keep values as Python objects when native conversion is not suitable. Series can return Arrow arrays or Python values when data must leave the engine.

Series operations preserve column alignment rules. A mask or index series selects values from another series, and concatenation joins series with compatible meaning. A series may contain null values; null handling is part of the type-aware operations rather than a separate column type.

References: daft/series.py• L20-111 daft/series.py• L180-241 daft/series.py• L243-274 src/…/mod.rs• L30-41 src/…/series_like.rs• L13-42

Partitioning values

Series can derive values that describe where rows belong in a partitioned layout. Temporal values map to calendar-based keys, while supported scalar values can map to hash buckets or truncated values. These derived Series keep row alignment and provide the keys used by partition-aware reads and execution stages.

The partitioning rules preserve nulls and reject types that do not support the requested transform. Hash-based keys return integer values, while truncation keeps the value family of the source column for integers, decimals, strings, and binary data.

References: src/…/partitioning.rs• L5-27 src/…/partitioning.rs• L29-69 src/…/partitioning.rs• L71-126 src/…/hash.rs• L24-34 src/…/hash.rs• L250-320 src/…/truncate.rs• L15-79

Record batches

A RecordBatch is a rectangular table made from named, typed Series that all have the same row count. It is the smallest tabular unit in this model: the schema describes the columns, while the Series hold the values for each row.

Record batches accept data from Arrow tables, pandas DataFrames, Python mappings, and existing Series. Construction checks that the fields, types, and lengths agree. A unit-length series can be broadcast when a caller builds a batch with an explicit row count. Empty batches retain their schema so an empty result still has a known shape.

Batch operations return another batch with the same row alignment model. They support row slicing and taking, column selection and append, expression evaluation, filtering, and concatenation. Concatenation requires the input schemas to match because it combines rows rather than changing the table shape.

References: daft/…/recordbatch.py• L38-160 daft/…/recordbatch.py• L166-229 src/…/lib.rs• L67-101 src/…/lib.rs• L164-245 src/…/lib.rs• L376-407 src/…/lib.rs• L596-694

Micropartition representation

Micropartitions

A MicroPartition is the engine’s tabular data unit. It groups one or more record batches under one schema and carries metadata for the complete group, including its row count and optional table statistics. The group lets the engine process data in bounded pieces while keeping the table contract visible to readers, expressions, and execution stages.

The schema is available even when a micropartition has no record batches. When batches are present, each one must match the micropartition schema exactly. Optional statistics must describe that same schema, so metadata cannot silently refer to different columns or types.

Micropartitions can be built from Arrow, pandas, Python mappings, record batches, or file reads. They can be concatenated, sliced, converted to one record batch, streamed as separate record batches, or serialized as an Arrow IPC stream. These boundaries allow data to enter and leave the engine without changing the common tabular model.

File reads align data from several inputs to one schema before they create a micropartition. Some reads can use source metadata for a count result, while filters or row-delete rules require the matching data rows before the result is materialized.

References: daft/…/micropartition.py• L36-70 daft/…/micropartition.py• L76-152 daft/…/micropartition.py• L158-191 src/…/micropartition.rs• L32-142 src/…/micropartition.rs• L197-230 src/…/micropartition.rs• L640-758 src/…/micropartition.rs• L781-827

Micropartition flow

Data enters as a file, Arrow value, or Python table. Daft assigns a schema, groups columns into record batches, and places those batches in a micropartition. Execution stages then read columns or batches from the micropartition and produce new micropartitions for the next stage.

The following diagram shows the relationship between the data abstractions and the engine boundary.

flowchart LR
    I[File, Arrow, or Python input] --> S[Schema and DataType]
    S --> C[Series columns]
    C --> R[RecordBatch rows]
    R --> M[MicroPartition]
    M --> O[Expression and table operations]
    O --> N[New MicroPartition]
    N --> E[Arrow, Python, or downstream engine stage]

The partition API exposes both column-level and table-level work. Expression evaluation and filtering use Series as their value surface, while sorting, aggregation, joins, reshaping, and sampling return partition-level results. A partition can also expose its record batches as a stream, which lets downstream work consume bounded pieces without first merging them into one batch. This separation allows the same data contract to serve local operations and larger DataFrame plans; see Expressions and functions and Lazy DataFrame lifecycle.

References: daft/…/micropartition.py• L193-313 daft/…/micropartition.py• L306-340 src/…/micropartition.rs• L55-115 src/…/micropartition.rs• L781-827

Schema boundaries

Schema boundaries keep partitions safe to combine and keep downstream stages aware of changed columns. A read of several files can align their fields to a shared schema before it creates one micropartition, while a transformation creates a result schema that matches its output columns.

When a partition is converted to one record batch, its batches are concatenated first. When it is exported without concatenation, its batch boundaries remain visible in the Arrow table. The choice changes the physical grouping of rows, not the logical schema or row values.

References: src/…/micropartition.rs• L144-155 src/…/micropartition.rs• L262-309 src/…/micropartition.rs• L382-400 daft/…/micropartition.py• L158-166

Change checklist

When these files or sections are changed, remember to consider these:

  • Changes to DataType must preserve its Arrow conversion and round-trip behavior, including metadata for logical and extension types.
  • Changes to literal variants or type derivation must keep literal values aligned with their DataType and with Series construction and casting.
  • Changes to literal SQL rendering must preserve SQL quoting and reject values that have no supported SQL representation.
  • Changes to Field or Schema must preserve the schema agreement required by record-batch and micropartition concatenation.
  • Changes to Series construction must keep inferred types and Python-object fallback consistent with RecordBatch and Arrow input paths.
  • Changes to Series partitioning values must preserve temporal, bucket, and truncate key types so partition-aware readers and execution stages use compatible keys.
  • Changes to array hashing or truncation must preserve null positions and the value rules expected by partition transforms.
  • Changes to record-batch grouping must keep row counts, schemas, and empty-result behavior consistent for micropartition consumers.
  • Changes to micropartition serialization must preserve the schema and all record-batch boundaries needed by Arrow IPC readers.

Important failure modes

TriggerConsequenceGuard
A record batch receives a column with a different lengthRows no longer align and batch construction failsValidate Series lengths against the batch row count.
Record batches with different schemas are concatenatedThe combined columns could have different meanings or typesRequire exact schema agreement before concatenation.
A micropartition schema differs from one of its record batchesColumn lookup and downstream expression results can be incorrectKeep the partition schema equal to every contained batch schema.
Input values cannot map to a native Daft typeConversion can fail or lose the intended value typeChoose an explicit type or use the Python-object type when native conversion is not possible.
A logical or extension type loses its type metadata at an Arrow boundaryThe receiving system sees only the physical storage typePreserve the type metadata when converting fields to Arrow.
A literal's declared type does not match the value it carriesExpression type checks or conversion to a Series can produce invalid resultsKeep each literal variant mapped to its corresponding DataType.
A literal with unsupported structure is sent to SQL translationSQL generation fails instead of producing a valid queryUse only literal forms with a supported SQL representation at that boundary.
A partition transform receives an unsupported Series typeKey derivation fails before partitioned work can runUse temporal inputs for time keys and supported numeric, decimal, string, or binary inputs for Iceberg transforms.
A bucket or truncate width does not satisfy its contractBucket or truncate key creation can fail or produce an invalid partition keyUse a non-negative bucket count and a positive truncate width.
A nested value has no usable child data for hashingHash-based partitioning cannot produce a keyKeep struct values defined by at least one child field.

Key files

FileWhy to read it
daft/datatype.pyPublic DataType creation, inference, and conversion entry points.
src/…/dtype.rsThe complete set of Daft data type categories and their meaning.
src/…/mod.rsQuery literal values, type derivation, casting, and SQL rendering.
daft/schema.pyPublic Field and Schema behavior used by DataFrame-facing code.
daft/series.pyPublic Series construction, conversion, and value-level operations.
src/…/mod.rsCore Series contract and its relationship to typed arrays.
src/…/partitioning.rsSeries-level temporal, bucket, and truncate keys for partition-aware work.
src/…/hash.rsTyped and nested value hashing used to derive stable keys.
src/…/truncate.rsValue-preserving truncate rules for supported partition key types.
daft/…/recordbatch.pyPublic RecordBatch creation, exchange, and table operations.
src/…/lib.rsCore row-alignment, schema validation, and batch combination rules.
daft/…/micropartition.pyPublic micropartition lifecycle and execution-facing operations.
src/…/micropartition.rsCore partition representation, input alignment, metadata-aware reads, batch streaming, and exchange boundaries.