forked from douglascoimbra/test-sample-pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproductvoid.csql
45 lines (39 loc) · 1.42 KB
/
productvoid.csql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
-- pk: _id
with qa_stg_nlp_product
as (
SELECT
stg.id as mdmbarcode,
stg.productname as mdmname,
stg.category as mdmdescription,
stg.productprice as mdmunitvalue,
ROW_NUMBER() OVER(PARTITION BY stg.id ORDER BY mdmCounterForEntity DESC) AS ranking
--CONTAINS_SUBSTR(stg.productname, 'banan') AS mdmDeleted
--metadata{nlp,product}--
from stg_nlp_product as stg
--timestamp-- WHERE mdmCounterForEntity__DATETIME__ > SAFE.DATETIME(TIMESTAMP_MICROS(SAFE_CAST({{start_from}} AS INT64)))
),
qa_stg_sql_cypresstest
as (
SELECT
stg.id as mdmbarcode,
stg.productname as mdmname,
stg.category as mdmdescription,
stg.productprice as mdmunitvalue,
ROW_NUMBER() OVER(PARTITION BY stg.id ORDER BY mdmCounterForEntity DESC) AS ranking
--CONTAINS_SUBSTR(stg.productname, 'banan') AS mdmDeleted
--metadata{nlp,product}--
from stg_sql_cypresstest as stg
--timestamp-- WHERE mdmCounterForEntity__DATETIME__ > SAFE.DATETIME(TIMESTAMP_MICROS(SAFE_CAST({{start_from}} AS INT64)))
),
mdmproduct as (
select * from qa_stg_nlp_product where ranking = 1
union all
select * from qa_stg_sql_cypresstest where ranking = 1
)
select * except(ranking),
(
(mdmname is null) or (mdmname = '')
or (mdmbarcode is null) or (mdmbarcode = '')
or (mdmdescription is null) or (mdmdescription = '')
) mdmDeleted
from mdmproduct