我正在尝试使用配置单元执行 Twitter 分析,但出现了如上所述的错误。我已经添加了如下所示的 jar 文件,并且没有出现错误,但是在创建外部表时出现如下错误:
FAILED: ParseException line 9:2 cannot recognize input near 'user' 'STRUCT' '<' in column name or primary key or foreign key
add jar /home/shashank/Desktop/Hadoopprac/Twitteranalysis/hive-json-serde.jar;
CREATE EXTERNAL TABLE IF NOT EXISTS tweets (
text STRING,
entities STRUCT<
hashtags:ARRAY<STRUCT<text:STRING>>>,
user STRUCT<
screen_name:STRING,
friends_count:INT,
followers_count:INT,
statuses_count:INT,
verified:BOOLEAN,
utc_offset:INT,
time_zone:STRING>
)
ROW FORMAT SERDE 'com.cloudera.hive.serde.JSONSerDe'
LOCATION '/home/shashank/Desktop/Hadoopprac/tweetsfile.json';
最佳答案
所以终于得到了答案,实际上问题在于保留关键字,用户是配置单元解析中的保留关键字,因此用户应该放入``并运行查询,感谢hlagos和cricket_007的努力。
CREATE EXTERNAL TABLE IF NOT EXISTS tweets (
text STRING,
entities STRUCT<
hashtags:ARRAY<STRUCT<text:STRING>>>,
`user` STRUCT<
screen_name:STRING,
friends_count:INT,
followers_count:INT,
statuses_count:INT,
verified:BOOLEAN,
utc_offset:INT,
time_zone:STRING>
)
ROW FORMAT SERDE 'com.cloudera.hive.serde.JSONSerDe'
LOCATION '/home/shashank/Desktop/Hadoopprac/tweetsfile.json';
关于hadoop - 无法识别配置单元中的列名称或主键或外键中 'user' 'STRUCT' '<' 附近的输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49997152/