Skip to content

Commit

Permalink
backport hive compatibility apache#4255 apache#4246 apache#4341 to 1.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
GuoPhilipse committed Mar 20, 2023
1 parent ebe52f6 commit 2bb6a39
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,19 @@ public void setVersion(String version) {
public Boolean isEmpty() {
return StringUtils.isBlank(getEngineType()) || StringUtils.isBlank(getVersion());
}

@Override
protected void setStringValue(String stringValue) {
String version;
String engineType = stringValue.split("-")[0];

if (engineType.equals("*")) {
version = stringValue.replaceFirst("[" + engineType + "]-", "");
} else {
version = stringValue.replaceFirst(engineType + "-", "");
}

setEngineType(engineType);
setVersion(version);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* 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.linkis.manager.label.entity.engine;

import org.apache.linkis.manager.label.builder.factory.LabelBuilderFactory;
import org.apache.linkis.manager.label.builder.factory.LabelBuilderFactoryContext;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

/** EngineTypeLabel Tester */
public class EngineTypeLabelTest {

@Test
public void testSetStringValue() {
String engineType = "hive";
String version = "1.1.0-cdh5.12.0";

String engineType1 = "*";
String version1 = "*";

LabelBuilderFactory labelBuilderFactory = LabelBuilderFactoryContext.getLabelBuilderFactory();
EngineTypeLabel engineTypeLabel = labelBuilderFactory.createLabel(EngineTypeLabel.class);
engineTypeLabel.setStringValue(engineType + "-" + version);
Assertions.assertEquals(engineTypeLabel.getEngineType(), engineType);
Assertions.assertEquals(engineTypeLabel.getVersion(), version);

engineTypeLabel.setStringValue(engineType1 + "-" + version1);
Assertions.assertEquals(engineTypeLabel.getEngineType(), engineType1);
Assertions.assertEquals(engineTypeLabel.getVersion(), version1);
}
}
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 @@ -329,7 +332,52 @@ private static void writePrimitiveUTF8(
}
default:
{
throw new RuntimeException("Unknown primitive type: " + category);
if (!"INTERVAL_YEAR_MONTH".equals(category.name())
&& !"INTERVAL_DAY_TIME".equals(category.name())) {
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())
&& "INTERVAL_YEAR_MONTH".equals(category.name());
containsIntervalDayTime =
"INTERVAL_DAY_TIME".equals(primitiveCategory.name())
&& "INTERVAL_DAY_TIME".equals(category.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 | InvocationTargetException | NoSuchMethodException e) {
LOG.error("Fail to invoke method:[getPrimitiveWritableObject]!", e);
}
}
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

0 comments on commit 2bb6a39

Please sign in to comment.