Skip to content

Commit 033d329

Browse files
committed
reformat logic
1 parent 5154814 commit 033d329

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

sqlalchemy_bigquery/base.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,11 +338,13 @@ def visit_label(self, *args, within_group_by=False, **kwargs):
338338
# Flag set in the group_by_clause method. Works around missing
339339
# equivalent to supports_simple_order_by_label for group by.
340340
if within_group_by:
341-
if all(
342-
keyword not in str(args[0])
343-
for keyword in ("GROUPING SETS", "ROLLUP", "CUBE")
344-
):
345-
kwargs["render_label_as_label"] = args[0]
341+
column_label = args[0]
342+
sql_keywords = {"GROUPING SETS", "ROLLUP", "CUBE"}
343+
for keyword in sql_keywords:
344+
if keyword in str(column_label):
345+
break
346+
else: # for/else always happens unless break gets called
347+
kwargs["render_label_as_label"] = column_label
346348

347349
return super(BigQueryCompiler, self).visit_label(*args, **kwargs)
348350

tests/unit/test_compiler.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
sqlalchemy_before_2_0,
2727
)
2828
from sqlalchemy.sql.functions import rollup, cube, grouping_sets
29-
from sqlalchemy import func
3029

3130

3231
def test_constraints_are_ignored(faux_conn, metadata):

0 commit comments

Comments
 (0)