diff --git a/changelog.d/ITL-1434.md b/changelog.d/ITL-1434.md new file mode 100644 index 000000000..fbe82c3cf --- /dev/null +++ b/changelog.d/ITL-1434.md @@ -0,0 +1,6 @@ +### Fixed + +- The documentation says what record ids look like (text: `row_`, or the key columns as a + JSON object), and why `as_source()` of a node downstream of a join is refused as the + input of a new `PipelineJob`: its schema declares one pair of system tags per joined source + (ITL-1434). diff --git a/docs/concepts/sources.md b/docs/concepts/sources.md index 7fc9c8f84..2607c9f8e 100644 --- a/docs/concepts/sources.md +++ b/docs/concepts/sources.md @@ -773,8 +773,9 @@ forms: its identity may change in a later release. and presents them as a new source. You get one by calling `as_source()` on the node, for example `job.nodes["bmi"].as_source()`. This is useful for chaining pipeline stages: run a job, then use one of its outputs as the input of a new pipeline. The `as_source()` of a node -downstream of a join cannot yet be bound as a source of a new `PipelineJob`: its rows carry -the system tags of every joined source, and binding refuses it with `SourceSpecMismatchError` +downstream of a `Join` or `MergeJoin` of two sources cannot yet be bound as a source of a new +`PipelineJob`: its schema is the node's, which declares a pair of system tags for each joined +source, and binding accepts exactly one pair, so it is refused with `SourceSpecMismatchError` (support is planned, ITL-1127). **Using a tag value as an input to a computation.** Tags identify a row and data is what a diff --git a/docs/tutorial/08-inspecting-and-tracing.md b/docs/tutorial/08-inspecting-and-tracing.md index 939ee748b..0f4a0be41 100644 --- a/docs/tutorial/08-inspecting-and-tracing.md +++ b/docs/tutorial/08-inspecting-and-tracing.md @@ -102,7 +102,8 @@ Every stream carries hidden columns that record where its rows and values came f are left out by default. Ask for them with the `columns` argument of `as_table`. **Source-info columns.** For each data column there is a companion column named -`_source_`. On a source it holds the source's name, the row number and the column: +`_source_`. On the `units` source it holds the source id, the row's record id +(its position, counted from zero) and the column: ```python table = job.nodes["units"].as_table(columns={"source": True}) @@ -136,8 +137,20 @@ Two system-tag columns, because two sources feed `rates`; every row depends on o `sessions` and one row of `units`. The column names end in a long hash that identifies the source's position in the pipeline, which is why the sample selects them by prefix. -The companion `_tag_record_id::...` columns identify the individual source row, as text: -`row_5` for the sixth row, or the values of the source's key columns when it has some. +The companion `_tag_record_id::...` columns identify the individual source row within its +source, as text. By default a record id is the row's position, counted from zero: + +```python +units_table = job.nodes["units"].as_table(columns={"system_tags": True}) +record_id_column = next( + name for name in units_table.column_names if name.startswith("_tag_record_id::") +) +print(units_table.column(record_id_column)[5].as_py()) +# row_5 +``` + +For a source with key columns (`record_id_columns`), the record id is instead a JSON object +of the key columns and their values, in the order you declared them. !!! note "After `group_by`" A grouped row comes from many source rows. Its system tags are folded into a single @@ -481,8 +494,11 @@ result of the node, including those of earlier runs over other inputs, like !!! warning "Not yet: a stored joined result as the source of a new job" The stage above runs in memory, so its own results are not stored. Recording it in a new `PipelineJob` does not work yet for `session_means`, or for any node downstream of a - join: its rows still carry the provenance of both joined sources, and a job refuses such - a source with `SourceSpecMismatchError` when it is bound. Support is planned (ITL-1127). + `Join` or `MergeJoin` of two sources. An input of a job must declare exactly one + source-id and one record-id system tag. The source `session_means` has the schema + of its node, which declares a pair for each joined source, so a job refuses it with + `SourceSpecMismatchError` when it is bound. (Its rows hold only the stored tag and data + columns: no system tags, and null source-info tokens.) Support is planned (ITL-1127). Until then, to store a later stage, add it to the first job. ## What to remember