Skip to content
Advertisement

BigQuery nested table UPDATE based on condition of non-nested data AND nested data

I am trying to update records in a bigQuery database that looks like this:

enter image description here

Using the code below:

However, as show in the picture, it makes ALL of the addresses read “sleep” instead of just the “previous one.

I must admit, I’m pretty confused as to how best to deal with alterations within nested tables. Is there a general way to achieve just updating the “previous” piece of the nested array?

Advertisement

Answer

Is this what you want to do?

This does rearrange the columns in the struct — which can be fixed with more coding. I think this might be what you want to do.

EDIT:

To avoid shifting, you can explicitly list the columns:

This just reconstructs the struct but conditionally reassigning the value for address.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement