Subspace · sub
---
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["Subspace · sub<br/>🟢2"]:::ok
v_one_id["DS#91;sub Id = value#93;"]:::ok
v_multi_id["DS#91;sub Id = value, Id = value#93;"]:::ok
v_one_id --- O
O --- v_multi_id
click v_one_id href "#form-one-id"
click v_multi_id href "#form-multi-id"
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[sub Id = value] 🟢 · any scalar → any type
Manual example 3 🟢 pandas ✅ · DuckDB ✅
- Tests:
DS_1 [ sub Id_2 = "A" ] + DS_1 [ sub Id_2 = "B" ]: two subspaces on one identifier, added.- Manual:
Subspace, Example 3, output verbatim: “It maintains the Data Points of VDS for which identifier = value”, then “It projects out (“drops”, in VTL terms) all the identifier (s)”.
- Expected:
Both subspaces have
Id_1andId_3, and the sum pairs their data points on them:(1,XX)= 20 + 4 = 24,(1,YY)= 10,(2,XX)= 19 and(2,YY)= 20.At_1is non-viral, so the sum does not keep it: “the non-viral Attributes are not kept in the result” (User Manual).
DS_r := DS_1 [ sub Id_2 = "A" ] + DS_1 [ sub Id_2 = "B" ];
| Id_1 | Id_2 | Id_3 | Me_1 | At_1 |
|---|---|---|---|---|
| 1 | A | XX | 20 | F |
| 1 | A | YY | 1 | F |
| 1 | B | XX | 4 | E |
| 1 | B | YY | 9 | F |
| 2 | A | XX | 7 | F |
| 2 | A | YY | 5 | E |
| 2 | B | XX | 12 | F |
| 2 | B | YY | 15 | F |
| Id_1 | Id_3 | Me_1 |
|---|---|---|
| 1 | XX | 24 |
| 1 | YY | 10 |
| 2 | XX | 19 |
| 2 | YY | 20 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
Fixed identifier dropped 🟢 pandas ✅ · DuckDB ✅
- Tests:
sub Id_1 = 1, alone, on one of two identifiers.- Manual:
Subspace: “It maintains the Data Points of VDS for which identifier = value (for all the specified identifier) and eliminates all the Data Points for which identifier <> value”, then “It projects out (“drops”, in VTL terms) all the identifier (s)”.
- Expected:
(1,A)= 10 and(1,B)= 20 are kept and(2,A)= 30 is eliminated;Id_1is projected out, leavingId_2andMe_1. Manual example 3 adds two subspaces with+; this one showssubalone.
DS_r := DS_1 [ sub Id_1 = 1 ];
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | A | 10 |
| 1 | B | 20 |
| 2 | A | 30 |
| Id_2 | Me_1 |
|---|---|
| A | 10 |
| B | 20 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
DS[sub Id = value, Id = value] 🟢 · any scalar → any type
Manual example 1 🟢 pandas ✅ · DuckDB ✅
- Tests:
sub Id_1 = 1, Id_2 = "A": two of the three identifiers fixed.- Manual:
Subspace, Example 1, output verbatim: “It maintains the Data Points of VDS for which identifier = value (for all the specified identifier) and eliminates all the Data Points for which identifier <> value (even for only one specified identifier)”, then “It projects out (“drops”, in VTL terms) all the identifier (s)”.
- Expected:
The two data points with
Id_1= 1 andId_2=A, without these two identifiers:Id_3,Me_1andAt_1=XX, 20,FandYY, 1,F.
DS_r := DS_1 [ sub Id_1 = 1, Id_2 = "A" ];
| Id_1 | Id_2 | Id_3 | Me_1 | At_1 |
|---|---|---|---|---|
| 1 | A | XX | 20 | F |
| 1 | A | YY | 1 | F |
| 1 | B | XX | 4 | E |
| 1 | B | YY | 9 | F |
| 2 | A | XX | 7 | F |
| 2 | A | YY | 5 | E |
| 2 | B | XX | 12 | F |
| 2 | B | YY | 15 | F |
| Id_3 | Me_1 | At_1 |
|---|---|---|
| XX | 20 | F |
| YY | 1 | F |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
Manual example 2 🟢 pandas ✅ · DuckDB ✅
- Tests:
sub Id_1 = 1, Id_2 = "B", Id_3 = "YY": every identifier fixed.- Manual:
Subspace, Example 2, output verbatim: “The resulting Data Set has the Identifier Components that are not specified as identifier (s) and has the same Measure and Attribute Components of the input Data Set.”
- Expected:
The data point
(1,B,YY)alone, with no identifiers:Me_1= 9 andAt_1=F.
DS_r := DS_1 [ sub Id_1 = 1, Id_2 = "B", Id_3 = "YY" ];
| Id_1 | Id_2 | Id_3 | Me_1 | At_1 |
|---|---|---|---|---|
| 1 | A | XX | 20 | F |
| 1 | A | YY | 1 | F |
| 1 | B | XX | 4 | E |
| 1 | B | YY | 9 | F |
| 2 | A | XX | 7 | F |
| 2 | A | YY | 5 | E |
| 2 | B | XX | 12 | F |
| 2 | B | YY | 15 | F |
| Me_1 | At_1 |
|---|---|
| 9 | F |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗