New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expression name with spaces causes incorrect aliasing when used together with Custom Column on BigQuery #25931
Comments
I can repro this on master. The BigQuery driver is not handling spaces in expression names. Some more data points from my testing:
So this is a specific error only around custom aggregations with spaces in their names, with another stage after them. |
The broken SQL is: SELECT
`source`.`category` AS `category`,
`source`.`expression name with spaces` AS `expression_name_with_spaces`,
`source`.`CC` AS `CC`
FROM (
SELECT
`source`.`category` AS `category`,
1 * 1 AS `CC`
FROM (
SELECT
`sample_database.products`.`category` AS `category`,
1 * 1 AS `expression_name_with_spaces`
FROM `sample_database.products`
GROUP BY `category`
ORDER BY `category` ASC
) AS `source`
) AS `source`
LIMIT 2000 The same query on H2 yields SQL like this: SELECT
"source"."CATEGORY" AS "CATEGORY",
"source"."expression name with spaces" AS "expression name with spaces",
"source"."CC" AS "CC" FROM (
SELECT
"source"."CATEGORY" AS "CATEGORY",
"source"."expression name with spaces" AS "expression name with spaces",
1 * 1 AS "CC"
FROM (
SELECT
"PUBLIC"."PRODUCTS"."CATEGORY" AS "CATEGORY",
1 * 1 AS "expression name with spaces"
FROM "PUBLIC"."PRODUCTS"
GROUP BY "PUBLIC"."PRODUCTS"."CATEGORY"
ORDER BY "PUBLIC"."PRODUCTS"."CATEGORY" ASC
) AS "source"
) AS "source"
LIMIT 2000 |
I'll pick this up again next week. For now I want to note for posterity that there's actually two things going wrong in the bad SQL:
I suspect (1) is a symptom of (2). That is, if the field were getting returned from that middle query properly, the correct name for it would be used in the outer query. Since that field isn't found in the |
Describe the bug
Expression name with spaces causes incorrect aliasing when used together with Custom Column on BigQuery.
Historically similar to #22310.
Workaround: Only use expression names without spaces.
To Reproduce
1 * 1
as "expression name with spaces" grouped by Category1 * 1
as "CC"Full stacktrace
Information about your Metabase Installation:
Tested 0.44.4
The text was updated successfully, but these errors were encountered: