Hive: Tests to do validation hive content and iceberg table with the same name#9980
Conversation
|
|
||
| catalog.setListAllTables(true); | ||
| List<TableIdentifier> tableIdents2 = catalog.listTables(TABLE_IDENTIFIER.namespace()); | ||
| assertThat(tableIdents2).as("should be 2 tables in namespace .").hasSize(2); |
There was a problem hiding this comment.
this should also use .containsExactly(..) to check what exactly comes back
There was a problem hiding this comment.
assertThat(catalog.listTables(TABLE_IDENTIFIER.namespace())).hasSize(2).containsExactly(...) (no need to define List<TableIdentifier> tableIdents2)
| throws IOException { | ||
| @Test | ||
| public void testHiveTableAndIcebergTableWithSameName() throws TException, IOException { | ||
| List<TableIdentifier> tableIdents = catalog.listTables(TABLE_IDENTIFIER.namespace()); |
There was a problem hiding this comment.
no need to store this in a variable
| @Test | ||
| public void testHiveTableAndIcebergTableWithSameName() throws TException, IOException { | ||
| List<TableIdentifier> tableIdents = catalog.listTables(TABLE_IDENTIFIER.namespace()); | ||
| assertThat(tableIdents).as("should be 1 table in namespace .").hasSize(1); |
There was a problem hiding this comment.
| assertThat(tableIdents).as("should be 1 table in namespace .").hasSize(1); | |
| assertThat(catalog.listTables(TABLE_IDENTIFIER.namespace())).hasSize(1).containsExactly(...); |
| catalog.createTable( | ||
| identifierWithHiveTableName, schema, PartitionSpec.unpartitioned())) | ||
| .isInstanceOf(NoSuchIcebergTableException.class) | ||
| .hasMessageStartingWith("Not an iceberg table: hive.hivedb.test_hive_table"); |
There was a problem hiding this comment.
| .hasMessageStartingWith("Not an iceberg table: hive.hivedb.test_hive_table"); | |
| .hasMessageStartingWith(String.format("Not an iceberg table: %s", identifier)); |
| List<TableIdentifier> tableIdents2 = catalog.listTables(TABLE_IDENTIFIER.namespace()); | ||
| assertThat(tableIdents2).as("should be 2 tables in namespace .").hasSize(2); | ||
|
|
||
| TableIdentifier identifierWithHiveTableName = TableIdentifier.of(DB_NAME, hiveTableName); |
There was a problem hiding this comment.
| TableIdentifier identifierWithHiveTableName = TableIdentifier.of(DB_NAME, hiveTableName); | |
| TableIdentifier identifier = TableIdentifier.of(DB_NAME, hiveTableName); |
| } | ||
|
|
||
| @Test | ||
| public void testHiveViewAndIcebergTableWithSameName() throws TException, IOException { |
There was a problem hiding this comment.
please also reflect the comments from above in this test method
|
|
||
| private org.apache.hadoop.hive.metastore.api.Table createHiveTable(String hiveTableName) | ||
| throws IOException { | ||
| @Test |
There was a problem hiding this comment.
you could change this to a @ParameterizedTest, since the only difference between the two tests is the TableType. So the test would have a TableType parameter, where you pass TableType.EXTERNAL_TABLE and TableType.VIRTUAL_VIEW via @EnumSource (there are examples in the codebase on how to use parameterized tests with enums)
| import org.junit.jupiter.api.extension.ExtendWith; | ||
| import org.junit.jupiter.api.io.TempDir; | ||
|
|
||
| @ExtendWith(ParameterizedTestExtension.class) |
There was a problem hiding this comment.
you don't have to make the full class a parameterized test.
…e can't be created (apache#9980)
…e can't be created (apache#9980)
Hive should not allow creating an iceberg table, if there is already another content available with same name.
@pvary / @szehon-ho Please share your feedback for these tests.