last
是非保留關鍵字。
這裏沒有問題。
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-Keywords,Non-reservedKeywordsandReservedKeywords
hive> dfs -cat /user/hive/warehouse/my_table/*;
{"a":"hello","b":"world","last":"!"}
create external table my_table
(
a string
,b string
,last string
)
row format serde 'org.apache.hive.hcatalog.data.JsonSerDe'
location '/user/hive/warehouse/my_table'
;
select * from my_table
;
+------------+------------+---------------+
| my_table.a | my_table.b | my_table.last |
+------------+------------+---------------+
| hello | world | ! |
+------------+------------+---------------+
對於保留關鍵字s,'(Grave accent)的資格解決了這個問題。
hive> dfs -cat /user/hive/warehouse/my_table_2/*;
{"and":"X","or":"Mix","not":"Drix"}
create external table my_table_2
(
`and` string
,`or` string
,`not` string
)
row format serde 'org.apache.hive.hcatalog.data.JsonSerDe'
location '/user/hive/warehouse/my_table_2'
;
select * from my_table_2
;
+----------------+---------------+----------------+
| my_table_2.and | my_table_2.or | my_table_2.not |
+----------------+---------------+----------------+
| X | Mix | Drix |
+----------------+---------------+----------------+
我站在更正 - 謝謝你的全面解答。實際上,在使用AWS Athena時遇到了一個問題 - 'SELECT * FROM my_table'起作用,但是'SELECT last FROM my_table'不起作用。聽起來像這個問題可能是特定於雅典娜。 – tobycoleman