Change of Component name · rename
---
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["Change of Component name · rename<br/>🟢2"]:::ok
v_basic["DS#91;rename comp to comp#93;"]:::ok
v_multiple["DS#91;rename comp to comp, comp to comp#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
v_multiple --- 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 v_multiple href "#form-multiple"
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 any scalar · Gives any type
Comes from: any operator that returns a value
Goes to: whatever takes its input's type
Forms
DS[rename comp to comp] 🟢 · any scalar → any type
Measure renamed 🟢 pandas ✅ · DuckDB ✅
- Tests:
rename Me_1 to Me_2: one measure renamed.- Manual:
Change of Component name: “Only the Component name is changed and not the Component Values”.
- Expected:
Me_2is a Measure of type Integer, with the values ofMe_1: 10 and 20.
DS_r := DS_1 [ rename Me_1 to Me_2 ];
| Id_1 | Me_1 |
|---|---|
| 1 | 10 |
| 2 | 20 |
| Id_1 | Me_2 |
|---|---|
| 1 | 10 |
| 2 | 20 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
Identifier renamed 🟢 pandas ✅ · DuckDB ✅
- Tests:
rename Id_2 to Id_3: an identifier renamed, where Manual example 1 of themultipleform renames a measure and an attribute.- Manual:
Change of Component name: “The operator assigns new names to one or more Components (Identifier, Measure or Attribute Components).”
- Expected:
Id_3stays an Identifier of type String, with the values ofId_2:AandB.
DS_r := DS_1 [ rename Id_2 to Id_3 ];
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | A | 10 |
| 1 | B | 20 |
| Id_1 | Id_3 | Me_1 |
|---|---|---|
| 1 | A | 10 |
| 1 | B | 20 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
New name already in operand 🟢 pandas ✅ · DuckDB ✅
- Tests:
rename Me_1 to Me_2, on a data set that already has the measureMe_2: the first error condition that the page states.- Manual:
Change of Component name: “the component used in the dsc_to cannot have the same names as other Components of the result Data Set”.
- Expected:
The error
1-1-6-8, “Cannot use component {comp_name} for rename, it is already in the Dataset {dataset_name}.”, for “The resulting Data Set, after renaming the specified Components, must have unique names of all its Components (otherwise a runtime error is raised)”: the result would have two components namedMe_2. The page calls it a runtime error, but a name clash is a condition on the structures alone, so vtlengine raises it as a SemanticError and no2-*message states it.
DS_r := DS_1 [ rename Me_1 to Me_2 ];
| Id_1 | Me_1 | Me_2 |
|---|---|---|
| 1 | 10 | 100 |
| 2 | 20 | 200 |
Expected error 1-1-6-8: Cannot use component {comp_name} for rename, it is already in the Dataset {dataset_name}.
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/error.json · example page ↗
DS[rename comp to comp, comp to comp] 🟢 · any scalar → any type
Manual example 1 🟢 pandas ✅ · DuckDB ✅
- Tests:
rename Me_1 to Me_2, At_1 to At_2: a measure and an attribute renamed in one clause.- Manual:
Change of Component name, Example 1, output verbatim: “The operator assigns new names to one or more Components (Identifier, Measure or Attribute Components)”, and “Only the Component name is changed and not the Component Values”.
- Expected:
The same data points, with
Me_2andAt_2in place ofMe_1andAt_1, with their roles and types.
DS_r := DS_1 [ rename Me_1 to Me_2, At_1 to At_2];
| Id_1 | Id_2 | Id_3 | Me_1 | At_1 |
|---|---|---|---|---|
| 1 | B | XX | 20 | F |
| 1 | B | YY | 1 | F |
| 2 | A | XX | 4 | E |
| 2 | A | YY | 9 | F |
| Id_1 | Id_2 | Id_3 | Me_2 | At_2 |
|---|---|---|---|---|
| 1 | B | XX | 20 | F |
| 1 | B | YY | 1 | F |
| 2 | A | XX | 4 | E |
| 2 | A | YY | 9 | F |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗