简体   繁体   English

创建Hive表的Shell脚本

[英]Shell Script to Create a Hive Table

I am trying to create one Hive External Table Hbase. 我正在尝试创建一个Hive外部表Hbase。

Below is my simple code: 下面是我的简单代码:

hive -hiveconf DB_NAME=bdsma -hiveconf TABLE_NAME=RAW_BBPROCESSINGRESOURCE -f Create External table bdsma.RAW_BBPROCESSINGRESOURCE( hbase_key string,pmRohcCidSum FLOAT) ROW FORMAT SERDE "org.apache.hadoop.hive.hbase.HBaseSerDe" STORED BY "org.apache.hadoop.hive.hbase.HBaseStorageHandler" WITH SERDEPROPERTIES '('hbase.columns.mapping'=':key, \tCF:pmRohcCidSum')' TBLPROPERTIES ("COLUMN_STATS_ACCURATE"="false","hbase.mapred.output.outputtable"="RAW_OPS_ODEB", "hbase.table.name"="RAW_OPS_ODEB")

But its showing the error below: 但其显示以下错误:

-bash: syntax error near unexpected token `(' -bash:意外令牌'('附近的语法错误

hive -f takes a file, so make a file containing your script, then it would be hive -f script.sql hive -f需要一个文件,因此制作一个包含脚本的文件,那么它将是hive -f script.sql

If you want to write the statement on the CLI, you want hive -e "CREATE EXTERNAL TABLE bdsma.RAW_BBPROCESSINGRESOURCE( ... ) ..." . 如果要在CLI上编写该语句,则需要hive -e "CREATE EXTERNAL TABLE bdsma.RAW_BBPROCESSINGRESOURCE( ... ) ..." If using this way, then both -hiveconf can be removed because you aren't using it. 如果使用这种方式,则-hiveconf都可以删除,因为您没有使用它。

我记得hive -f /path/to/sql.file :)另外,hive和beeline都支持此参数。

Thank you. 谢谢。

Find below the final script. 在最终脚本下面找到。

hive -hiveconf DB_NAME=bdsmart -hiveconf TABLE_NAME=RAW_BBPROCESSINGRESOURCE -e "Create External table RAW_BBPROCESSINGRESOURCE( hbase_key string,pmRohcCidSum FLOAT) ROW FORMAT SERDE 'org.apache.hadoop.hive.hbase.HBaseSerDe' STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES ('hbase.columns.mapping'=':key, \\tCF:pmRohcCidSum') TBLPROPERTIES ('COLUMN_STATS_ACCURATE'='false','hbase.mapred.output.outputtable'='RAW_ERICSSON_ENODEB', 'hbase.table.name'='RAW_ERICSSON_ENODEB')" Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512M; hive -hiveconf DB_NAME = bdsmart -hiveconf TABLE_NAME = RAW_BBPROCESSINGRESOURCE -e“创建外部表RAW_BBPROCESSINGRESOURCE(hbase_key string,pmRohcCidSum FLOAT)ROW FORMAT SERDE'org.apache.hadoop.hive.hbase.HBaseSerDe'STOR。 hive.hbase.HBaseStorageHandler'与SERDEPROPERTIES('hbase.columns.mapping'=':key,\\ tCF:pmRohcCidSum')TBLPROPERTIES('COLUMN_STATS_ACCURATE'='false','hbase.mapred.output.outputtable'='RAW_ERICSSON_ENODEB ,'hbase.table.name'='RAW_ERICSSON_ENODEB')“ Java HotSpot(TM)64位服务器VM警告:忽略选项MaxPermSize = 512M; support was removed in 8.0 Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512M; 8.0中的支持已删除Java HotSpot™64位服务器VM警告:不建议使用增量CMS,并且在将来的版本中可能会删除Java HotSpot™64位服务器VM警告:忽略选项MaxPermSize = 512M;请参见参考。 support was removed in 8.0 在8.0中删除了支持

Logging initialized using configuration in jar:file:/opt/cloudera/parcels/CDH-5.12.1-1.cdh5.12.1.p0.3/jars/hive-common-1.1.0-cdh5.12.1.jar!/hive-log4j.properties OK Time taken: 3.332 seconds 使用jar中的配置初始化日志记录:file:/opt/cloudera/parcels/CDH-5.12.1-1.cdh5.12.1.p0.3/jars/hive-common-1.1.0-cdh5.12.1.jar!/ hive -log4j.properties OK需要的时间:3.332秒

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM