Membership · #

🟢 5 of 5 forms all ok · VTL 2.2 Reference Manual ↗ · vtlengine 1.10.0rc3 (9e1c81a6) · pandas 2.3.3 · DuckDB 1.5.5
🟢 all ok🟡 partially implemented🛡️ refused with an error🔴 not implemented or crash🔵 engines differ ✅ match · ❌ wrong result · 🛡 guarded error (code) · 💥 crash · 📌 team decision
        ---
config:
  flowchart:
    useMaxWidth: false

---
flowchart LR
    classDef ok fill:#d4edda,stroke:#28a745,color:#000
    classDef partial fill:#fff3cd,stroke:#ffc107,color:#000
    classDef refused fill:#d4edda,stroke:#28a745,stroke-width:3px,stroke-dasharray: 2 2,color:#000
    classDef missing fill:#f8d7da,stroke:#dc3545,color:#000
    classDef diverge fill:#cce5ff,stroke:#007bff,color:#000
    classDef block fill:#2b3a4a,stroke:#2b3a4a,color:#fff,font-weight:bold
    classDef ext fill:#fff,stroke:#666,color:#000,stroke-dasharray: 5 5
    O["Membership · #35; 📌<br/>🟢5"]:::ok
    v_identifier["DS#35;Id 📌"]:::ok
    v_measure["DS#35;Me 📌"]:::ok
    v_attribute["DS#35;At"]:::ok
    v_viral_attribute["DS#35;At (viral) 📌"]:::ok
    v_on_aggregate["agg(DS)#35;Me"]:::ok
    v_identifier --- O
    v_measure --- O
    v_attribute --- O
    O --- v_viral_attribute
    O --- v_on_aggregate
    click v_identifier href "#form-identifier"
    click v_measure href "#form-measure"
    click v_attribute href "#form-attribute"
    click v_viral_attribute href "#form-viral-attribute"
    click v_on_aggregate href "#form-on-aggregate"
    

Types

Takes any scalar · Gives any type

Comes from: any operator that returns a value

Goes to: whatever takes its input's type

Forms

DS#Id 🟢 · any scalar → any type

Manual example 2 🟢 pandas ✅ · DuckDB ✅
Tests:

DS_1#Id_1: the values of an identifier become a new measure, named for its type.

Manual:

Membership, Example 2, output verbatim: “If comp is an Identifier or an Attribute Component in ds, then all the existing Measures of ds are dropped in the result and a new Measure is added.”

Expected:

Id_1, Id_2 and the measure int_var with the values of Id_1; the measures and the non-viral At_1 are dropped.

script.vtl
DS_r := DS_1#Id_1;
Input DS_1
Id_1Id_2Me_1Me_2At_1
1A15
1B210P
2A312
Expected DS_r
Id_1Id_2int_var
1A1
1B1
2A2

Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

Manual example 5 🟢 pandas ✅ · DuckDB ✅
Tests:

DS_2#Id_1 on a dataset whose At_1 is viral: the new measure, and At_1 kept.

Manual:

Membership, Example 5, output verbatim: “viral Attributes of ds are maintained in the result as viral”. The manual’s ds_2.json names its dataset DS_1, a slip: the example loads it as DS_2, the name that the page and the script give it.

Expected:

Id_1, Id_2, the measure int_var with the values of Id_1, and the viral At_1.

Team decision:

#1257: as the comments on sdmx-twg/vtl#731 propose, a viral Attribute needs a propagation rule only where its values are combined, until the VTL Task Force discusses it.

script.vtl
DS_r := DS_2#Id_1;
Input DS_2
Id_1Id_2Me_1Me_2At_1
1A15
1B210P
2A312
Expected DS_r
Id_1Id_2int_varAt_1
1A1
1B1P
2A2

Files: script.vtl · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

DS#Me 🟢 · any scalar → any type

Manual example 1 🟢 pandas ✅ · DuckDB ✅
Tests:

DS_1#Me_1: the measure is kept, and the other measure and the non-viral attribute are dropped.

Manual:

Membership, Example 1, output verbatim: “If comp is a Measure in ds, then comp is maintained in the result while all other Measures are dropped.”

Expected:

Id_1, Id_2 and Me_1.

script.vtl
DS_r := DS_1#Me_1;
Input DS_1
Id_1Id_2Me_1Me_2At_1
1A15
1B210P
2A312
Expected DS_r
Id_1Id_2Me_1
1A1
1B2
2A3

Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

Manual example 4 🟢 pandas ✅ · DuckDB ✅
Tests:

DS_2#Me_1 on a dataset whose At_1 is viral: the viral attribute is kept.

Manual:

Membership, Example 4, output verbatim: “viral Attributes of ds are maintained in the result as viral, non-viral ones are dropped”. The manual’s ds_2.json names its dataset DS_1, a slip: the example loads it as DS_2, the name that the page and the script give it.

Expected:

Id_1, Id_2, Me_1 and the viral At_1.

Team decision:

#1257: as the comments on sdmx-twg/vtl#731 propose, a viral Attribute needs a propagation rule only where its values are combined, until the VTL Task Force discusses it.

script.vtl
DS_r := DS_2#Me_1;
Input DS_2
Id_1Id_2Me_1Me_2At_1
1A15
1B210P
2A312
Expected DS_r
Id_1Id_2Me_1At_1
1A1
1B2P
2A3

Files: script.vtl · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

DS#At 🟢 · any scalar → any type

Manual example 3 🟢 pandas ✅ · DuckDB ✅
Tests:

DS_1#At_1 on a non-viral attribute: its values become a new measure, and the attribute itself is dropped.

Manual:

Membership, Example 3: “A default conventional name is assigned to the new Measure depending on its type: for example num_var if the Measure is numeric, string_var if it is string”.

Expected:

Id_1, Id_2 and a String measure with the values of At_1; the values are the manual’s.

Adaptation:

The manual names the new measure string_var; the expected output names it str_var, vtlengine’s default name for a String measure, documented in docs/data_types.rst. Default names “can be personalised in the implementations” (Typical behaviour).

script.vtl
DS_r := DS_1#At_1;
Input DS_1
Id_1Id_2Me_1Me_2At_1
1A15
1B210P
2A312
Expected DS_r
Id_1Id_2str_var
1A
1BP
2A

Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

Dataset without identifiers 🟢 pandas ✅ · DuckDB ✅
Tests:

The scalar rule for an attribute, the case that Manual example 8 meant: on a dataset with no identifiers, DS_1#At_1 gives the value of At_1.

Manual:

Membership: “If ds has no Identifier Components (for example is a result of an aggregate invocation), comp must be a Data Set Component of the Data Set ds (a Measure or an Attribute). In this case the operator returns a scalar value equal to the value of comp in ds”.

Expected:

SC_r = "P", a String. DS_1 is given as it is, without identifiers, because an aggregation would drop the non-viral At_1.

script.vtl
SC_r := DS_1#At_1;
Input DS_1
Me_1At_1
5P
Expected scalars

Name

Type

Value

SC_r

String

"P"

Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/scalars.json · example page ↗

DS#At (viral) 🟢 · any scalar → any type

Manual example 6 🟢 pandas ✅ · DuckDB ✅
Tests:

DS_2#At_1 on a viral attribute: a new measure with its values, and At_1 kept as viral.

Manual:

Membership, Example 6: “If comp is an Attribute, it follows the Attribute propagation rule too”, and the result has “a single Measure”. The manual’s ds_2.json names its dataset DS_1, a slip: the example loads it as DS_2, the name that the page and the script give it.

Expected:

Id_1, Id_2, str_var with the values of At_1, and the viral At_1; the values are the manual’s.

Adaptation:

string_var is written str_var, as in Manual example 3.

Team decision:

#1257: as the comments on sdmx-twg/vtl#731 propose, a viral Attribute needs a propagation rule only where its values are combined, until the VTL Task Force discusses it.

script.vtl
DS_r := DS_2#At_1;
Input DS_2
Id_1Id_2Me_1Me_2At_1
1A15
1B210P
2A312
Expected DS_r
Id_1Id_2str_varAt_1
1A
1BPP
2A

Files: script.vtl · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

Manual example 8 🟢 pandas ✅ · DuckDB ✅
Tests:

SC_r := DS_2#At_1 on a viral attribute of a dataset that has identifiers.

Manual:

Membership, Example 8: “The membership operator returns a Data Set having the same Identifier Components of ds and a single Measure.” As in Manual example 6, ds_2.json names its dataset DS_1.

Expected:

The dataset of Manual example 6, assigned to SC_r.

Erratum:

The manual expects the scalar "P", but the scalar rule is for a dataset without identifiers, and DS_2 has Id_1, Id_2 and three data points, so the general rule gives a dataset. The scalar case has its own example, Dataset without identifiers.

Adaptation:

string_var is written str_var, as in Manual example 3.

Team decision:

#1257: as the comments on sdmx-twg/vtl#731 propose, a viral Attribute needs a propagation rule only where its values are combined, until the VTL Task Force discusses it.

script.vtl
SC_r := DS_2#At_1;
Input DS_2
Id_1Id_2Me_1Me_2At_1
1A15
1B210P
2A312
Expected SC_r
Id_1Id_2str_varAt_1
1A
1BPP
2A

Files: script.vtl · input/DS_2.csv · input/DS_2.json · expected/SC_r.csv · expected/SC_r.json · example page ↗

agg(DS)#Me 🟢 · any scalar → any type

Manual example 7 🟢 pandas ✅ · DuckDB ✅
Tests:

max(DS_1)#Me_1: membership on the result of an aggregate invocation, which has no identifiers, gives a scalar.

Manual:

Membership, Example 7, output verbatim: “If ds has no Identifier Components (for example is a result of an aggregate invocation), […] the operator returns a scalar value equal to the value of comp in ds”.

Expected:

max(DS_1) has one data point, Me_1 = 3 and Me_2 = 12, so SC_r = 3, an Integer.

script.vtl
SC_r := max(DS_1)#Me_1;
Input DS_1
Id_1Id_2Me_1Me_2At_1
1A15
1B210P
2A312
Expected scalars

Name

Type

Value

SC_r

Integer

"3"

Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/scalars.json · example page ↗