Describe the bug
GROUPING can panic during analysis of GROUPING SETS with 65 distinct grouping columns, even when GROUPING has only one argument.
The analyzer constructs the mask using 1 << group_by_idx. A column at bit 64 causes a shift overflow in a checked build. The physical grouping-set representation already has a 64-bit capacity limit.
To reproduce
Generate the SQL below and run its output in a debug DataFusion CLI:
n = 65
cols = ", ".join(f"c{i} INTEGER" for i in range(n))
keys = ", ".join(f"c{i}" for i in range(n))
row = ", ".join(str(i + 1) for i in range(n))
print(f"CREATE TABLE wide_keys ({cols});")
print(f"INSERT INTO wide_keys VALUES ({row});")
print(f"SELECT GROUPING(c0), COUNT(*) FROM wide_keys "
f"GROUP BY GROUPING SETS (({keys}), ());")
Expected behavior
Return NotImplemented before constructing an unrepresentable grouping-set mask. Ordinary GROUP BY with 65 columns should continue to allow GROUPING to return zero.
Additional context
Reproduced through core API regression tests on commit 1fa378d380fa7e494aae1085945f8b048e9376c3.
Describe the bug
GROUPING can panic during analysis of GROUPING SETS with 65 distinct grouping columns, even when GROUPING has only one argument.
The analyzer constructs the mask using
1 << group_by_idx. A column at bit 64 causes a shift overflow in a checked build. The physical grouping-set representation already has a 64-bit capacity limit.To reproduce
Generate the SQL below and run its output in a debug DataFusion CLI:
Expected behavior
Return NotImplemented before constructing an unrepresentable grouping-set mask. Ordinary GROUP BY with 65 columns should continue to allow GROUPING to return zero.
Additional context
Reproduced through core API regression tests on commit
1fa378d380fa7e494aae1085945f8b048e9376c3.