Let's say I have 2 tables TABLE_A and TABLE_B. When there is no row in TABLE_B I want to insert a dummy row in TABLE_A and if there is any row in TABLE_B I want to insert whatever is present into TABLE_A. How can we do this ?
CREATE TABLE TABLE_A(
id STRING NOT NULL
, uid STRING NOT NULL
, date STRING NOT NULL
, timestamp TIMESTAMP NOT NULL
, payload OBJECT NOT NULL
, arr ARRAY NOT NULL
)
;
CREATE TABLE TABLE_B(
id STRING NOT NULL
, uid STRING NOT NULL
, date STRING NOT NULL
, timestamp TIMESTAMP NOT NULL
, payload OBJECT NOT NULL
, arr ARRAY NOT NULL
)
;
When COUNT(*) = 0 in TABLE_B Then Insert 'dummy_id','dummy_uid', current_date(), current_timestamp(), TO_OBJECT(PARSE_JSON('{}')), TO_ARRAY('DUMMY_ROWS') into TABLE_A.