bigquery-emulator
bigquery-emulator copied to clipboard
encodeSchemaField() not quoting record field names
What happened?
Attempt to create a table with a RECORD field one of whose embedded field names is "current" using the Google BigQuery Python SDK.
2025-07-01T20:50:14.276Z ERROR server/handler.go:2667 internalError {"error": "internalError: failed to create table CREATE TABLE `unittest.efcdecdadc.resource_feeder` (`id` STRING,`type` STRING,`title` STRING,`config` STRUCT<voltage DOUBLE>,`ratings` STRUCT<power STRUCT<apparent DOUBLE>,voltage DOUBLE,current DOUBLE>,`upline` STRUCT<substation STRING,parent STRING>,`downline` STRUCT<bus STRING>,`raw` STRING): failed to parse statements: failed to parse statement: INVALID_ARGUMENT: Syntax error: Unexpected keyword CURRENT [type.googleapis.com/zetasql.ErrorLocation='\\x08\\x01\\x10\\xc2\\x01']"}
What did you expect to happen?
The table should haven been created.
How can we reproduce it (as minimally and precisely as possible)?
Create a table with a RECORD field containing a field named "current".
Anything else we need to know?
The issue is that encodeSchemaField() is not escaping record field names, whereas other codepaths in CreateTable() do this.
A fix for using reserved keywords as struct keys has been implemented and released in the Recidiviz fork of the emulator https://github.com/Recidiviz/bigquery-emulator/releases/tag/v0.6.6-recidiviz.0