You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ab...@apache.org on 2021/11/12 14:09:34 UTC
[hive] branch master updated: HIVE-25685: HBaseStorageHandler:
ensure that hbase properties are present in final JobConf for Tez (#2776)
(Laszlo Bodor reviewed by Panagiotis Garefalakis)
This is an automated email from the ASF dual-hosted git repository.
abstractdog pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/master by this push:
new cfe7295 HIVE-25685: HBaseStorageHandler: ensure that hbase properties are present in final JobConf for Tez (#2776) (Laszlo Bodor reviewed by Panagiotis Garefalakis)
cfe7295 is described below
commit cfe7295d56aecf4748f8a1b23e016d325783aed0
Author: Bodor Laszlo <bo...@gmail.com>
AuthorDate: Fri Nov 12 15:09:25 2021 +0100
HIVE-25685: HBaseStorageHandler: ensure that hbase properties are present in final JobConf for Tez (#2776) (Laszlo Bodor reviewed by Panagiotis Garefalakis)
---
.../hadoop/hive/hbase/HBaseStorageHandler.java | 1 +
.../hadoop/hive/hbase/TestHBaseStorageHandler.java | 59 ++++++++++++++++++++++
hbase-handler/src/test/resources/hbase-site.xml | 25 +++++++++
3 files changed, 85 insertions(+)
diff --git a/hbase-handler/src/java/org/apache/hadoop/hive/hbase/HBaseStorageHandler.java b/hbase-handler/src/java/org/apache/hadoop/hive/hbase/HBaseStorageHandler.java
index e9546af..302c09c 100644
--- a/hbase-handler/src/java/org/apache/hadoop/hive/hbase/HBaseStorageHandler.java
+++ b/hbase-handler/src/java/org/apache/hadoop/hive/hbase/HBaseStorageHandler.java
@@ -357,6 +357,7 @@ public class HBaseStorageHandler extends DefaultStorageHandler
public void configureJobConf(TableDesc tableDesc, JobConf jobConf) {
LOG.debug("Configuring JobConf for table {}.{}", tableDesc.getDbName(), tableDesc.getTableName());
try {
+ HBaseConfiguration.addHbaseResources(jobConf);
HBaseSerDe.configureJobConf(tableDesc, jobConf);
/*
* HIVE-6356
diff --git a/hbase-handler/src/test/org/apache/hadoop/hive/hbase/TestHBaseStorageHandler.java b/hbase-handler/src/test/org/apache/hadoop/hive/hbase/TestHBaseStorageHandler.java
new file mode 100644
index 0000000..8c8702a
--- /dev/null
+++ b/hbase-handler/src/test/org/apache/hadoop/hive/hbase/TestHBaseStorageHandler.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.hbase;
+
+import java.util.Properties;
+
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.ql.plan.TableDesc;
+import org.apache.hadoop.mapred.JobConf;
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+public class TestHBaseStorageHandler {
+
+ @Test
+ public void testHbaseConfigIsAddedToJobConf() {
+ HBaseStorageHandler hbaseStorageHandler = new HBaseStorageHandler();
+ hbaseStorageHandler.setConf(new JobConf(new HiveConf()));
+
+ TableDesc tableDesc = getHBaseTableDesc();
+
+ JobConf jobConfToConfigure = new JobConf(new HiveConf());
+
+ Assert.assertTrue("hbase-site.xml is supposed to be present",
+ jobConfToConfigure.get("hbase.some.fake.option.from.xml.file") == null);
+
+ hbaseStorageHandler.configureJobConf(tableDesc, jobConfToConfigure);
+
+ Assert.assertTrue("hbase-site.xml is supposed to be added as a resource by HBaseStorageHandler",
+ jobConfToConfigure.get("hbase.some.fake.option.from.xml.file") != null);
+ }
+
+ private TableDesc getHBaseTableDesc() {
+ TableDesc tableDesc = Mockito.mock(TableDesc.class);
+ Properties properties = new Properties();
+ properties.put(HBaseSerDe.HBASE_COLUMNS_MAPPING, "cf:string");
+ properties.put(HBaseSerDe.HBASE_AUTOGENERATE_STRUCT, "true");
+ properties.put("cf.string.serialization.type", "avro");
+ properties.put("cf.string.serialization.class", "org.apache.hadoop.io.serializer.avro.AvroSpecificSerialization");
+ Mockito.when(tableDesc.getProperties()).thenReturn(properties);
+ return tableDesc;
+ }
+}
diff --git a/hbase-handler/src/test/resources/hbase-site.xml b/hbase-handler/src/test/resources/hbase-site.xml
new file mode 100644
index 0000000..6a0c680
--- /dev/null
+++ b/hbase-handler/src/test/resources/hbase-site.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<configuration>
+ <property>
+ <name>hbase.some.fake.option.from.xml.file</name>
+ <value>value</value>
+ </property>
+</configuration>