I am trying to move a BigQuery table to a new schema that has some additional new NULLABLE fields and in which a field f
has become REQUIRED (they were NULLABLE in the old schema.)
I tried to update the table with the new schema through the command
bq update <table> <new_schema>
and I get the error
BigQuery error in update operation: Provided Schema does not match Table
As a second attempt, I created a temporary empty table with the new field and then tried to append there the data coming from a query (SELECT * from the old table), but I get the error:
Invalid schema update. Field f has changed mode from REQUIRED to NULLABLE
Is there a way to do this migration easily? Of course I am fine with ignoring rows of the table where the field f
is actually NULL. It would be cool if BigQuery could infer that from the query. I tried to do
SELECT * FROM old_table WHERE f IS NOT NULL
and append the result to the table with the new schema, but that doesn't work.
IFNULL() allows to return the first value if the value is NULL; otherwise, the second value is returned. COALESCE() is a function that returns the first non-null value in a set of arguments. NVL() can be used to replace a NULL value with a value specified by the user.
NOT EQUAL TO (!=) and EXISTS... EQUAL TO Giving Different Results.
Try to use empty string where f is null.
CASE
WHEN f IS NULL THEN ""
ELSE f
END as f
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With