Membership · #
---
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
compis an Identifier or an Attribute Component inds, then all the existing Measures ofdsare dropped in the result and a new Measure is added.”- Expected:
Id_1,Id_2and the measureint_varwith the values ofId_1; the measures and the non-viralAt_1are dropped.
DS_r := DS_1#Id_1;
| Id_1 | Id_2 | Me_1 | Me_2 | At_1 |
|---|---|---|---|---|
| 1 | A | 1 | 5 | |
| 1 | B | 2 | 10 | P |
| 2 | A | 3 | 12 |
| Id_1 | Id_2 | int_var |
|---|---|---|
| 1 | A | 1 |
| 1 | B | 1 |
| 2 | A | 2 |
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_1on a dataset whoseAt_1is viral: the new measure, andAt_1kept.- Manual:
Membership, Example 5, output verbatim: “viral Attributes of
dsare maintained in the result as viral”. The manual’sds_2.jsonnames its datasetDS_1, a slip: the example loads it asDS_2, the name that the page and the script give it.- Expected:
Id_1,Id_2, the measureint_varwith the values ofId_1, and the viralAt_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.
DS_r := DS_2#Id_1;
| Id_1 | Id_2 | Me_1 | Me_2 | At_1 |
|---|---|---|---|---|
| 1 | A | 1 | 5 | |
| 1 | B | 2 | 10 | P |
| 2 | A | 3 | 12 |
| Id_1 | Id_2 | int_var | At_1 |
|---|---|---|---|
| 1 | A | 1 | |
| 1 | B | 1 | P |
| 2 | A | 2 |
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
compis a Measure inds, thencompis maintained in the result while all other Measures are dropped.”- Expected:
Id_1,Id_2andMe_1.
DS_r := DS_1#Me_1;
| Id_1 | Id_2 | Me_1 | Me_2 | At_1 |
|---|---|---|---|---|
| 1 | A | 1 | 5 | |
| 1 | B | 2 | 10 | P |
| 2 | A | 3 | 12 |
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | A | 1 |
| 1 | B | 2 |
| 2 | A | 3 |
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_1on a dataset whoseAt_1is viral: the viral attribute is kept.- Manual:
Membership, Example 4, output verbatim: “viral Attributes of
dsare maintained in the result as viral, non-viral ones are dropped”. The manual’sds_2.jsonnames its datasetDS_1, a slip: the example loads it asDS_2, the name that the page and the script give it.- Expected:
Id_1,Id_2,Me_1and the viralAt_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.
DS_r := DS_2#Me_1;
| Id_1 | Id_2 | Me_1 | Me_2 | At_1 |
|---|---|---|---|---|
| 1 | A | 1 | 5 | |
| 1 | B | 2 | 10 | P |
| 2 | A | 3 | 12 |
| Id_1 | Id_2 | Me_1 | At_1 |
|---|---|---|---|
| 1 | A | 1 | |
| 1 | B | 2 | P |
| 2 | A | 3 |
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_1on 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_varif the Measure isnumeric,string_varif it isstring”.- Expected:
Id_1,Id_2and a String measure with the values ofAt_1; the values are the manual’s.- Adaptation:
The manual names the new measure
string_var; the expected output names itstr_var, vtlengine’s default name for a String measure, documented indocs/data_types.rst. Default names “can be personalised in the implementations” (Typical behaviour).
DS_r := DS_1#At_1;
| Id_1 | Id_2 | Me_1 | Me_2 | At_1 |
|---|---|---|---|---|
| 1 | A | 1 | 5 | |
| 1 | B | 2 | 10 | P |
| 2 | A | 3 | 12 |
| Id_1 | Id_2 | str_var |
|---|---|---|
| 1 | A | |
| 1 | B | P |
| 2 | A |
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_1gives the value ofAt_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
compinds”.- Expected:
SC_r = "P", a String.DS_1is given as it is, without identifiers, because an aggregation would drop the non-viralAt_1.
SC_r := DS_1#At_1;
| Me_1 | At_1 |
|---|---|
| 5 | P |
Name |
Type |
Value |
|---|---|---|
|
String |
|
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/scalars.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
compinds”.- Expected:
max(DS_1)has one data point,Me_1 = 3andMe_2 = 12, soSC_r = 3, an Integer.
SC_r := max(DS_1)#Me_1;
| Id_1 | Id_2 | Me_1 | Me_2 | At_1 |
|---|---|---|---|---|
| 1 | A | 1 | 5 | |
| 1 | B | 2 | 10 | P |
| 2 | A | 3 | 12 |
Name |
Type |
Value |
|---|---|---|
|
Integer |
|
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/scalars.json · example page ↗