hive 映射 mysql 表:在连接条件中选择不同的 mysql 数据源时无法成功

问题描述 投票:0回答:1

我使用jdbc存储处理程序将hive中的多个mysql数据源映射为https://cwiki.apache.org/confluence/display/Hive/JDBC+Storage+Handler; 第一个表是:

CREATE EXTERNAL TABLE IF NOT EXISTS dim_order_right_detail(
  id bigint,
  right_detail_id string,
  open_id string,
  order_id string
) STORED BY 'org.apache.hive.storage.jdbc.JdbcStorageHandler' 
LOCATION 'hdfs://hdp5/dpyy/prod/hive/dpyy_prod.db/dim_order_right_detail' 
TBLPROPERTIES (
  'hive.sql.database.type' = 'MYSQL',
  'hive.sql.jdbc.driver' = 'com.mysql.cj.jdbc.Driver',
  'hive.sql.jdbc.url' = 'jdbc:mysql://XXX.XX.XXX.XXX:3306/dpyy_vas?&allowPublicKeyRetrieval=true&useSSL=false',
  'hive.sql.dbcp.username' = 'XXXXX',
  'hive.sql.dbcp.password' = 'XXXXX',
  'hive.sql.query' = 'SELECT id,right_detail_id,open_id,order_id FROM order_right_detail',
  'hive.sql.dbcp.maxActive' = '1'
)

另一个是:

CREATE EXTERNAL TABLE IF NOT EXISTS dim_account_info(
     id bigint,
     open_id string,
     user_id string
) STORED BY 'org.apache.hive.storage.jdbc.JdbcStorageHandler' 
LOCATION 'hdfs://hdp5/dpyy/prod/hive/plat_prod.db/dim_account_info' 
TBLPROPERTIES (
  'hive.sql.database.type' = 'MYSQL',
  'hive.sql.jdbc.driver' = 'com.mysql.cj.jdbc.Driver',
  'hive.sql.jdbc.url' = 'jdbc:mysql://XXX.XXX.XXX.XXX:3306/dpyy_ucs?&allowPublicKeyRetrieval=true&useSSL=false',
  'hive.sql.dbcp.username' = 'dpyy_bigdata',
  'hive.sql.dbcp.password' = 'XXXXXXX',
  'hive.sql.query' = 'SELECT id,open_id,user_id FROM account_info',
  'hive.sql.dbcp.maxActive' = '1'
)

当我查询单表时,一切正常,但是当我在连接条件下查询时出现错误,错误是:

Table not found in dpyy_ucs.order_info 
or 
Table not found in dpyy_vas.account_info

在 hive 3.1.3 中似乎不支持多 mysql 数据源,但是在 hive 3.1.0 中可以使用。 谁能给我任何建议来解决 hive 3.1.3 中的这个问题?

mysql apache-spark hadoop hive
1个回答
0
投票

我终于通过使用hive材质视图解决了这个问题,但是,让我感到困惑的是hive视图不起作用

© www.soinside.com 2019 - 2024. All rights reserved.