Element <reference>¶
Purpose: Sample correlated fields from one source row and map them into the current product.
Why: Use it when several output fields must come from the same sampled source row.
Example¶
1 | |
Decision guide¶
Business value: Preserves correlations when several output fields must come from the same selected source row.
-
Use when
- Copying multiple related columns from one source record into the current product.
-
Choose another approach when
- Each field may be selected independently or only one direct value is needed.
-
Prerequisites
- Provide a supported source and declare the target/source field mappings.
-
Alternatives
- Use one source-bound variable when later scripts need the full row. (See:
<variable>)
- Use one source-bound variable when later scripts need the full row. (See:
Complete examples¶
Copy correlated fields from one weighted customer row
Use one reference with field children when several foreign-key values must always come from the same selected source record.
| correlated-reference/data/customers.wgt.ent.csv | |
|---|---|
1 2 3 | |
| correlated-reference/datamimic.xml | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 | |
Rules and invalid combinations¶
unique cannot be combined with cyclic or ordered selection.
Attributes: unique, cyclic, distribution
Why: Unique selection samples without replacement, while cyclic and ordered modes intentionally walk or repeat source rows.
| Valid combination | |
|---|---|
1 | |
| Invalid combination | |
|---|---|
1 | |
cyclic requires distribution='ordered'.
Attributes: cyclic, distribution
Why: Only an ordered walk has a defined end that cyclic can wrap back to the first row.
| Valid combination | |
|---|---|
1 | |
| Invalid combination | |
|---|---|
1 | |
sourceType is required unless source is a weighted reference file.
Attributes: source, sourceType
Why: Database-style sources need an entity name; .wgt.csv and .wgt.ent.csv encode their reference shape in the file.
| Valid combination | |
|---|---|
1 | |
| Invalid combination | |
|---|---|
1 | |
I843 β Task Reference Unsupported Source
Reference '{name}' requires a configured relational or MongoDB source, or a .wgt.csv/.wgt.ent.csv project file
Why: The reference source is neither a supported configured client nor a weighted project file.
Resolution: Use a relational or MongoDB source id, or provide a .wgt.csv/.wgt.ent.csv project file.
I844 β Task Reference No Data
No data found for reference '{name}'
Why: An error occurred during task configuration.
Resolution: Review the configuration and retry.
I845 β Task Reference Unique Too Few
Cannot generate {requested} unique values - only {available} available for reference '{name}'
Why: The system could not generate {requested} unique values - only {available} available for reference '{name}'.
Resolution: Review the configuration and retry.
I846 β Task Reference Iterator Not Initialized
Iterator was not properly initialized for reference '{name}'
Why: An error occurred during task configuration.
Resolution: Review the configuration and retry.
I874 β Task Reference Query Failed
Failed to resolve reference '{name}' from source '{source_type}' and sourceKey '{source_key}': {error_type}{error_code_hint}{error_category_hint}: {error}
Why: Database query failed while resolving values for a
Resolution: Review sourceType/sourceKey, SQL identifier validity, and database permissions before retrying.
I875 β Task Reference Single Weighting Multi Field
Reference '{name}' uses single-column weighting source '{source}' with {target_count} mapped fields. Use exactly one field for '.wgt.csv' or switch to '.wgt.ent.csv' for tuple references.
Why: Single-column weighting files cannot represent multi-column tuple references.
Resolution: Map exactly one target field for '.wgt.csv' or use '.wgt.ent.csv' with
I876 β Task Reference Unique Duplicates
Reference '{name}' requires business-unique values but source has {duplicates} duplicate rows ({unique_available} unique values from {total_rows} rows). Set platform_json 'reference_unique_duplicate_policy' to warning/skip/ignore if deduplication is acceptable.
Why: The unique reference source contains duplicate business tuples while strict duplicate policy is enabled.
Resolution: Deduplicate the source values, or change reference_unique_duplicate_policy to warning/skip/ignore when duplicates are expected.
I896 β Task Reference Ordered Exhausted
Ordered reference '{name}' exhausted after {count} rows; add cyclic="true" to wrap, or reduce the generated count.
Why: A non-cyclic distribution="ordered"
Resolution: Add cyclic="true" to wrap, or reduce the generated count.
Allowed parents / Allowed children¶
Allowed parents: else, else-if, generate, if, iterate, while
Allowed children:
field
Related concepts and use cases¶
- Model relationships and correlated data β Explains when to use nested products, memstore lineage, or one correlated reference selection.
Attributes¶
Show all 8 attributes
cyclic
Wrap the source back to the start when exhausted (typically with ordered).
optional; boolean; Default: null.
distribution
How candidates are picked per record: random (default, with replacement) or ordered (source order). cyclic wraps ordered once exhausted.
optional; string; Default: null; Values: ordered, random.
name
Name of the reference field.
required; string.
source
Source of data for the reference field.
required; string.
sourceKey
Key field in the source for the reference (legacy single-field form).
optional; string; Default: null.
sourceType
Source type for the reference field.
optional; string; Default: null.
unique
Uniqueness constraint for the reference field.
optional; boolean; Default: null.
weightColumn
Optional numeric weight column used for weighted sampling from sourceType.
optional; string; Default: null.