hive-json-schema icon indicating copy to clipboard operation
hive-json-schema copied to clipboard

keys with whitespace or punctuation

Open mtoupsUNO opened this issue 9 years ago • 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.

mtoupsUNO avatar Apr 25 '15 02:04 mtoupsUNO