1

I am trying to import a JSON file into a Google BigQuery table using the BigQuery Web UI.

When I define the JSON schema it fails to import because some of the json field names contain dashes - the UI reports and error saying the field is invalid.

For example:

{
    "first-name": "Bob",
    "last-name": "Smith"
}

I have huge amounts of data already in this format, so renaming the field isn't really an option. Any ideas?

seedhead
  • 3,655
  • 4
  • 32
  • 38

1 Answers1

2

BigQuery currently only supports field names in the following format: uppercase and/or lowercase letters (A-Z, a-z), digits (0-9) and underscores, (but not spaces or other characters).

Michael Manoochehri
  • 7,931
  • 6
  • 33
  • 47
  • It would be awesome if support could be added for this. I'll have to shelve using it for now! Thanks – seedhead Nov 08 '12 at 16:52
  • I agree that it's not trivial to change the keys of large JSON objects. However, even with large files, using sed to replace string values can be fairly efficient. You could also read the JSON in via Python and write out new keys recursively, using a strategy like this: http://stackoverflow.com/a/11700817/336505 – Michael Manoochehri Nov 08 '12 at 21:45
  • 2
    Just wanted to add a technical reason for this limitation -- when a query is parsed, we can't tell the difference between a field named "first-name" and an expression subtracting "name" from "first". Because of this, we're unlikely to change the name restrictions. – Jordan Tigani Nov 09 '12 at 11:25