← in operator page · comparison/in/ds_value_domain/manual_ex_3

Manual example 3 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

DS_1#Id_2 in myGeoValueDomain: the identifier Id_2, taken as a measure by the membership operator, against a value domain.

Manual:

Element of, Example 3, output verbatim: "The in operator returns true if op belongs to the collection, false otherwise." The page defines the Value Domain myGeoValueDomain (string) in the text before its examples, not in their files, as {"AF", "BS", "FJ", "GA", "KH", "MO", "PK", "QA", "UG"}; it is passed to run as value_domains/myGeoValueDomain.json.

Expected:

bool_var is true for BS, MO and FJ, which are elements of the value domain, and false for GZ, SQ and CQ, which are not.

script.vtl ⇩

DS_r := DS_1#Id_2 in myGeoValueDomain;

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
2012FJtrue
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"}
      ]
    }
  ]
}

value_domains/myGeoValueDomain.json ⇩

{
  "name": "myGeoValueDomain",
  "setlist": [
    "AF",
    "BS",
    "FJ",
    "GA",
    "KH",
    "MO",
    "PK",
    "QA",
    "UG"
  ],
  "type": "String"
}