当尝试查询时,是否可以通过hive odbc连接发送hive conf变量?

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

我有一个hive脚本,上面有一些hive conf变量。当我在我们的emr集群上运行这个查询时,它的工作很好,返回的是预期的数据。例如,我想在我们的emr集群上运行这个查询,它可以正常运行,并返回预期的数据。

set hive.exec.dynamic.partition.mode=nonstrict;
set hive.exec.dynamic.partition=true;
set hive.exec.max.dynamic.partitions=10000;
set mapreduce.map.memory.mb=7168;
set mapreduce.reduce.memory.mb=7168;
set hive.exec.max.dynamic.partitions.pernode=10000;
set hive.exec.compress.output=true;
set mapred.output.compression.codec=org.apache.hadoop.io.compress.SnappyCodec;
set hive.execution.engine=mr;
select 
  fruits,
  count(1) as n
from table
group by fruits;

我想在另一台与hive有odbc连接的服务器上运行这个查询。

(我在r中)

hive_conn <- DBI::dbConnect(odbc(), dsn = "Hive")
results <- DBI::dbGetQuery(hive_conn,  "select fruits, count(1) as n from table group by fruits")

这运行得很好,并按预期返回一个数据帧。

然而,如果我想设置一些hive配置,我不知道如何用odbc发送这些配置。

我如何通过 odbc 告诉 hive 用我选择的 hive conf 设置来运行我的查询?

set hive.exec.dynamic.partition.mode=nonstrict;
set hive.exec.dynamic.partition=true;
set hive.exec.max.dynamic.partitions=10000;
set mapreduce.map.memory.mb=7168;
set mapreduce.reduce.memory.mb=7168;
set hive.exec.max.dynamic.partitions.pernode=10000;
set hive.exec.compress.output=true;
set mapred.output.compression.codec=org.apache.hadoop.io.compress.SnappyCodec;
set hive.execution.engine=mr;
r hive odbc r-dbi
1个回答
0
投票

我在驱动的文档中找到了解决这个问题的方法。https:/www.simba.comproductsHivedocODBC_InstallGuidelinuxcontentodbchiconfiguringserverside.htm

我需要在创建连接时添加这些 "服务器端属性"。你可以在前面加上字符串'SSP_'(服务器端属性),然后以名称值对的形式添加它们,例如

hive_conn <- dbConnect(odbc(), 
                       dsn = "Hive", 
                       SSP_hive.execution.engine = "mr",
                       SSP_hive.exec.dynamic.partition.mode = "nonstrict",
                       SSP_hive.exec.dynamic.partition = "true",
                       SSP_hive.exec.max.dynamic.partitions = 10000,
                       SSP_mapreduce.map.memory.mb = 7168,
                       SSP_mapreduce.reduce.memory.mb = 7168,
                       SSP_hive.exec.max.dynamic.partitions.pernode = 10000,
                       SSP_hive.exec.compress.output = "true",
                       SSP_mapred.output.compression.codec = "org.apache.hadoop.io.compress.SnappyCodec"
                       )
© www.soinside.com 2019 - 2024. All rights reserved.