← in operator page · comparison/in/comp_set/manual_ex_2

Manual example 2 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

Me_1 in { 0, 3, 6, 12 } inside calc, where the new measure Me_2 takes the result.

Manual:

Element of, Example 2, output verbatim: "The in operator returns true if op belongs to the collection, false otherwise."

Expected:

Me_2 is true for BS and MO, and false for GZ, SQ, FJ and CQ; Me_1 is kept.

script.vtl ⇩

DS_r := DS_1 [ calc Me_2:= Me_1 in { 0, 3, 6, 12 } ];

input/DS_1.csv ⇩

Id_1Id_2Me_1
2012BS0
2012GZ4
2012SQ9
2012MO6
2012FJ7
2012CQ2

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": "Me_1", "type": "Integer", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Id_2Me_1Me_2
2012BS0true
2012GZ4false
2012SQ9false
2012MO6true
2012FJ7false
2012CQ2false

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": "Me_1", "type": "Integer", "role": "Measure"},
        {"name": "Me_2", "type": "Boolean", "role": "Measure"}
      ]
    }
  ]
}