我正在amazoneemr中运行一个小集群,以便使用apachehive2.3.5。据我所知,apachehive可以从远程数据库导入数据,并让集群运行查询。我遵循的是apachehiveweb文档中提供的一个示例(https://cwiki.apache.org/confluence/display/hive/jdbcstoragehandler)并创建了以下代码:
CREATE EXTERNAL TABLE hive_table
(
col1 int,
col2 string,
col3 date
)
STORED BY 'org.apache.hive.storage.jdbc.JdbcStorageHandler'
TBLPROPERTIES (
'hive.sql.database.type'='POSTGRES',
'hive.sql.jdbc.driver'='org.postgresql.Driver',
'hive.sql.jdbc.url'='jdbc:postgresql://<url>/<dbname>',
'hive.sql.dbcp.username'='<username>',
'hive.sql.dbcp.password'='<password>',
'hive.sql.table'='<dbtable>',
'hive.sql.dbcp.maxActive'='1'
);
但我得到以下错误:
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. java.lang.RuntimeException: MetaException(message:org.apache.hadoop.hive.serde2.SerDeException java.lang.IllegalArgumentException: Property hive.sql.query is required.)
根据文档,我需要指定“hive.sql.table”或“hive.sql.query”来说明如何从jdbc数据库获取数据。但是,如果用hive.sql.query替换hive.sql.table,则会出现以下错误:
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. java.lang.RuntimeException: MetaException(message:org.apache.hadoop.hive.serde2.SerDeException java.lang.IllegalArgumentException: No enum constant org.apache.hive.storage.jdbc.conf.DatabaseType.POSTGRES)
我试着在网上寻找一个解决方案,但似乎没有人遇到与我相同的问题。我需要修改一个配置文件还是我的代码中缺少了一些关键的东西?
1条答案
按热度按时间erhoui1w1#
我认为您使用的jar版本不支持postgres。
从以下链接下载最新的jar:http://repo1.maven.org/maven2/org/apache/hive/hive-jdbc-handler/3.1.2/hive-jdbc-handler-3.1.2.jar
将下载的jar放到hdfs位置。
正常运行Hive。
run命令:add jar${hdfs\u path\u to\u downloaded\u jar}
运行create table命令