Hive CREATE EXTERNAL TABLE with parameterized LOCATION

别来无恙 提交于 2019-12-23 02:59:07

问题


This works as expected:

 DROP TABLE mytable; 
 CREATE EXTERNAL TABLE mytable (
     Dim1 STRING,
     Dim2 STRING,
     Dim3 STRING ) 
 LOCATION 'hdfs:///user/myuser/data';

but this doesn't:

 set rootpath = 'hdfs:///user/myuser/data'; 
 DROP TABLE mytable; 
 CREATE EXTERNAL TABLE mytable (
     Dim1 STRING,
     Dim2 STRING,
     Dim3 STRING ) 
 LOCATION '${hiveconf:rootpath}';

It fails with the following error (Hive 0.9.0):

FAILED: Parse Error: line 9:11 mismatched input 'hdfs' expecting EOF near ''''

Am I doing something wrong, or is this a known issue/limitation? Are there any suggestions for workarounds?


回答1:


I think it should read LOCATION ${hiveconf:rootpath}.




回答2:


You can also use an environment variable which we often use in the create table DDL's. It can be referred as ${env:variable_name}



来源:https://stackoverflow.com/questions/15382342/hive-create-external-table-with-parameterized-location

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!