Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] support different hive version #4255

Merged
merged 3 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion linkis-engineconn-plugins/flink/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
<artifactId>linkis-engineconn-plugin-flink</artifactId>
<properties>
<flink.version>1.12.2</flink.version>
<hive.version>2.3.3</hive.version>
<commons-cli.version>1.3.1</commons-cli.version>
</properties>

Expand Down
4 changes: 0 additions & 4 deletions linkis-engineconn-plugins/hive/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@

<artifactId>linkis-engineplugin-hive</artifactId>

<properties>
<hive.version>2.3.3</hive.version>
</properties>

<dependencies>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.linkis.engineplugin.hive.serde;

import org.apache.linkis.common.utils.ClassUtils;

import org.apache.commons.codec.binary.Base64;
import org.apache.hadoop.hive.serde2.ByteStream;
import org.apache.hadoop.hive.serde2.SerDeException;
Expand All @@ -33,6 +35,7 @@

import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -309,18 +312,6 @@ private static void writePrimitiveUTF8(
binaryData = Base64.encodeBase64(String.valueOf(wc).getBytes());
break;
}
case INTERVAL_YEAR_MONTH:
{
wc = ((HiveIntervalYearMonthObjectInspector) oi).getPrimitiveWritableObject(o);
binaryData = Base64.encodeBase64(String.valueOf(wc).getBytes());
break;
}
case INTERVAL_DAY_TIME:
{
wc = ((HiveIntervalDayTimeObjectInspector) oi).getPrimitiveWritableObject(o);
binaryData = Base64.encodeBase64(String.valueOf(wc).getBytes());
break;
}
case DECIMAL:
{
HiveDecimalObjectInspector decimalOI = (HiveDecimalObjectInspector) oi;
Expand All @@ -329,7 +320,48 @@ private static void writePrimitiveUTF8(
}
default:
{
throw new RuntimeException("Unknown primitive type: " + category);
boolean containsIntervalYearMonth = false;
boolean containsIntervalDayTime = false;
for (PrimitiveObjectInspector.PrimitiveCategory primitiveCategory :
PrimitiveObjectInspector.PrimitiveCategory.values()) {
containsIntervalYearMonth = "INTERVAL_YEAR_MONTH".equals(primitiveCategory.name());
containsIntervalDayTime = "INTERVAL_DAY_TIME".equals(primitiveCategory.name());
try {
if (containsIntervalYearMonth) {
wc =
(WritableComparable)
ClassUtils.getClassInstance(
"org.apache.hadoop.hive.serde2.objectinspector.primitive.HiveIntervalYearMonthObjectInspector")
.getClass()
.getMethod("getPrimitiveWritableObject", Object.class)
.invoke(oi, o);
binaryData = Base64.encodeBase64(String.valueOf(wc).getBytes());
break;
}
if (containsIntervalDayTime) {
wc =
(WritableComparable)
ClassUtils.getClassInstance(
"org.apache.hadoop.hive.serde2.objectinspector.primitive.HiveIntervalDayTimeObjectInspector")
.getClass()
.getMethod("getPrimitiveWritableObject", Object.class)
.invoke(oi, o);
binaryData = Base64.encodeBase64(String.valueOf(wc).getBytes());
break;
}
} catch (IllegalAccessException e) {
e.printStackTrace();
jackxu2011 marked this conversation as resolved.
Show resolved Hide resolved
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
}
if (containsIntervalYearMonth || containsIntervalDayTime) {
break;
} else {
throw new RuntimeException("Unknown primitive type: " + category);
}
}
}
if (binaryData == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<artifactId>linkis-metadata-query-service-hive</artifactId>

<properties>
<hive.version>2.3.3</hive.version>
<hadoop.version>2.7.2</hadoop.version>
<datanucleus-api-jdo.version>4.2.4</datanucleus-api-jdo.version>
</properties>
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
<revision>1.3.2-SNAPSHOT</revision>
<jedis.version>2.9.2</jedis.version>
<spark.version>2.4.3</spark.version>
<hive.version>2.3.3</hive.version>
<hadoop.version>2.7.2</hadoop.version>
<hadoop-hdfs-client.artifact>hadoop-hdfs</hadoop-hdfs-client.artifact>
<hadoop-hdfs-client-shade.version>2.7.2</hadoop-hdfs-client-shade.version>
Expand Down