Skip to content

Commit ece7f1f

Browse files
committed
removed unnecessary clause function changes, edited tests
1 parent e82f5dd commit ece7f1f

File tree

3 files changed

+4
-33
lines changed

3 files changed

+4
-33
lines changed

sqlalchemy_bigquery/base.py

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -342,37 +342,8 @@ def visit_label(self, *args, within_group_by=False, **kwargs):
342342
kwargs["render_label_as_label"] = args[0]
343343
return super(BigQueryCompiler, self).visit_label(*args, **kwargs)
344344

345-
def group_by_clause(self, select, **kw):
346-
grouping_sets_exprs = []
347-
rollup_exprs = []
348-
cube_exprs = []
349-
350-
# Traverse select statement to extract grouping sets, rollup, and cube expressions
351-
for expr in select._group_by_clause:
352-
if isinstance(expr, grouping_sets):
353-
grouping_sets_exprs.append(
354-
self.process(expr.clauses)
355-
) # Assuming SQLAlchemy syntax
356-
elif isinstance(expr, rollup): # Assuming SQLAlchemy syntax
357-
rollup_exprs.append(self.process(expr.clauses))
358-
elif isinstance(expr, cube): # Assuming SQLAlchemy syntax
359-
cube_exprs.append(self.process(expr.clauses))
360-
else:
361-
# Handle regular group by expressions
362-
pass
363-
364-
clause = super(BigQueryCompiler, self).group_by_clause(select, **kw)
365-
366-
if grouping_sets_exprs:
367-
clause = (
368-
f"GROUP BY {clause} GROUPING SETS ({', '.join(grouping_sets_exprs)})"
369-
)
370-
if rollup_exprs:
371-
clause = f"GROUP BY {clause} ROLLUP ({', '.join(rollup_exprs)})"
372-
if cube_exprs:
373-
clause = f"GROUP BY {clause} CUBE ({', '.join(cube_exprs)})"
374-
375-
return clause
345+
def group_by_clause(self, select, **kwargs):
346+
return super(BigQueryCompiler, self).group_by_clause(select, **kwargs)
376347

377348
############################################################################
378349
# Handle parameters in in

testing/constraints-3.8.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# List *all* library dependencies and extras in this file.
44
# Pin the version to the lower bound.
55
#
6-
# e.g., if setup.py has "foo >= 1.14.1, < 2.0.0dev",
6+
# e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev",
77
sqlalchemy==1.4.16
88
google-auth==1.25.0
99
google-cloud-bigquery==3.3.6

tests/unit/test_compiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ def test_grouping_sets(faux_conn, metadata):
297297

298298
expected_sql = (
299299
"SELECT `table1`.`foo`, `table1`.`bar` \n"
300-
"FROM `table1` GROUP BY GROUPING SETS ((`table1`.`foo`), (`table1`.`bar`))"
300+
"FROM `table1` GROUP BY GROUPING SETS(`table1`.`foo`, `table1`.`bar`)"
301301
)
302302
found_sql = q.compile(faux_conn).string
303303
assert found_sql == expected_sql

0 commit comments

Comments
 (0)