766 select.dictionary_element: add split parameter - #996
Conversation
|
Automatically outputting a split dictionary like this will be a breaking change. I would suggest leaving the default behavior as is and adding some sort of parameter that splits the selected elements. |
|
@thomasstvr it will not be a breaking change as it's new wrangle |
|
@mborodii-prog somehow I completely missed that. In general, I don't think it is a good idea to just create a new wrangle when we don't like the behavior of another. I skipped right over it because the names are so similar myself. |
|
@thomasstvr I updated current PR approach that you proposed: added new parameter split instead of creating new wrangle |
Adds a split parameter to select.dictionary_element. When split is true, the selected element(s) are written to new column(s) named after the key(s) instead of overwriting the input column, leaving the input intact. Default behavior (split: false) is unchanged.
e5a7acb to
a2a0be3
Compare
|
@thomasstvr - I don't think 'split' make senses in the context of select, especially since we have a split.dictionry. While we generally don't want a breaking change, in this case I believe it is worthwhile. I think I ran a models table query that found all of the instances where this wrangle is used without an output. I will take the action item to rerun that and assess how we can change the behavior to be intuitive -> you specify the key(s) you want and they pop out as columns without having to specify output. That way a) it always yields columns, and b) the user only needs to specify output(s) when they want to rename. I have never had a use for the current default behavior of 'selecting' a subset of keys but leaving it as a smaller dictionary. Have you? |
|
Queue triage (2026-07-27)
Please keep the branch current and put the decision in GitHub. This is one of the five active review slots. |
select.dictionary_element: add split parameter
Summary
Per @thomasstvr's suggestion, instead of adding a new
select.dict_elementwrangle, this adds a
splitparameter to the existingselect.dictionary_elementwrangle. Default behavior is unchanged.Motivation
select.dictionary_elementoverwrites the input column when nooutputis specified, which is convenient for quick in-place replacements but
makes it easy to lose the original data (see #766). Rather than
introducing a separate wrangle with different default behavior,
splitopts into the non-destructive behavior on the existing wrangle.
Behavior
splitfalse(default)outputif given, otherwise overwrites the input columntrueoutput. With a single key, creates one column named after that key; a list, wildcard, or regex element creates one column per matched key.Examples
Simple key — new column named after the element, input preserved:
List of keys — one column per key:
Wildcard — matched keys resolved at runtime, each becomes a column:
Regex — same as wildcard: