When using raw SQL queries, _extractFromClause() fails to extract the project, dataset and table name from the FROM clause when using variables or when using FROM in a subquery.
Expected Behavior
Variables are interpolated before extracting the FROM clause and there are no API errors when using raw SQL queries with variables and/or subqueries.
Actual Behavior
Given a variable $source_table set as my_project.my_dataset.my_table:
SELECT
CURRENT_TIMESTAMP() AS time,
SUM(cost) AS value
FROM
`$source_table`
WHERE
$__timeFilter(usage_start_time)
GROUP BY 1
ORDER BY 1 ASC
Also if using FROM in a subquery earlier in the SELECT clause for instance:
SELECT
CURRENT_TIMESTAMP() AS time,
SUM(IFNULL((SELECT SUM(c.amount) FROM UNNEST(credits) c), 0)) AS value
FROM
`$source_table`
WHERE
$__timeFilter(usage_start_time)
GROUP BY 1
ORDER BY 1 ASC
Also could we have an option for disabling "fixing" the raw queries? I prefer adding the partition filter explicitly myself and not having the query altered in any way (aside from variable/macro interpolation).
Bug Report
When using raw SQL queries,
_extractFromClause()
fails to extract the project, dataset and table name from the FROM clause when using variables or when using FROM in a subquery.Expected Behavior
Variables are interpolated before extracting the FROM clause and there are no API errors when using raw SQL queries with variables and/or subqueries.
Actual Behavior
Given a variable
$source_table
set asmy_project.my_dataset.my_table
:results in this error:
Also if using FROM in a subquery earlier in the SELECT clause for instance:
results in this error:
Steps to Reproduce the Problem
Variable interpolation case:
source_table
set as the full table namesource_table
in the FROM clause (see example above)Subquery case:
Specifications