来自配置单元的查询红移,不下推 predicate

w6lpcovy  于 2021-06-25  发布在  Hive
关注(0)|答案(0)|浏览(289)

我用emr5.28.0、spark和hive发布了一个aws emr集群。我习惯于使用spark redshift connector激发sql,它使我能够在redshift中读/写,并创建如下外部表:

CREATE TABLE `test`.`redshift_table` (`id` INT, `object_id` STRING)
USING com.databricks.spark.redshift
OPTIONS (
  `tempdir` 's3a://my_bucket/table/',
  `url` 'jdbc:redshift://xxxxxx:5439/database?user=user&password=password',
  `forward_spark_s3_credentials` 'true',
  `serialization.format` '1',
  `dbtable` 'my.table'
)

现在我要在Hive里寻找同样的东西:
至少能够从配置单元中读取红移表(这样我就可以将红移数据与datalake中的其他表连接起来)
如果可能,也可以从配置单元写入redshift(这样我就可以在数据湖中创建etl,将一些结果写入redshift)
我四处查看了一下,但不确定create表的格式是什么,也不确定之前是否需要在集群上安装其他东西。
谢谢
更新:我已经能够用emr 5.28.0现在使用这些JAR:
https://mvnrepository.com/artifact/org.apache.hive/hive-jdbc-handler/3.1.2
https://s3.amazonaws.com/redshift-downloads/drivers/jdbc/1.2.37.1061/redshiftjdbc42-no-awssdk-1.2.37.1061.jar
然后在配置单元中创建表:

CREATE EXTERNAL TABLE test.table(
    id INTEGER,
    name STRING
)
STORED BY 'org.apache.hive.storage.jdbc.JdbcStorageHandler'
TBLPROPERTIES (
    "hive.sql.database.type" = "POSTGRES",
    "hive.sql.jdbc.driver" = "com.amazon.redshift.jdbc.Driver",
    "hive.sql.jdbc.url" = "jdbc:redshift://host:5439/database",
    "hive.sql.dbcp.username" = "user",
    "hive.sql.dbcp.password" = "password",
    "hive.sql.table" = "schema.name",
    "hive.sql.dbcp.maxActive" = "1"
);

我现在的问题是它不会将 predicate 下推到红移。例如“select*from test.table where id=1;”首先执行一个红移查询读取整个表,你知道如何改变这个行为吗?
我检查了配置单元设置,我有:

hive.optimize.ppd=true
hive.optimize.ppd.storage=true

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题