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/10 21:09:29 UTC
[iceberg] branch master updated: Hive: Avoid loading catalog to
initialized a serde (#1564)
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 3c7abb1 Hive: Avoid loading catalog to initialized a serde (#1564)
3c7abb1 is described below
commit 3c7abb12a5865445afb5366341a5b8fd705cbcb6
Author: Sushant Raikar <sr...@linkedin.com>
AuthorDate: Sat Oct 10 14:09:18 2020 -0700
Hive: Avoid loading catalog to initialized a serde (#1564)
---
.../java/org/apache/iceberg/mr/hive/HiveIcebergSerDe.java | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/mr/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergSerDe.java b/mr/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergSerDe.java
index e3c9bb4..b46847e 100644
--- a/mr/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergSerDe.java
+++ b/mr/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergSerDe.java
@@ -27,8 +27,11 @@ import org.apache.hadoop.hive.serde2.SerDeException;
import org.apache.hadoop.hive.serde2.SerDeStats;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
import org.apache.hadoop.io.Writable;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.SchemaParser;
import org.apache.iceberg.Table;
import org.apache.iceberg.mr.Catalogs;
+import org.apache.iceberg.mr.InputFormatConfig;
import org.apache.iceberg.mr.hive.serde.objectinspector.IcebergObjectInspector;
import org.apache.iceberg.mr.mapred.Container;
@@ -38,10 +41,15 @@ public class HiveIcebergSerDe extends AbstractSerDe {
@Override
public void initialize(@Nullable Configuration configuration, Properties serDeProperties) throws SerDeException {
- Table table = Catalogs.loadTable(configuration, serDeProperties);
-
+ Schema tableSchema;
+ if (configuration.get(InputFormatConfig.TABLE_SCHEMA) != null) {
+ tableSchema = SchemaParser.fromJson(configuration.get(InputFormatConfig.TABLE_SCHEMA));
+ } else {
+ Table table = Catalogs.loadTable(configuration, serDeProperties);
+ tableSchema = table.schema();
+ }
try {
- this.inspector = IcebergObjectInspector.create(table.schema());
+ this.inspector = IcebergObjectInspector.create(tableSchema);
} catch (Exception e) {
throw new SerDeException(e);
}