I have a perfect code that compares the data from one table with another (see below) which works totally fine and runs fine as well in BigQuery:
with source1 as (
select
b.id,
b.qty,
a.price
from <table> as a
,unnest <details> as b
where b.status != 'canceled'
),
source2 as (
select id_, qty_, price_ from <table2>
where city != 'delhi'
)
select *
from source1 s1
full outer join source2 s2
on id = id_
where format('%t', s1) != format('%t', s2)
However, the code above runs into an error in sqlfluff i.e a certain SQL formatting rules checker that I can't bypass or turn off, see the error from sqlfluff below:
ERROR FROM SQLFLUFF:
*'s1' found in select with more than one referenced table/view' and 's2' found in select with more than one referenced table/view
Does anybody know how I can fix it ?
Windows function may perform better.
Instead of joining, the tables are unioned. Then a window function will search for combinations. As you tagged this question [Big-Query] it is tested for BigQuery: