I have two queries running in BQ. I expect them having the same results, but it turns out not. I don't understand why it happens.
Query 1:
select a.* from
(
select *, _PARTITIONTIME as pt from
`table_A`
where
p > 5 and q != 0
) as a
left join
(select distinct x, pt from `table_b`) as b
on join_clauses
Query 2:
select a.* from
table_A as a
left join
(select distinct x, pt from table_b) as b
on join_clauses
and a.p > 5 and a.q != 0
If I remove the conditions of a.p > 5 and a.q != 0
from both queries, the results are identical.
As far as I know, the conditions under the on
statements is evaluated before the join, which should make the two queries equal. Then I don't know why do I see different results here. Is there any special setup in Google's BQ?