Hydra ETL
Build your first job
Hydra DSL7 · Expressionsscript.code
Grammar element · script.code

script.code runs inside a declared boundary

Row and vectorized scripts stay explicit about inputs, outputs, types, and mode.

transformations.yaml4 steps

      
What the engine exposes

Only declared inputs, approved builtins, and assignments to declared outputs.

✓ row script · 30 rows

What script.code is

script.code is restricted Python executed inside an explicit input/output contract.

It is not an escape to the host Python process. Imports are unavailable, builtins are allow-listed, and outputs must be declared before code runs.

What it contains

  • Assignments and expressions — Code that derives declared output variables.
  • Approved builtins — Common numeric, collection, iteration, formatting, and type helpers.
  • No ambient access — Inputs are declared columns; outputs are declared names and types.

The contract is larger than the code

Read inputs, outputs, and mode before reading the code block. They define what the script may consume, must produce, and how values appear during execution.

Script code is enclosed by an input-output contract The amount input enters restricted code and produces declared typed output columns. inputs: amountdeclared access restricted coderow or Series typed outputsdeclared result The code cannot widen its own contract after execution starts.
Custom logic remains reviewable because its boundary is YAML.

Run the complete example

Copy this manifest from the verified documentation project, then run it from the repository root.

version: "1.0"
transformations:
  steps:
    - cast:
        mapping: {amount: float}
    - script:
        inputs: [amount]
        outputs: {amount_with_tax: float}
        mode: row
        code: |
          amount_with_tax = amount * 1.2
hdrctl run examples/tutorial/dsl-elements -t script.yaml
  ✅ Pipeline completed successfully in 2.4s
  Rows read   : 30
  Rows written: 30

The relevant command syntax, copied from hdrctl run --help:

hdrctl run [PATH]
  -s, --sources FILE          explicit path to sources.yaml
  -d, --destinations FILE     explicit path to destinations.yaml
  -t, --transformations FILE  explicit path to transformations.yaml
  -P, --param KEY=VALUE       override a parameter, repeatable

Close by

0 / 0 on this page