You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pivot wider is inherently eager as it needs the distinct values from the names_from column.
Right now, the macro and underlying function actively pulls them before building the equivalent sql.
It might be nice additionally to allow names_from to also accept tuples or pairs where one is the column name for names from (as it needs to know so it can be dropped), and the other part would be the distinct values (if the user for some reason already knows them)
I was running a pivot on 10 gigs of data and was like hmm I already know the distinct values might be nice to save some query time but open to ideas
Adds lazy pivot method where a Tuple of (col_name, [:column_values] can be provided as the names_from argument, for the sql generation. If its not given, @pivot_wider will query the relevant column to pull the distinct column values needed to make the new column names.
test = (:variable, [:income, :rent]);
@eval @chain rentin begin
@pivot_wider(names_from = $test,
values_from = estimate:moe)
@aside @show_query _
@collect
end
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ex below just need to add tidy selection.
names_from only supports one col right now