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
{{ message }}
This repository has been archived by the owner on Sep 3, 2022. It is now read-only.
I encountered a case that needs compose the main query from multiple subqueries which also have dependency queries. However, The final query didn't work as expected. I will show the case in an example.
%%bq query -n subQuery2 --subqueries subQuery1
,
subQuery2_q1 as (
select state, name
from subQuery1
limit 10
)
select *
from subQuery2_q1
subQuery2 works with subQuery1 as dependency.
Since subQuery2 has its own common table expression, then comma is needed at the front to make it working.
--------------------- main Query ---------------------
WITH subQuery1 AS (
select state, name, year
from `bigquery-public-data.usa_names.usa_1910_2013`
limit 10
),
subQuery2 AS (
,
subQuery2_q1 as (
select state, name
from subQuery1
limit 10
)
select *
from subQuery2_q1
)
select *
from subQuery2
limit 10
In this case, the main query won't work, because subQuery2 here is not valid.
I am looking at the _recurse_subqueries functionhere, instead of putting subQuery1 and subQuery2 into a flat list, should subQuery1 be inside of subQuery2?
And Query should be,
with subQuery2 AS (
WITH subQuery1 AS (
select state, name, year
from `bigquery-public-data.usa_names.usa_1910_2013`
limit 10
),
subQuery2_q1 as (
select state, name
from subQuery1
limit 10
)
select *
from subQuery2_q1
)
select *
from subQuery2
limit 10
or
WITH subQuery1 AS (
select state, name, year
from `bigquery-public-data.usa_names.usa_1910_2013`
limit 10
),
subQuery2 AS (
with subQuery2_q1 as (
select state, name
from subQuery1
limit 10
)
select *
from subQuery2_q1
)
select *
from subQuery2
limit 10
thanks a lot.
The text was updated successfully, but these errors were encountered:
Hello,
I encountered a case that needs compose the main query from multiple subqueries which also have dependency queries. However, The final query didn't work as expected. I will show the case in an example.
--------------------- subQuery1 ---------------------
subQuery1 works.
--------------------- subQuery2 ---------------------
subQuery2 works with subQuery1 as dependency.
Since subQuery2 has its own common table expression, then comma is needed at the front to make it working.
--------------------- main Query ---------------------
main query will look like,
In this case, the main query won't work, because subQuery2 here is not valid.
I am looking at the _recurse_subqueries functionhere, instead of putting subQuery1 and subQuery2 into a flat list, should subQuery1 be inside of subQuery2?
And Query should be,
or
thanks a lot.
The text was updated successfully, but these errors were encountered: