← in operator page · comparison/in/ds_set/manual_ex_1

Manual example 1 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

DS_1 in { 0, 3, 6, 12 }: every measure value of DS_1 against a set literal.

Manual:

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

Expected:

bool_var is true for BS (0) and MO (6), and false for GZ, SQ, FJ and CQ (4, 9, 7 and 2).

script.vtl ⇩

DS_r := DS_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_2bool_var
2012BStrue
2012GZfalse
2012SQfalse
2012MOtrue
2012FJfalse
2012CQfalse

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": "bool_var", "type": "Boolean", "role": "Measure"}
      ]
    }
  ]
}