我想覆盖我的一些 hive 属性值。我正在使用 spring 上下文连接到 hive。基本上我想执行语句
SET hive.auto.convert.join=false;
template.execute(splitQuery);
但这不起作用。jdbc:hive2://host:port/default;hive.auto.convert.join=false
但这也不起作用。
我的 sprint context.xml 是
<?xml version="1.0" encoding="UTF-8"?><beans:beans xmlns="http://www.springframework.org/schema/hadoop" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:c="http://www.springframework.org/schema/c"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/hadoop http://www.springframework.org/schema/hadoop/spring-hadoop.xsd">
<context:property-placeholder location="hadoop.properties,hive.properties" />
<configuration>
fs.defaultFS=${hd.fs}
yarn.resourcemanager.address=${hd.rm}
mapreduce.framework.name=yarn
mapreduce.jobhistory.address=${hd.jh}
</configuration>
<!-- This sample requires a running HiveServer2 -->
<hive-client-factory id="hiveClientFactory" hive-data-source-ref="hiveDataSource" />
<beans:bean id="hiveDriver" class="org.apache.hive.jdbc.HiveDriver" />
<beans:bean id="hiveDataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
<beans:constructor-arg name="driver" ref="hiveDriver" />
<beans:constructor-arg name="url" value="${hive.url}" />
<beans:constructor-arg name="username" value="${hive.user}" />
<beans:constructor-arg name="password" value="${hive.password}" />
</beans:bean>
<beans:bean id="template" class="org.springframework.jdbc.core.JdbcTemplate" c:data-source-ref="hiveDataSource"/>
<!-- hive-template id="hiveTemplate"/ -->
任何人都可以建议任何其他方式吗?谢谢
您应该能够将附加属性作为
的一部分注入它将在 driver.connect 方法期间注入属性。所以你应该能够做类似的事情(未经测试)
<bean id="myproperties"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="properties">
<value>
hive.auto.convert.join=false
</value>
</property>
</bean>
<beans:bean id="hiveDataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
<beans:constructor-arg name="driver" ref="hiveDriver" />
<beans:constructor-arg name="url" value="${hive.url}" />
<beans:constructor-arg name="username" value="${hive.user}" />
<beans:constructor-arg name="password" value="${hive.password}" />
<property name="connectionProperties" ref="myproperties">
</property>
</beans:bean>
当我使用以下格式时
jdbc:hive2://host:port/database?hive.resultset.use.unique.column.names=false
,该属性实际上对我有用。
请注意数据库名称和属性之间的
?
而不是 ;
。