Skip to content

Commit

Permalink
fix: separate groupby and grouping set
Browse files Browse the repository at this point in the history
  • Loading branch information
richtia committed Sep 6, 2024
1 parent 8b88b2b commit fd57123
Show file tree
Hide file tree
Showing 10 changed files with 706 additions and 13 deletions.
6 changes: 6 additions & 0 deletions substrait_consumer/functional/aggregate_relation_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
"sql_query": AGGREGATE_RELATIONS["aggregate_in_subquery"],
"ibis_expr": None
},
{
"test_name": "aggregate_with_group_by",
"file_names": ['lineitem_small.parquet'],
"sql_query": AGGREGATE_RELATIONS["aggregate_with_group_by"],
"ibis_expr": None
},
{
"test_name": "aggregate_with_grouping_set",
"file_names": ['lineitem_small.parquet'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,26 @@
""",
[DuckDBProducer, DataFusionProducer, IsthmusProducer],
),
"aggregate_with_group_by": (
"""
SELECT SUM(L_EXTENDEDPRICE), L_LINENUMBER
FROM '{}'
GROUP BY L_LINENUMBER
""",
[DuckDBProducer, DataFusionProducer, IsthmusProducer],
),
"aggregate_with_grouping_set": (
"""
SELECT SUM(l_extendedprice), l_linenumber
SELECT SUM(L_EXTENDEDPRICE), L_LINENUMBER, L_ORDERKEY
FROM '{}'
GROUP BY l_linenumber
GROUP BY GROUPING SETS
(
(L_LINENUMBER),
(L_ORDERKEY)
)
ORDER BY L_LINENUMBER
""",
[DuckDBProducer, DataFusionProducer, IsthmusProducer],
),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
{
"extensions": [
{
"extensionFunction": {
"extensionUriReference": 4294967295,
"name": "sum"
}
}
],
"relations": [
{
"root": {
"input": {
"project": {
"input": {
"aggregate": {
"input": {
"read": {
"baseSchema": {
"names": [
"l_orderkey",
"l_partkey",
"l_suppkey",
"l_linenumber",
"l_quantity",
"l_extendedprice",
"l_discount",
"l_tax",
"l_returnflag",
"l_linestatus",
"l_shipdate",
"l_commitdate",
"l_receiptdate",
"l_shipinstruct",
"l_shipmode",
"l_comment"
]
},
"projection": {
"select": {
"structItems": [
{
"field": 3
},
{
"field": 5
}
]
}
},
"namedTable": {
"names": [
"lineitem_small"
]
}
}
},
"groupings": [
{
"groupingExpressions": [
{
"selection": {
"directReference": {
"structField": {}
}
}
}
]
}
],
"measures": [
{
"measure": {
"invocation": "AGGREGATION_INVOCATION_ALL",
"arguments": [
{
"value": {
"selection": {
"directReference": {
"structField": {
"field": 1
}
}
}
}
}
]
}
}
]
}
},
"expressions": [
{
"selection": {
"directReference": {
"structField": {
"field": 1
}
}
}
},
{
"selection": {
"directReference": {
"structField": {}
}
}
}
]
}
},
"names": [
"sum(lineitem_small.l_extendedprice)",
"l_linenumber"
]
}
}
],
"version": {
"minorNumber": 51,
"producer": "datafusion"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"projection": {
"select": {
"structItems": [
{},
{
"field": 3
},
Expand All @@ -56,6 +57,19 @@
}
},
"groupings": [
{
"groupingExpressions": [
{
"selection": {
"directReference": {
"structField": {
"field": 1
}
}
}
}
]
},
{
"groupingExpressions": [
{
Expand All @@ -78,7 +92,7 @@
"selection": {
"directReference": {
"structField": {
"field": 1
"field": 2
}
}
}
Expand All @@ -95,7 +109,7 @@
"selection": {
"directReference": {
"structField": {
"field": 1
"field": 2
}
}
}
Expand All @@ -106,13 +120,23 @@
"structField": {}
}
}
},
{
"selection": {
"directReference": {
"structField": {
"field": 1
}
}
}
}
]
}
},
"names": [
"sum(lineitem_small.l_extendedprice)",
"l_linenumber"
"l_linenumber",
"l_orderkey"
]
}
}
Expand Down
Loading

0 comments on commit fd57123

Please sign in to comment.