Skip to content

Commit

Permalink
aggresive cache pivot
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-yzou committed Oct 31, 2024
1 parent aba566d commit 3e61da6
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -831,16 +831,16 @@ def pivot(
See detailed docstring in Snowpark DataFrame's pivot.
"""
snowpark_dataframe = self.to_projected_snowpark_dataframe()
pivot_snowpark_dataframe = snowpark_dataframe.pivot(
pivot_col=pivot_col,
values=values,
default_on_null=default_on_null,
).agg(*agg_exprs)
cached_snowpark_dataframe = pivot_snowpark_dataframe.cache_result()
return OrderedDataFrame(
# the pivot result columns for dynamic pivot are data dependent, a schema call is required
# to know all the quoted identifiers for the pivot result.
DataFrameReference(
snowpark_dataframe.pivot(
pivot_col=pivot_col,
values=values,
default_on_null=default_on_null,
).agg(*agg_exprs)
)
DataFrameReference(cached_snowpark_dataframe)
)

def unpivot(
Expand Down

0 comments on commit 3e61da6

Please sign in to comment.