RenameFields / Struct Layer
Rename fields within struct columns. Similar to pandas rename() or R's rename() for nested structures. Maintains data structure while updating field names.
Example transformation:
Original struct:
data |
---|
{fname: 'John', lname: 'Doe'} |
{fname: 'Jane', lname: 'Smith'} |
After renaming (fname→first_name, lname→last_name):
data |
---|
{first_name: 'John', last_name: 'Doe'} |
{first_name: 'Jane', last_name: 'Smith'} |
Common applications:
- Standardizing field names
- Making names more descriptive
- Fixing inconsistent naming
- Preparing data for specific systems
- Harmonizing data structures
- Meeting naming conventions
Note: Unmapped field names remain unchanged. The operation preserves the original structure and data types while only updating specified field names.
Select
columnThe struct column to modify. Examples of input structures:
- User data: {uid: 123, uname: 'John'}
- Metrics: {val: 10, desc: 'count'}
- Nested: {usr: {id: 1, nm: 'Alice'}}
- Mixed: {dt: '2024-01-31', vals: [1,2]}
Mappings
[, ...]List of field name mappings. Each mapping specifies an old field name and its new name. Example mappings:
- {old_field: 'fname', new_field: 'first_name'}
- {old_field: 'lname', new_field: 'last_name'}
- {old_field: 'tel', new_field: 'phone_number'}
Must contain at least one mapping. Duplicate old_field names are not allowed.
OldField
stringOriginal field name in the struct. Must exactly match existing field name. Examples:
- 'fname' to rename first name field
- 'user_id' to rename identifier
- 'desc' to rename description
NewField
stringNew name for the field. Must be a valid identifier. Examples:
- 'first_name' for clarity
- 'identifier' for standardization
- 'description' for completeness