You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by bl...@apache.org on 2020/10/19 19:34:04 UTC
[iceberg] branch master updated: Hive: Select ObjectInspectors
based on classpath (#1632)
This is an automated email from the ASF dual-hosted git repository.
blue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iceberg.git
The following commit(s) were added to refs/heads/master by this push:
new 0311c23 Hive: Select ObjectInspectors based on classpath (#1632)
0311c23 is described below
commit 0311c2330e9568c96a6beb0306851266b3f5568f
Author: Marton Bod <ma...@gmail.com>
AuthorDate: Mon Oct 19 21:33:50 2020 +0200
Hive: Select ObjectInspectors based on classpath (#1632)
---
.../objectinspector/IcebergObjectInspector.java | 30 +++++++++++++---------
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/mr/src/main/java/org/apache/iceberg/mr/hive/serde/objectinspector/IcebergObjectInspector.java b/mr/src/main/java/org/apache/iceberg/mr/hive/serde/objectinspector/IcebergObjectInspector.java
index f9b2214..ac8bffc 100644
--- a/mr/src/main/java/org/apache/iceberg/mr/hive/serde/objectinspector/IcebergObjectInspector.java
+++ b/mr/src/main/java/org/apache/iceberg/mr/hive/serde/objectinspector/IcebergObjectInspector.java
@@ -28,6 +28,7 @@ import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo;
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
import org.apache.iceberg.Schema;
import org.apache.iceberg.common.DynMethods;
+import org.apache.iceberg.hive.MetastoreUtil;
import org.apache.iceberg.types.Type;
import org.apache.iceberg.types.TypeUtil;
import org.apache.iceberg.types.Types;
@@ -36,23 +37,28 @@ public final class IcebergObjectInspector extends TypeUtil.SchemaVisitor<ObjectI
// get the correct inspectors depending on whether we're working with Hive2 or Hive3 dependencies
// we need to do this because there is a breaking API change in Date/TimestampObjectInspector between Hive2 and Hive3
+ private static final String DATE_INSPECTOR_CLASS = MetastoreUtil.hive3PresentOnClasspath() ?
+ "org.apache.iceberg.mr.hive.serde.objectinspector.IcebergDateObjectInspectorHive3" :
+ "org.apache.iceberg.mr.hive.serde.objectinspector.IcebergDateObjectInspector";
+
private static final ObjectInspector DATE_INSPECTOR = DynMethods.builder("get")
- .impl("org.apache.iceberg.mr.hive.serde.objectinspector.IcebergDateObjectInspectorHive3")
- .impl("org.apache.iceberg.mr.hive.serde.objectinspector.IcebergDateObjectInspector")
- .buildStatic()
- .invoke();
+ .impl(DATE_INSPECTOR_CLASS)
+ .buildStatic()
+ .invoke();
+
+ private static final String TIMESTAMP_INSPECTOR_CLASS = MetastoreUtil.hive3PresentOnClasspath() ?
+ "org.apache.iceberg.mr.hive.serde.objectinspector.IcebergTimestampObjectInspectorHive3" :
+ "org.apache.iceberg.mr.hive.serde.objectinspector.IcebergTimestampObjectInspector";
private static final ObjectInspector TIMESTAMP_INSPECTOR = DynMethods.builder("get")
- .impl("org.apache.iceberg.mr.hive.serde.objectinspector.IcebergTimestampObjectInspectorHive3", boolean.class)
- .impl("org.apache.iceberg.mr.hive.serde.objectinspector.IcebergTimestampObjectInspector", boolean.class)
- .buildStatic()
- .invoke(false);
+ .impl(TIMESTAMP_INSPECTOR_CLASS, boolean.class)
+ .buildStatic()
+ .invoke(false);
private static final ObjectInspector TIMESTAMP_INSPECTOR_WITH_TZ = DynMethods.builder("get")
- .impl("org.apache.iceberg.mr.hive.serde.objectinspector.IcebergTimestampObjectInspectorHive3", boolean.class)
- .impl("org.apache.iceberg.mr.hive.serde.objectinspector.IcebergTimestampObjectInspector", boolean.class)
- .buildStatic()
- .invoke(true);
+ .impl(TIMESTAMP_INSPECTOR_CLASS, boolean.class)
+ .buildStatic()
+ .invoke(true);
public static ObjectInspector create(@Nullable Schema schema) {
if (schema == null) {