quux00/hive-json-schema

keys with whitespace or punctuation

mtoupsUNO opened this issue · 0 comments

Hi, thanks for making this, it is saving me some trouble.

I did notice that when reading keys with whitespace, the output schema syntax is invalid.

Here's an example:

{"name": "sometext",
"stuff": {"white space":false},
"white space": "blah blah"
}

The resulting schema output will be invalid syntax due to the spaces:

CREATE TABLE x (
  name string,
  stuff struct<white space:boolean>,
  white space string)
ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe';

Hive does support column names with whitespace (and, in fact, any Unicode character).

The simple solution is to enclose the column names in backticks.