← define_operator operator page · definitions/define_operator/dataset/named_components

Named components 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

a dataset parameter whose constraints name its components, dataset { identifier<integer> Id_1, measure<integer> Me_1 }: the structure of DS_1.

Manual:

define operator: componentConstraint ::= componentType { componentName | multiplicityModifier }. The script ends with end operator, as the page's examples and the grammar do; its syntax line writes end define operator.

Expected:

Me_1 * 2 on each data point: (1, 20) and (2, 40).

script.vtl ⇩

define operator twice (ds dataset { identifier<integer> Id_1, measure<integer> Me_1 })
    returns dataset is
        ds * 2
end operator;

DS_r := twice(DS_1);

input/DS_1.csv ⇩

Id_1Me_1
110
220

input/DS_1.json ⇩

{
  "datasets": [
    {
      "name": "DS_1",
      "DataStructure": [
        {
          "name": "Id_1",
          "type": "Integer",
          "role": "Identifier",
          "nullable": false
        },
        {
          "name": "Me_1",
          "type": "Integer",
          "role": "Measure",
          "nullable": true
        }
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Me_1
120
240

expected/DS_r.json ⇩

{
  "datasets": [
    {
      "name": "DS_r",
      "DataStructure": [
        {
          "name": "Id_1",
          "type": "Integer",
          "role": "Identifier"
        },
        {
          "name": "Me_1",
          "type": "Integer",
          "role": "Measure"
        }
      ]
    }
  ]
}