2

I am facing issue with space in key name in the struct type while creating a table.

Following is the create table command I am using

 CREATE TABLE event_test (
  android_id string,
  app string,
  app_ver string,
  at string,
  birth_date int,
  browser string,
  carrier string,
  city_name string,
  closed_at string,
  `country name` string,
  custom struct<`test name`:string>,
  os_ver string,
 )
  ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe'
STORED AS TEXTFILE;

following is the error msg:

FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. java.lang.IllegalArgumentException: Error: : expected at the position 85 of 'string:string:string:string:int:string:string:string:string:string:string:struct<test name:string>' but ' ' is found.

The "country name" is working fine with “``" but if I create a struct and inside struct the “test name” if I use backtick it is throwing error. Is there a way to define the key (name with space in between ) in struct type?

Thanks in Advance

dtolnay
  • 9,621
  • 5
  • 41
  • 62
Dutta
  • 663
  • 2
  • 11
  • 30
  • I had some issue with SERDEPROPERTIES. First, check that you have correct jars in /usr/hdp/current/hive-client/. The second variant, you can create table without SERDE and than add SERGEPROPERTIES like this: ALTER TABLE test.test_table SET SERDEPROPERTIES ('escapeChar'='\\\\','quoteChar'='\"','separatorChar'=','); Also, you can add into the create table statement the following:
    WITH SERDEPROPERTIES ( 'escapeChar'='\\\\', 'quoteChar'='\"', 'separatorChar'=',')
    – Glib Martynenko Jan 26 '17 at 18:45

0 Answers0