diff --git a/mr/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java b/mr/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java index 4bfd458e7b06..5efca2f1217e 100644 --- a/mr/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java +++ b/mr/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java @@ -85,22 +85,24 @@ public void preCreateTable(org.apache.hadoop.hive.metastore.api.Table hmsTable) // so that the table can be read by other engines like Impala hmsTable.getSd().setInputFormat(HiveIcebergInputFormat.class.getCanonicalName()); hmsTable.getSd().setOutputFormat(HiveIcebergOutputFormat.class.getCanonicalName()); + } - // If not using HiveCatalog check for existing table - try { - this.icebergTable = Catalogs.loadTable(conf, catalogProperties); + // Check for existing table + try { + this.icebergTable = Catalogs.loadTable(conf, catalogProperties); + if (!Catalogs.hiveCatalog(conf, catalogProperties)) { Preconditions.checkArgument(catalogProperties.getProperty(InputFormatConfig.TABLE_SCHEMA) == null, - "Iceberg table already created - can not use provided schema"); + "Iceberg table already created - can not use provided schema"); Preconditions.checkArgument(catalogProperties.getProperty(InputFormatConfig.PARTITION_SPEC) == null, - "Iceberg table already created - can not use provided partition specification"); + "Iceberg table already created - can not use provided partition specification"); + } - LOG.info("Iceberg table already exists {}", icebergTable); + LOG.info("Iceberg table already exists {}", icebergTable); - return; - } catch (NoSuchTableException nte) { - // If the table does not exist we will create it below - } + return; + } catch (NoSuchTableException nte) { + // If the table does not exist we will create it below } // If the table does not exist collect data for table creation