I need to query for the same aggregate stat over all tables matching some naming scheme:
SELECT
SUBSTR(CONCAT('20', _TABLE_SUFFIX), 0, 10) AS date,
CASE
WHEN ENDS_WITH(_TABLE_SUFFIX, 'mobile') THEN 'mobile'
ELSE 'desktop'
END AS client,
APPROX_QUANTILES(bytesJS,1000)[OFFSET(500)] AS p50
FROM
`httparchive.runs.20*`
WHERE
ENDS_WITH(_TABLE_SUFFIX, '_pages')
OR ENDS_WITH(_TABLE_SUFFIX, '_pages_mobile')
GROUP BY
1,
2
ORDER BY
1,
2
However, the query is failing with Error: Unrecognized name: bytesJS at [7:20]
There should be about 150 tables that match the query. Here's the schema for one of these tables: https://bigquery.cloud.google.com/table/httparchive:runs.2017_05_15_pages
bytesJS
is a valid column name, but it's failing as unrecognized. Same error when substituting different known columns. I'm not sure if this is a direct result of using the table wildcard or what.
I would rewrite this with legacy SQL and see if that works, but my query requires selecting the table metadata.
Is this an incompatibility with the wildcard?