I'm using the following workflow to append data to an existing BigQuery table from an external source:
- query the table for the most updated record: (select max(lastModifiedData) from test.table). Save this data as 'lastMigrationTime';
- query the external source for ids for records that changed since after 'lastMigrationTime'
- query big Query table for all records except the updated ones: save result to test.tempTable.
- move tempTable to table (using delete table,copy tempTable to table,delete tempTable).
- Query external source for updated records and load them to test.table
The problem I'm facing is that the original schema of the table contains nested elements. Any query I run will flatten the schema, forcing me to flatten the original schema as well. Another side effect I saw is that column names are turned to lower case.
Is there any way to keep the original schema (mainly the nesting, but also maintaining the case would be nice)?