-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should also use .containsExactly(..)
to check what exactly comes back
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please also reflect the comments from above in this test method
@@ -349,8 +351,70 @@ public void testListTables() throws TException, IOException { | |||
HIVE_METASTORE_EXTENSION.metastoreClient().dropTable(DB_NAME, hiveTableName); | |||
} | |||
|
|||
private org.apache.hadoop.hive.metastore.api.Table createHiveTable(String hiveTableName) | |||
throws IOException { | |||
@Test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.io.TempDir; | ||
|
||
@ExtendWith(ParameterizedTestExtension.class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't have to make the full class a parameterized test.
Lines 137 to 141 in 820fc3c
@ParameterizedTest | |
@EnumSource( | |
value = TableSchemaType.class, | |
names = {"ONE_BUCKET", "IDENTITY_AND_BUCKET"}) | |
public void testSendRecordsToAllBucketsEvenly(TableSchemaType tableSchemaType) throws Exception { |
…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.