Subspace · sub

🟢 2 of 2 forms all ok · VTL 2.2 Reference Manual ↗ · vtlengine 1.10.0rc2 (90ee9376) · 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["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_1 and Id_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_1 is non-viral, so the sum does not keep it: “the non-viral Attributes are not kept in the result” (User Manual).

script.vtl
DS_r := DS_1 [ sub Id_2 = "A" ] + DS_1 [ sub Id_2 = "B" ];
Input DS_1
Id_1Id_2Id_3Me_1At_1
1AXX20F
1AYY1F
1BXX4E
1BYY9F
2AXX7F
2AYY5E
2BXX12F
2BYY15F
Expected DS_r
Id_1Id_3Me_1
1XX24
1YY10
2XX19
2YY20

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_1 is projected out, leaving Id_2 and Me_1. Manual example 3 adds two subspaces with +; this one shows sub alone.

script.vtl
DS_r := DS_1 [ sub Id_1 = 1 ];
Input DS_1
Id_1Id_2Me_1
1A10
1B20
2A30
Expected DS_r
Id_2Me_1
A10
B20

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 and Id_2 = A, without these two identifiers: Id_3, Me_1 and At_1 = XX, 20, F and YY, 1, F.

script.vtl
DS_r := DS_1 [ sub Id_1 = 1, Id_2 = "A" ];
Input DS_1
Id_1Id_2Id_3Me_1At_1
1AXX20F
1AYY1F
1BXX4E
1BYY9F
2AXX7F
2AYY5E
2BXX12F
2BYY15F
Expected DS_r
Id_3Me_1At_1
XX20F
YY1F

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 and At_1 = F.

script.vtl
DS_r := DS_1 [ sub Id_1 = 1, Id_2 = "B", Id_3 = "YY" ];
Input DS_1
Id_1Id_2Id_3Me_1At_1
1AXX20F
1AYY1F
1BXX4E
1BYY9F
2AXX7F
2AYY5E
2BXX12F
2BYY15F
Expected DS_r
Me_1At_1
9F

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