简体   繁体   中英

Big Query: create table from first key in JSON only

I am trying to create a table from JSON files in BigQuery and want just one column which will represent the first key 'id' only.

Creating a schema with only one column causes errors because all of the JSON keys in the input files are considered.

Is there a way to create a table that corresponds to only specific JSON keys?

Unfortunately, you can't create a table from a JSON file in BigQuery with just one column from the JSON file. You can create a feature request in this link .

You have these options:

Option 1

  • Don't import as JSON , but as CSV instead (define null character as separator)
  • Each line has only one column - the full JSON string
  • Parse inside BigQuery with maximum flexibility (JSON parsing functions and even JS)

Option 2

Do a 2-step import:

  • Import as a new table with all the columns.
  • Append " SELECT column1 FROM [newtable] " into the existing table.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM