← parentheses operator page · general/parentheses/ds/manual_ex_1

Manual example 1 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

(DS_1 + DS_2) * DS_2: the sum in the parentheses comes first, then the product with DS_2, on the data points that the operands share.

Manual:

Parentheses, Example 1, output verbatim: "The part of the expression inside the parentheses is evaluated before the part outside of the parentheses."

Expected:

Only (10, A) and (11, B) are in both datasets: Me_1 is (5 + 10) * 10 = 150 and (4 + 6) * 6 = 60, an Integer, and Me_2 is (5.0 + 3.0) * 3.0 = 24.0 and (20.3 + 7.0) * 7.0 = 191.1, a Number. Without the parentheses, (10, A) would give 105 and 14.0.

script.vtl ⇩

DS_r := (DS_1 + DS_2) * DS_2;

input/DS_1.csv ⇩

Id_1Id_2Me_1Me_2
10A55.0
10B210.5
11A312.2
11B420.3

input/DS_1.json ⇩

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

input/DS_2.csv ⇩

Id_1Id_2Me_1Me_2
10A103.0
10C116.2
11B67.0

input/DS_2.json ⇩

{
  "datasets": [
    {
      "name": "DS_2",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
        {"name": "Id_2", "type": "String", "role": "Identifier", "nullable": false},
        {"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true},
        {"name": "Me_2", "type": "Number", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Id_2Me_1Me_2
10A15024.0
11B60191.1

expected/DS_r.json ⇩

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