Filtering Data Points · filter

🟢 1 of 1 form 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["Filtering Data Points · filter<br/>🟢1"]:::ok
    v_basic["DS#91;filter cond#93;"]:::ok
    subgraph G_use["Used with"]
        direction LR
        used__join__inner_join["inner_join ↗<br/><small>used by</small>"]:::ext
        used__join__left_join["left_join ↗<br/><small>used by</small>"]:::ext
        used__join__full_join["full_join ↗<br/><small>used by</small>"]:::ext
        used__join__cross_join["cross_join ↗<br/><small>used by</small>"]:::ext
    end
    v_basic --- O
    O -.- G_use
    style G_use fill:#ffffff,stroke:#868e96,stroke-width:1px,stroke-dasharray: 1 4
    click v_basic href "#form-basic"
    click used__join__inner_join href "../join/inner_join.html" "Inner Join · inner_join"
    click used__join__left_join href "../join/left_join.html" "Left Join · left_join"
    click used__join__full_join href "../join/full_join.html" "Full Join · full_join"
    click used__join__cross_join href "../join/cross_join.html" "Cross Join · cross_join"
    

Types

Takes boolean, any scalar · Gives any type

Comes from: any operator that returns a value

Goes to: whatever takes its input's type

Forms

DS[filter cond] 🟢 · any scalar, boolean → any type

Manual example 1 🟢 pandas ✅ · DuckDB ✅
Tests:

filter Id_1 = 1 and Me_1 < 10: a condition on an identifier and a measure.

Manual:

Filtering Data Points, Example 1, output verbatim: “When the expression is true the Data Point is kept in the result, otherwise it is not kept”.

Expected:

The three data points with Id_1 = 1 and Me_1 below 10, with their At_1: (1,A,XX) = 2, (1,A,YY) = 2 and (1,B,YY) = 1.

script.vtl
DS_r := DS_1 [ filter Id_1 = 1 and Me_1 < 10 ];
Input DS_1
Id_1Id_2Id_3Me_1At_1
1AXX2E
1AYY2F
1BXX20F
1BYY1F
2AXX4E
2AYY9F
Expected DS_r
Id_1Id_2Id_3Me_1At_1
1AXX2E
1AYY2F
1BYY1F

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

Null condition filtered out 🟢 pandas ✅ · DuckDB ✅
Tests:

filter Me_1 > 10, where Me_1 is null on one data point, so the condition is null there.

Manual:

Filtering Data Points: “it filters out the Data Points of the operand Data Set for which filterCondition condition evaluates to false or null”.

Expected:

Id_1 = 3 and 4 (15 and 20) are kept; Id_1 = 1 (5, false) and Id_1 = 2 (null) are filtered out.

script.vtl
DS_r := DS_1 [ filter Me_1 > 10 ];
Input DS_1
Id_1Me_1
15
2
315
420
Expected DS_r
Id_1Me_1
315
420

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