Zum Inhalt

Element <variable>

Zweck: Bindet einen wiederverwendbaren Skalar, eine Entity, eine Quellauswahl oder einen Skriptwert im aktiven Scope.

Warum: Verwende dieses Element für wiederverwendbare Zwischendaten, die nicht selbst exportiert werden sollen.

Beispiel

1
<variable name="active" generator="BooleanGenerator"/>

Entscheidungshilfe

Fachlicher Nutzen: Trennt wiederverwendbare Berechnungen und Quell-Bindings von den exportierten Produktfeldern.

  • Verwenden, wenn

    • Wenn mehrere spätere Felder dieselbe Entity, Quellzeile, denselben Wert oder dieselbe Berechnung benötigen.
  • Anderen Ansatz wählen, wenn

    • Wenn der Wert direkt zum exportierten Datensatz gehört.
  • Voraussetzungen

    • Deklariere die Variable vor allen Ausdrücken, die ihren Namen verwenden.
  • Alternativen

    • Verwende key, wenn der Wert Teil des Ausgabedatensatzes sein muss. (Siehe: <key>)

Vollständige Beispiele

Wiederverwendbare Werte vor dem Feldexport binden

Verwende Variablen für Zwischenwerte und exportiere nur die Keys, die zum Produkt gehören.

variable-binding-strategies/datamimic.xml
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
<setup rngSeed="42">
    <generate name="variable_bindings" count="5" target="LogExporter">
        <variable name="sequence" generator="IncrementGenerator"/>
        <variable name="country" constant="Germany"/>
        <variable name="doubled" script="sequence * 2"/>
        <variable name="tier" values="'standard','premium'" weights="3,1"/>
        <key name="id" script="sequence"/>
        <key name="country" script="country"/>
        <key name="score" script="doubled"/>
        <key name="tier" script="tier"/>
    </generate>
</setup>
Eine geordnete Entity-CSV-Quelle zyklisch durchlaufen

Verwende cyclic nur, wenn ein begrenztes Produkt bewusst mehr Datensätze als die endliche Quelle benötigt.

variable-ordered-cyclic/data/people.ent.csv
1
2
3
4
id|name
1|Ada
2|Grace
3|Linus
variable-ordered-cyclic/datamimic.xml
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<setup defaultSeparator="|">
    <generate name="cycled_people" count="8" target="LogExporter">
        <variable name="person"
                  source="data/people.ent.csv"
                  distribution="ordered"
                  cyclic="true"/>
        <key name="person_id" script="person.id"/>
        <key name="person_name" script="person.name"/>
    </generate>
</setup>
iterator, data oder value bewusst als Storage-Modus wählen

Verwende iterator für zeilenweises Durchlaufen, data für Berechnungen auf dem gesamten Pool und value für einen gehaltenen Datensatz.

variable-storage-modes/data/colors.ent.csv
1
2
3
4
color|priority
red|1
green|2
blue|3
variable-storage-modes/datamimic.xml
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<setup defaultSeparator="|">
    <variable name="color_iterator" source="data/colors.ent.csv" storage="iterator" cyclic="true"/>
    <variable name="all_colors" source="data/colors.ent.csv" storage="data"/>
    <variable name="first_color" source="data/colors.ent.csv" storage="value"/>
    <generate name="storage_examples" count="5" target="LogExporter">
        <key name="cycled_color" script="color_iterator.color"/>
        <key name="available_colors" script="len(all_colors)"/>
        <key name="template_color" script="first_color.get('color')"/>
    </generate>
</setup>

Regeln und ungültige Kombinationen

Eine variable benötigt genau einen Modus zur Werterzeugung.

Attribute: source, entity, script, generator, values, constant, type, pattern, string

Warum: Ein Binding ohne Quelle, Entity, Skript, Generator, Wertepool, Konstante, Typ, Pattern oder String-Template kann keinen Wert bereitstellen.

Gültige Kombination
1
<variable name="environment" constant="test"/>
Ungültige Kombination
1
<variable name="environment"/>
Wähle genau einen expliziten Erzeugungsmodus für die variable.

Attribute: source, entity, script, generator, values, constant, pattern, string

Warum: Die Kombination von source, entity, script, generator, values, constant, pattern oder string würde das Binding mehrdeutig machen.

Gültige Kombination
1
<variable name="environment" constant="test"/>
Ungültige Kombination
1
<variable name="environment" constant="test" script="'development'"/>
storage erfordert eine materialisierbare source.

Attribute: storage, source

Warum: value, data und iterator beschreiben die Aufbewahrung von Quelldatensätzen; sie gelten nicht für Konstanten oder Generatorergebnisse.

Gültige Kombination
1
<variable name="customer" source="data/customers.ent.csv" storage="data"/>
Ungültige Kombination
1
<variable name="customer" constant="test" storage="data"/>
storage darf nicht mit iterationSelector kombiniert werden.

Attribute: storage, iterationSelector

Warum: Abfragen pro Iteration stellen keinen stabilen Quellpool bereit, den eine Storage-Strategie benötigt.

Gültige Kombination
1
<variable name="customer" source="data/customers.ent.csv" storage="data"/>
Ungültige Kombination
1
<variable name="customer" source="customerDb" storage="data" iterationSelector="SELECT * FROM customers"/>
unique darf nicht mit cyclic kombiniert werden.

Attribute: unique, cyclic

Warum: Unique-Auswahl verbraucht einen endlichen Pool ohne Zurücklegen, während cyclic ihn bewusst wiederholt.

Gültige Kombination
1
<variable name="code" values="'A','B'" unique="true"/>
Ungültige Kombination
1
<variable name="code" source="data/codes.ent.csv" unique="true" cyclic="true"/>
weights erfordert einen Inline-Pool in values.

Attribute: weights, values

Warum: Jedes Gewicht beeinflusst den entsprechenden values-Eintrag und hat ohne diesen Pool keine Bedeutung.

Gültige Kombination
1
<variable name="tier" values="'standard','premium'" weights="3,1"/>
Ungültige Kombination
1
<variable name="tier" type="string" weights="3,1"/>
defaultValue erfordert script.

Attribute: defaultValue, script

Warum: Der Fallback wird nur ausgewertet, wenn der Skriptwert fehlt oder seine condition die Variable unterdrückt.

Gültige Kombination
1
<variable name="nickname" script="None" defaultValue="'unknown'"/>
Ungültige Kombination
1
<variable name="nickname" constant="unknown" defaultValue="'fallback'"/>
Optionen zur Quellenauswahl erfordern source.

Attribute: source, selector, separator, sourceScripted, cyclic

Warum: Optionen zum Parsen und Auswählen besitzen ohne Quellenzugriff keine Bedeutung.

Gültige Kombination
1
<variable name="customer" source="data/customers.ent.csv" selector="id != None"/>
Ungültige Kombination
1
<variable name="customer" constant="x" selector="id != None"/>
Generator- und Entity-Optionen erfordern generator oder entity.

Attribute: generator, entity, locale, dataset, rngSeed

Warum: Locale, Dataset, Alter, Conditions und RNG konfigurieren einen komponenteneigenen Wert.

Gültige Kombination
1
<variable name="person" entity="Person" locale="en"/>
Ungültige Kombination
1
<variable name="person" constant="x" locale="en"/>
storage darf nicht mit sourceScripted kombiniert werden.

Attribute: storage, sourceScripted

Warum: Eine skriptgesteuerte Quelle stellt keinen stabilen materialisierbaren Pool bereit.

Gültige Kombination
1
<variable name="customer" source="data/customers.ent.csv" storage="data"/>
Ungültige Kombination
1
<variable name="customer" source="data/customers.ent.csv" storage="data" sourceScripted="true"/>
storage darf nicht mit converter kombiniert werden.

Attribute: storage, converter

Warum: Ein materialisierter Listen- oder Proxywert besitzt keine Konvertierungsgrenze pro Datensatz.

Gültige Kombination
1
<variable name="customer" source="data/customers.ent.csv" storage="data"/>
Ungültige Kombination
1
<variable name="customer" source="data/customers.ent.csv" storage="data" converter="Hash"/>
storage kann keine gewichtete Entity-Quelle materialisieren.

Attribute: storage, source

Warum: Gewichtete Auswahl verbraucht Quellmetadaten, die ein gespeicherter Proxy nicht korrekt bewahren kann.

Gültige Kombination
1
<variable name="customer" source="data/customers.ent.csv" storage="data"/>
Ungültige Kombination
1
<variable name="customer" source="data/customers.wgt.ent.csv" storage="data" weightColumn="weight"/>
unique erfordert values oder source.

Attribute: unique, values, source

Warum: Eine Stichprobe ohne Zurücklegen benötigt einen endlichen Pool.

Gültige Kombination
1
<variable name="code" values="'A','B'" unique="true"/>
Ungültige Kombination
1
<variable name="code" type="string" unique="true"/>
unique lässt sich nur mit distribution='random' kombinieren.

Attribute: unique, distribution

Warum: Geordnete oder gewichtete Auswahl widerspricht einer gleichverteilten Stichprobe ohne Zurücklegen.

Gültige Kombination
1
<variable name="code" values="'A','B'" unique="true" distribution="random"/>
Ungültige Kombination
1
<variable name="code" values="'A','B'" unique="true" distribution="ordered"/>
unique darf nicht mit weights kombiniert werden.

Attribute: unique, weights

Warum: Unique-Auswahl ist gleichverteilt ohne Zurücklegen; Gewichte beschreiben verzerrte wiederholte Ziehungen.

Gültige Kombination
1
<variable name="code" values="'A','B'" unique="true"/>
Ungültige Kombination
1
<variable name="code" values="'A','B'" weights="1,2" unique="true"/>
cyclic erfordert eine wiederholungskompatible Distribution.

Attribute: cyclic, distribution

Warum: Gewichtete und stratifizierte Vollpool-Ziehungen besitzen keine Neustartgrenze.

Gültige Kombination
1
<variable name="code" source="data/codes.ent.csv" cyclic="true" distribution="ordered"/>
Ungültige Kombination
1
<variable name="code" source="data/codes.ent.csv" cyclic="true" distribution="weighted" weightColumn="weight"/>
distribution='weighted' erfordert weightColumn.

Attribute: distribution, weightColumn

Warum: Die Auswahl benötigt eine numerische Quellspalte zur Berechnung der Wahrscheinlichkeiten.

Gültige Kombination
1
<variable name="customer" source="data/customers.ent.csv" weightColumn="weight" distribution="weighted"/>
Ungültige Kombination
1
<variable name="customer" source="data/customers.ent.csv" distribution="weighted"/>
distribution='stratified' erfordert stratifyBy.

Attribute: distribution, stratifyBy

Warum: Die Auswahl benötigt eine Quellspalte, die jedes Stratum identifiziert.

Gültige Kombination
1
<variable name="customer" source="data/customers.ent.csv" stratifyBy="segment" distribution="stratified"/>
Ungültige Kombination
1
<variable name="customer" source="data/customers.ent.csv" distribution="stratified"/>
Inline-values akzeptieren nur von dieser Oberfläche unterstützte Distributionen.

Attribute: values, source, distribution

Warum: Vollquellen-Policies benötigen Zeilenmetadaten, die ein skalarer Inline-Pool nicht bereitstellt.

Gültige Kombination
1
<variable name="code" values="'A','B'" distribution="ordered"/>
Ungültige Kombination
1
<variable name="code" values="'A','B'" distribution="reservoir"/>
Eine semantische Projektdatei-Quelle erfordert ihre katalogisierte Distribution.

Attribute: source, distribution

Warum: Der Suffix deklariert Auswahlsemantik, die eine widersprechende explizite Distribution nicht überschreiben darf.

Gültige Kombination
1
<variable name="customer" source="data/customers.wgt.ent.csv" weightColumn="weight" distribution="weighted"/>
Ungültige Kombination
1
<variable name="customer" source="data/customers.wgt.ent.csv" weightColumn="weight" distribution="ordered"/>
I192 — Source Reference Identifier Empty

Explicit source URI for family '{family}' requires a non-empty identifier

Warum: A recognized source-family URI was declared without the identifier needed to resolve its source.

Lösung: Add the source identifier after the URI scheme and retry.

Vollständige Regel

I193 — Source Reference Consumer Unsupported

Explicit source family '{family}' is not supported by <{consumer}>

Warum: The source family is valid, but the consuming DSL element does not implement its read contract.

Lösung: Use a source family supported by this element or move the read to generate/iterate.

Vollständige Regel

I194 — Source Reference Client Family Mismatch

Explicit source family '{family}' does not match configured client '{client_id}' of type '{actual_client_type}'

Warum: The referenced client exists but does not implement the source family declared by the URI.

Lösung: Use the URI scheme matching the configured client or reference a client of the declared family.

Vollständige Regel

I195 — Source Reference Identifier Conflict

Explicit source identifier '{identifier}' conflicts with {attribute}='{configured_identifier}'

Warum: Two source attributes select different identities for the same explicit source reference.

Lösung: Remove the legacy override or make it equal to the identifier in source.

Vollständige Regel

Erlaubte Elternelemente / Erlaubte Kindelemente

Erlaubte Elternelemente: ama-generate, else, else-if, generate, if, iterate, nestedKey, setup, while

Erlaubte Kindelemente:

Keine

Attribute

Alle 39 Attribute anzeigen

ageMax

Maximum age when generating entity data.

optional; integer; Standardwert: null.

ageMin

Minimum age when generating entity data.

optional; integer; Standardwert: null.

condition

Condition for including the variable value.

optional; string; Standardwert: null.

conditionsExclude

Conditions that must be excluded during generation.

optional; string; Standardwert: null.

conditionsInclude

Conditions that must be included during generation.

optional; string; Standardwert: null.

constant

Constant value for variable data.

optional; string; Standardwert: null.

converter

Converter for variable data transformation.

optional; string; Standardwert: null.

cyclic

Enable or disable cyclic generation for variables.

optional; boolean; Standardwert: null.

database

Database client id when source equals 'database'.

optional; string; Standardwert: null.

dataset

Dataset for variable data.

optional; string; Standardwert: null.

defaultValue

Default value for the variable.

optional; string; Standardwert: null.

distribution

Distribution type for data generation.

optional; string; Standardwert: null; Werte: ordered, random, weighted, stratified, round_robin, reservoir, cumulated.

entity

Entity type for the variable.

optional; string; Standardwert: null.

generator

Generator for variable data.

optional; string; Standardwert: null.

inDateFormat

Input date format for variable data.

optional; string; Standardwert: null.

iterationSelector

Selector for iteration of variable data.

optional; string; Standardwert: null.

locale

Locale for variable data.

optional; string; Standardwert: null.

name

Name of the variable.

erforderlich; string.

outDateFormat

Output date format for variable data.

optional; string; Standardwert: null.

paged

Enable paged DB variable behavior for selectors.

optional; boolean; Standardwert: null.

pattern

Pattern for variable data generation.

optional; string; Standardwert: null.

rngSeed

Deterministic RNG seed for this variable.

optional; integer; Standardwert: null.

script

Script for variable data generation.

optional; string; Standardwert: null.

selector

Selector for variable data generation.

optional; string; Standardwert: null.

separator

Separator for variable data.

optional; string; Standardwert: null.

source

Literal project-file, memstore, database, or Mongo source; expressions remain lazy.

optional; string; Standardwert: null.

sourceClient

Override the client used to load variable data.

optional; string; Standardwert: null.

sourceEntity

Explicit physical entity to read (table/collection/product).

optional; string; Standardwert: null.

sourceScripted

Enable or disable scripted sources.

optional; boolean; Standardwert: null.

storage

Variable storage strategy.

optional; string; Standardwert: null; Werte: value, data, iterator.

stratifyBy

Stratum column for distribution='stratified' source selection.

optional; string; Standardwert: null.

string

String for the variable data generation.

optional; string; Standardwert: null.

type

Data type of the variable.

optional; string; Standardwert: null; Werte: string, int, integer, float, bool, binary.

unique

Emit each value at most once (distinct picks from values, no replacement).

optional; boolean; Standardwert: null.

values

Comma-separated list of values for the variable.

optional; string; Standardwert: null.

variablePrefix

Prefix before field's name for query select data in selector element

optional; string; Standardwert: null.

variableSuffix

Suffix after field's name for query select data in selector element

optional; string; Standardwert: null.

weightColumn

Weight column for variable data generation; required for a .wgt.ent.csv source.

optional; string; Standardwert: null.

weights

Comma-separated relative weights, one per values entry, for weighted random selection.

optional; string; Standardwert: null.