@Test
  public void testCreateTableWithMetadataLocationWithoutSchema() throws IOException, TException, InterruptedException {
    Assume.assumeTrue("Create with metadata location is only supported for Hive Catalog tables",
        testTableType.equals(TestTables.TestTableType.HIVE_CATALOG));
    TableIdentifier sourceIdentifier = TableIdentifier.of("default", "source");
    PartitionSpec spec =
        PartitionSpec.builderFor(HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA).identity("customer_id").build();
    List<Record> records = TestHelper.generateRandomRecords(HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA, 4, 0L);
    Table sourceTable =
        testTables.createTable(shell, sourceIdentifier.name(), HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA, spec,
            FileFormat.PARQUET, records, 1,
            ImmutableMap.<String, String>builder().put(InputFormatConfig.EXTERNAL_TABLE_PURGE, "FALSE").build());
    String metadataLocation = ((BaseTable) sourceTable).operations().current().metadataFileLocation();
    shell.executeStatement("DROP TABLE " + sourceIdentifier.name());
    TableIdentifier targetIdentifier = TableIdentifier.of("default", "target");

    String tblProps =
        testTables.propertiesForCreateTableSQL(Collections.singletonMap("metadata_location", metadataLocation));

    // Try the query with columns also specified, it should throw exception.
    Assertions.assertThatThrownBy(() -> {
      shell.executeStatement("CREATE EXTERNAL TABLE target (id int) STORED BY ICEBERG " +
              testTables.locationForCreateTableSQL(targetIdentifier) + tblProps);
    })
        .isInstanceOf(IllegalArgumentException.class)
        .hasMessageContaining("Column names can not be provided along with metadata location.");
    shell.executeStatement(
            "CREATE EXTERNAL TABLE target STORED BY ICEBERG " + testTables.locationForCreateTableSQL(targetIdentifier) +
                    tblProps);

    // Check the partition and the schema are preserved.
    Table targetIcebergTable =
        IcebergTableUtil.getTable(shell.getHiveConf(), shell.metastore().getTable(targetIdentifier));
    Assert.assertEquals(1, targetIcebergTable.spec().fields().size());
    Assert.assertEquals(sourceTable.spec().fields(), targetIcebergTable.spec().fields());
    Assert.assertEquals(sourceTable.schema().toString(), targetIcebergTable.schema().toString());
  }
Checks that HiveIcebergMetaHook doesn't run into failures with undefined alter operation type (e.g. stat updates)
@throws Exception - any test failure
iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergStorageHandlerNoScan.java