You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Python 3.10.15
sqlalchemy_bigquery 1.12.0 (issue introduced in 1.11.0).
When creating a new FunctionalElement to compile some custom function that does not support the default dialect, and grouping by that element, we get an error as we are using the default dialect instead of compiler dialect.
Steps to reproduce
Create a new FunctionElement
Create a function that compiles it. Make sure it does not support the default dialect.
Create a query that groups by a field using this function and adding a label to it
sqlalchemy.exc.CompileError: custom_lower is not supported for dialect 'default'
This is because when trying to understand if we have the grouping_ops in the element we use str() to stringify it instead of compiling it using the dialect.
The solution should be in visit_label:
We should not use str(column_label), but rather column_label.compile(dialect=self.dialect).string
Example fix
defvisit_label(self, *args, within_group_by=False, **kwargs):
# Use labels in GROUP BY clause.## Flag set in the group_by_clause method. Works around missing# equivalent to supports_simple_order_by_label for group by.ifwithin_group_by:
column_label=args[0]
sql_keywords= {"GROUPING SETS", "ROLLUP", "CUBE"}
label_str=column_label.compile(dialect=self.dialect).stringifnotany(keywordinlabel_strforkeywordinsql_keywords):
kwargs["render_label_as_label"] =column_labelreturnsuper(BigQueryCompiler, self).visit_label(*args, **kwargs)
The text was updated successfully, but these errors were encountered:
Python 3.10.15
sqlalchemy_bigquery 1.12.0 (issue introduced in 1.11.0).
When creating a new FunctionalElement to compile some custom function that does not support the
default
dialect, and grouping by that element, we get an error as we are using thedefault
dialect instead of compiler dialect.Steps to reproduce
default
dialect.Code example
Error received
This is because when trying to understand if we have the
grouping_ops
in the element we usestr()
to stringify it instead of compiling it using the dialect.The solution should be in
visit_label
:We should not use
str(column_label)
, but rathercolumn_label.compile(dialect=self.dialect).string
Example fix
The text was updated successfully, but these errors were encountered: