0

I have 2 bigquery tables with nested columns, I need to update all the columns in table1 whenever table1.value1=table2.value, also those tables having a huge amount of data.

I could update a single nested column with static column like below,

    #standardSQL
    UPDATE `ck.table1` 
    SET promotion_id = ARRAY(
      SELECT AS STRUCT * REPLACE (100 AS PromotionId ) FROM UNNEST(promotion_id)
    )

But when I try to reuse the same to update multiple columns based on table2 data I am getting exceptions.

I am trying to update table1 with table2 data whenever the table1.value1=table2.value with all the nested columns.

As of now, both tables are having a similar schema.

1
  • please provide to us the exception you are receiving Commented Jun 11, 2019 at 14:30

1 Answer 1

1

I need to update all the columns in table1 whenever table1.value1=table2.value
... both tables are having a similar schema

I assume by similar you meant same

Below is for BigQuery Standard SQL
You can use below query to get combining result and save it back to table1 either using destination table or CREATE OR REPLACE TABLE syntax

#standardSQL
SELECT AS VALUE IF(value IS NULL, t1, t2)
FROM `project.dataset.table1` t1
LEFT JOIN `project.dataset.table2` t2
ON value1 = value

I have not tried this approach with UPDATE syntax - but you can try and let us know :o)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.