Zum Inhalt

Element <execute>

Zweck: Führt vertrauenswürdigen Python-, SQL- oder Bash-Code aus einer URI, einem Ausdruck oder einem Inline-Body aus.

Warum: Verwende dieses Element an einer expliziten Vertrauensgrenze für Projektskripte oder clientbezogenes SQL.

Beispiel

1
<execute/>

Entscheidungshilfe

Fachlicher Nutzen: Stellt eine explizite Vertrauensgrenze für Setup-Code oder clientbezogenes SQL bereit.

  • Verwenden, wenn

    • Beim Ausführen eines geprüften Python-/Bash-Projektskripts oder expliziten SQLs.
  • Anderen Ansatz wählen, wenn

    • Wenn ein eingebautes DSL-Element das Verhalten ausdrückt oder der Code nicht vertrauenswürdig ist.
  • Voraussetzungen

    • Wähle genau eine Codequelle und liefere erforderliche Typ- oder Zielinformationen.
  • Alternativen

    • Verwende generate für deklarative Datenerzeugung und Transformation. (Siehe: <generate>)
    • Verwende assert für ein deklaratives hartes Quality Gate. (Siehe: <assert>)

Vollständige Beispiele

Eine zustandsbehaftete Generatorinstanz registrieren und wiederverwenden

Verwende einen benannten Generator, wenn mehrere Felder oder Tasks bewusst dieselbe konfigurierte Generatorinstanz statt unabhängiger Instanzen nutzen sollen.

named-generator/script/preflight.scr.py
1
assert 2 + 2 == 4
named-generator/datamimic.xml
1
2
3
4
5
6
7
<setup>
    <execute uri="script/preflight.scr.py"/>
    <generator name="document_sequence" generator="IncrementGenerator(start=100)"/>
    <generate name="documents" count="3" target="LogExporter">
        <id name="document_id" generator="document_sequence"/>
    </generate>
</setup>

Regeln und ungültige Kombinationen

I614 — Parser Execute Invalid Source

requires exactly one code source: uri (a script file), inline text, or script (an expression).

Warum: has no code source or combines uri, inline text, and script even though they are alternatives.

Lösung: Provide exactly one source: uri= for a file, script= with type=, or an inline element body.

Vollständige Regel

I897 — Parser Execute Type Unresolved

: cannot infer execution type from the file extension; set an explicit type=.

Warum: The uri has no recognised extension and no explicit type= was given.

Lösung: Set type= (python, sql, or bash), or use a uri with a recognised extension.

Vollständige Regel

I823 — Task Execute Client Not Found

Client '{client_id}' not found for task. Check your project environment configuration.

Warum: The referenced client could not be found for the task configuration.

Lösung: Ensure the referenced client exists and the identifier/path is correct.

Vollständige Regel

I824 — Task Execute Script Not Found

Script file '{script_name}' not found in task workspace. Check your project environment configuration or uploaded script assets.

Warum: The referenced script could not be found for the task configuration.

Lösung: Ensure the referenced script exists and the identifier/path is correct.

Vollständige Regel

I873 — Task Execute SQL Failed

Failed to execute SQL script '{script_name}' on client '{client_id}': {error_type}{error_code_hint}{error_category_hint}: {error}

Warum: SQL execution failed while running the task against the configured client.

Lösung: Review client configuration, SQL statement, and database permissions before retrying.

Vollständige Regel

I894 — Task Execute Bash Failed

failed (exit {exit_code}): {detail}

Warum: The shell command run by returned a non-zero exit status.

Lösung: Fix the shell command or its environment; inspect the reported stderr/exit code.

Vollständige Regel

Inhaltsformen

  • uri — Load code from the uri attribute; the file extension determines its execution type.
  • Erforderliche Attribute: uri
  • script — Evaluate the script attribute to obtain the code to execute.
  • Erforderliche Attribute: script
  • inline — Use the element body as the code to execute.
  • Erforderliche Attribute: Keine

Erlaubte Elternelemente / Erlaubte Kindelemente

Erlaubte Elternelemente: else, else-if, if, nestedKey, setup, while

Erlaubte Kindelemente:

Keine

Attribute

Alle 4 Attribute anzeigen

script

Expression whose evaluated string value IS the code to run. Needs type. Mutually exclusive with uri.

optional; string; Standardwert: null.

target

Client id to execute a SQL script against (e.g. a id).

optional; string; Standardwert: null.

type

Execution type for script= (python, sql or bash). Inferred from the extension for uri=.

optional; string; Standardwert: null; Werte: python, sql, bash.

uri

URI of a script file to execute (.py or .sql). Mutually exclusive with script.

optional; string; Standardwert: null.