MCPcopy Create free account
hub / github.com/apache/datafusion / test_grouping_sets

Function test_grouping_sets

datafusion/core/tests/dataframe/mod.rs:3833–3872  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3831
3832#[tokio::test]
3833async fn test_grouping_sets() -> Result<()> {
3834 let grouping_set_expr = Expr::GroupingSet(GroupingSet::GroupingSets(vec![
3835 vec![col("a")],
3836 vec![col("b")],
3837 vec![col("a"), col("b")],
3838 ]));
3839
3840 let df = create_test_table("test")
3841 .await?
3842 .aggregate(vec![grouping_set_expr], vec![count(col("a"))])?
3843 .sort(vec![
3844 Sort::new(col("a"), false, true),
3845 Sort::new(col("b"), false, true),
3846 ])?;
3847
3848 let results = df.collect().await?;
3849
3850 assert_snapshot!(
3851 batches_to_string(&results),
3852 @r"
3853 +-----------+-----+---------------+
3854 | a | b | count(test.a) |
3855 +-----------+-----+---------------+
3856 | | 100 | 1 |
3857 | | 10 | 2 |
3858 | | 1 | 1 |
3859 | abcDEF | | 1 |
3860 | abcDEF | 1 | 1 |
3861 | abc123 | | 1 |
3862 | abc123 | 10 | 1 |
3863 | CBAdef | | 1 |
3864 | CBAdef | 10 | 1 |
3865 | 123AbcDef | | 1 |
3866 | 123AbcDef | 100 | 1 |
3867 +-----------+-----+---------------+
3868 "
3869 );
3870
3871 Ok(())
3872}
3873
3874#[tokio::test]
3875async fn test_grouping_sets_count() -> Result<()> {

Callers

nothing calls this directly

Calls 5

GroupingSetEnum · 0.85
collectMethod · 0.80
create_test_tableFunction · 0.70
sortMethod · 0.45
aggregateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…