← equal operator page · comparison/equal/comp_sc/manual_ex_2

Manual example 2 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

Me_1 = 0.08 inside calc, where the new measure Me_2 takes the result.

Manual:

Equal to, Example 2, output verbatim: "The operator returns true if the left is equal to right, false otherwise."

Expected:

Me_2 is true for F and W, false for G, S and M, and null for B, whose Me_1 is null; Me_1 is kept.

script.vtl ⇩

DS_r := DS_1 [ calc Me_2 := Me_1 = 0.08 ];

input/DS_1.csv ⇩

Id_1Id_2Id_3Id_4Me_1
2012BTotalTotal
2012GTotalTotal0.286
2012STotalTotal0.064
2012MTotalTotal0.043
2012FTotalTotal0.08
2012WTotalTotal0.08

input/DS_1.json ⇩

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

expected/DS_r.csv ⇩

Id_1Id_2Id_3Id_4Me_1Me_2
2012BTotalTotal
2012GTotalTotal0.286false
2012STotalTotal0.064false
2012MTotalTotal0.043false
2012FTotalTotal0.08true
2012WTotalTotal0.08true

expected/DS_r.json ⇩

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