Basically you can use UDF to emit one or more rows. In Standard UDF you must emit Array combined with Struct if you want to emit rows.
There is an example in the Migration guide that add data to non existing columns.
scroll down to: Functions operate on values rather than rows
. In legacy SQL, JavaScript functions operate on rows from a table. In standard SQL, as in the example above, JavaScript functions operate on values. To pass a row value to a JavaScript function using standard SQL, define a function that takes a struct of the same row type as the table.
If you end up emitting a struct that holds repeated data, you can write the query result into a new table. That's your insert.
What this means is that you need to create your query results in such way, that the results of the query are written to a destination table, and that becomes your insert. As BQ doesn't offer a strict INSERT
statement from UDF.