Working with Datasets
Datasets are the primary output and collaboration mechanism in DataChain. This guide covers creating, managing, versioning, and sharing datasets.
Creating Datasets
save(): Named, Versioned, Shared
save("name") creates an immutable, versioned dataset in the registry. It records author, dependencies, and code automatically.
save() is the default terminal operation, not show() or to_list(). Any chain that runs a Python function should end in save("name"). This makes queries reusable instead of producing throwaway output.
persist(): Anonymous, Script-Local
persist() creates a hidden dataset for caching within a script. Not in the registry, not versioned, not shared.
Versioning
Every save() auto-increments the version:
Read specific versions:
Control version bumps:
Namespaces
Two-level namespace system: team.project.name.
Override defaults with environment variables:
Or per-chain:
Dataset URI scheme: ds://namespace.project.name@v1.2.3.
Comparing Versions
diff() compares two chains row by row:
Status values: A (added), D (deleted), M (modified), S (same).
file_diff() compares file-level changes:
Management
Metrics and Parameters
Attach quantitative metrics to dataset versions:
Read parameters from the environment:
Parameters are captured in lineage so the exact configuration is always recoverable.
CLI Commands
CLI commands accept --studio or --local flags.
Studio Sync
read_dataset() auto-falls-back to Studio when a dataset is not found locally. Use the CLI to pull datasets explicitly: