pvary commented on a change in pull request #1495:
URL: https://github.com/apache/iceberg/pull/1495#discussion_r503726841



##########
File path: mr/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergSerDe.java
##########
@@ -29,25 +29,42 @@
 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.exceptions.NoSuchTableException;
 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;
 
 public class HiveIcebergSerDe extends AbstractSerDe {
-
   private ObjectInspector inspector;
 
   @Override
   public void initialize(@Nullable Configuration configuration, Properties 
serDeProperties) throws SerDeException {
+    // HiveIcebergSerDe.initialize is called multiple places in Hive code:
+    // - When we are trying to create a table - HiveDDL data is stored at the 
serDeProperties, but no Iceberg table
+    // is created yet.
+    // - When we are compiling the Hive query on HiveServer2 side - We only 
have table information (location/name),
+    // and we have to read the schema using the table data. This is called 
multiple times so there is room for
+    // optimizing here.
+    // - When we are executing the Hive query in the execution engine - We do 
not want to load the table data on every
+    // executor, but serDeProperties are populated by 
HiveIcebergStorageHandler.configureInputJobProperties() and
+    // the resulting properties are serialized and distributed to the executors
+
     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();
+      if (serDeProperties.get(InputFormatConfig.TABLE_SCHEMA) != null) {

Review comment:
       Done.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to