Datasets
A dataset is where a flow's observations live. It bundles the observations themselves with the metadata sxs needs to serve them, and it is the unit you create, publish, version and query.
What a dataset is
A dataset is bound to an SDMX artefact through a target:
resourceTypeis a dataflow, a datastructure or a dataprovider;versionmay be a semver pattern, so one dataset can match many versions of the same artefact (for example1.1+.0).
Storage is split by design:
The metadata caches everything a data query needs — the DSD components, the time dimension, the enumerated values of coded components — so serving data does not re-resolve the SDMX grammar on every request. This is what makes large data queries fast.
A dataset also has a human-readable name (for example
OECD.ENV.EPI:DSD_ECH@COAS_FLOOD:1.1) and a context equal to the target
resource type.
Metadata here means the dataset's own definition. It is not SDMX Metadata (reference metadata / MSD), which is a different concept.
Why datasets are built this way
- Fast queries — the structure is pre-resolved into the dataset metadata.
- Safe publishing — observations are immutable; changes are published as new versions instead of in-place updates, so a load never disrupts production (see versioning below).
- Flexible targeting — a dataset can follow a dataflow across versions, and one artefact can be served by several datasets (see the target).
- Isolation — datasets belong to a space, so tenants and spaces never share them. See Multitenancy.
The target
The link between data and structure goes from the dataset to the artefact: each
dataset points to an artefact through its target, and sxs resolves the link at
query time. This keeps structures and data independent.
version is either an exact version or a pattern that matches several
versions:
Example document:
With version: '1.1+.0', this dataset matches every 1.1.x version of
dataflow:OECD.ENV.EPI:DSD_ECH@COAS_FLOOD.
The relationship is many-to-many:
- one dataset can match several artefacts — when its version is a pattern;
- one artefact can be served by several datasets — for example one per provider or per import.
Resolution at query time
Data and availability requests address the artefact, not a dataset id:
At query time sxs:
- lists the datasets whose
targethas the sameresourceType,agencyIDandid; - matches each one against the requested artefact version using its
versionpattern; - returns the match with the most recent
publicationTime(the active dataset).
A dataset that is not the active one stays in history (see versioning).
Managing targets
The target is set when the dataset is created and can be changed afterwards (for
example from 1.0.0 to 1.1+.0), from Xplor. Changing it re-evaluates which
artefacts the dataset serves and republishes the related content constraints and
search index entries — see publication.
Dataset versioning
A dataset's observations are immutable. sxs never rewrites them: when data changes, it creates a new dataset version and keeps the previous one. This is how sxs delivers safe, transaction-free updates.
Every version is a plain dataset with its own:
- MongoDB document (metadata);
- ClickHouse observation table (
obs_<id>); - ClickHouse event table (
evt_<id>) describing what changed in that version.
Versions are chained:
prevIdpoints to the previous version;rootIdpoints to the first version of the chain (the root has neither).
A version is produced by applying a change set to the previous version. The change set is a list of events, each carrying an SDMX action:
The new version's observations are the unchanged rows of the previous version plus the adds and replaces; deleted rows are simply not carried over. The event table keeps the change set so it can be replayed later (history and delta sync).
The first load of a target has no predecessor: it starts a new chain.
Load or update
- loading data when no dataset exists for the target creates a new dataset (a new chain root);
- loading data for an existing dataset creates a new version appended to the chain.
A CSV update can carry an ACTION column that drives the change set (A, R,
D). When a dataset is first created from a file, only additions are accepted
(A, and I to ignore a row).
Some guard rails apply when creating a new version:
- the previous version must not be a draft;
- the new
publicationTimemust not be earlier than the previous version's; - the caller must have write access to the dataset.
Query the current version
A normal data or availability query returns the latest published version (see the target for how sxs selects it).
Query the history
Three parameters read across the chain:
These parameters need to scan several versions, so they force worker execution. See Execution modes and resource profiles.
Delete a version
Only the first (root) or the last version of a chain can be deleted:
- deleting the root promotes the next version to root and re-points
rootIdfor the rest of the chain; - an intermediate version cannot be deleted — it is part of the history.
Deleting an active version is refused unless the space enables
allowToDeleteActiveDatasets. See Settings.
Versioning is driven asynchronously through the message bus (MOM), by Xplor or the ingestion queue.
Dataset publication
Publishing is more than flipping a flag. When a dataset is published, sxs also keeps the platform consistent: it maintains the SDMX content constraint of the artefact and notifies the search/index services.
Reachability is decided by publicationTime — a draft has none, a
published dataset has one in the past, an upcoming one has a future one.
On top of that, publishing maintains a linked content constraint and emits bus
events so other services stay in sync.
What happens on publish
When a dataset becomes published (created with a publicationTime, or its
publicationTime is set/updated), sxs:
- creates the content constraint — derived from an exact availability
request, with
validFromset to the dataset'spublicationTime, and attached to the target artefact; - updates the artefact's
obs_countannotation with the number of observations; - emits
dbmx.dataset.publishedand onedbmx.search.indexOneper resolved target, so the search index (SFS) indexes the artefact; - records an activity for the audit trail.
If a dataset already carried a content constraint for the same artefact, the old one is replaced.
What happens on unpublish or delete
When a dataset is unpublished (its publicationTime is cleared) or deleted, sxs:
- deletes its content constraint(s);
- updates the artefact's
obs_count— recomputed from another published dataset for the same artefact, or removed if none remains; - emits
dbmx.dataset.unpublished, then for each target:dbmx.search.indexOneif another published dataset still serves that artefact (it becomes the new active one), otherwisedbmx.search.deleteOne(the artefact is removed from the index);
- records an activity.
Why
- Discoverability — consumers read what a dataflow contains through its content constraint (availability), without loading the data.
- Consistency — the search index and the availability always reflect the active dataset, whichever version that is.
- Auditability — every publish/unpublish is recorded as an activity.
How to use it
Set or clear the publicationTime:
- set it to now (or a future instant to schedule) to publish — from Xplor, or
by passing
publicationTimewhen storing data; - clear it to unpublish.
Changing the publicationTime of an already-published dataset re-runs the whole
sequence above (the content constraint's validFrom is updated, and both events
are emitted again).
Because a dataset may match several artefacts through its target version pattern (see the target), publishing indexes each resolved target. On unpublish, sxs re-evaluates every target: artefacts still served by another published dataset are re-indexed, the others are un-indexed.
In this picture ds1 targets DF(1.0.1); once its target pattern is widened it
also covers DF(1.0.2), so ds1 has two content constraints (one per artefact).
When ds2 is published for DF(1.0.2), it becomes the active dataset for that
dataflow, so the content constraint and index for DF(1.0.2) follow ds2, while
DF(1.0.1) stays on ds1.
Embargo
If a dataset carries a CONF_STATUS component holding embargo statuses (E,
N or C), it is flagged _meta.underEmbargo at publication.
Downstream
The publish/unpublish events are published on the message bus (MOM). Services
such as the search indexer consume them and acknowledge with
dbmx.search.indexedOne; sxs tracks failures from that acknowledgement.
See also
- Multitenancy — how datasets are isolated per space.
- Execution modes and resource profiles — history queries and workers.
- Authorization — space, agency and dataset access.
- Settings —
allowToDeleteActiveDatasetsand other switches. - API — data queries and the dataset events.
