snowflake.snowpark.GroupingSets

class snowflake.snowpark.GroupingSets(*sets: Union[Column, List[Column]])[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.16.0/src/snowflake/snowpark/relational_grouped_dataframe.py#L93-L117)

Bases: object

Creates a GroupingSets object from a list of column/expression sets that you pass to DataFrame.group_by_grouping_sets(). See DataFrame.group_by_grouping_sets() for examples of how to use this class with a DataFrame. See GROUP BY GROUPING SETS for its counterpart in SQL (several examples are shown below).

Python interface

SQL interface

GroupingSets([col("a")], [col("b")])

GROUPING SETS ((a), (b))

GroupingSets([col("a") , col("b")], [col("c"), col("d")])

GROUPING SETS ((a, b), (c, d))

GroupingSets([col("a"), col("b")])

GROUPING SETS ((a, b))

GroupingSets(col("a"), col("b"))

GROUPING SETS ((a, b))

语言: 中文