Skip to content

Commit 8fb170b

Browse files
committed
[hms] Fix testAlterTableHandler in later Hive versions
This patch adjusts testAlterTableHandler to stop reusing already created table objects when creating new tables. This prevents issues if read-only properties are set. An example of a read-only property is the ID field added in HIVE-20556. The error seen was: `testAlterTableHandler(org.apache.kudu.hive.metastore.TestKuduMetastorePlugin)InvalidObjectException(message:Id shouldn't be set but table default.table has the Id set to 1. It's a read-only option)` Change-Id: I8f8ddbe30a3e51957cafd8f1b596745b3262ca36 Reviewed-on: http://gerrit.cloudera.org:8080/15349 Reviewed-by: Hao Hao <hao.hao@cloudera.com> Tested-by: Grant Henke <granthenke@apache.org>
1 parent e2301c0 commit 8fb170b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

java/kudu-hive/src/test/java/org/apache/kudu/hive/metastore/TestKuduMetastorePlugin.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,10 @@ public void testCreateTableHandler() throws Exception {
233233
@Test
234234
public void testAlterTableHandler() throws Exception {
235235
// Test altering a Kudu (or a legacy) table.
236-
Table table = newTable("table");
237-
client.createTable(table, masterContext());
236+
Table initTable = newTable("table");
237+
client.createTable(initTable, masterContext());
238238
// Get the table from the HMS in case any translation occurred.
239-
table = client.getTable(table.getDbName(), table.getTableName());
239+
Table table = client.getTable(initTable.getDbName(), initTable.getTableName());
240240
Table legacyTable = newLegacyTable("legacy_table");
241241
client.createTable(legacyTable, masterContext());
242242
// Get the table from the HMS in case any translation occurred.
@@ -380,8 +380,10 @@ public void testAlterTableHandler() throws Exception {
380380

381381
// Test altering a non-Kudu table.
382382
{
383+
table = initTable.deepCopy();
383384
table.getParameters().clear();
384385
client.createTable(table);
386+
table = client.getTable(table.getDbName(), table.getTableName());
385387
try {
386388

387389
// Try to alter the table and add a Kudu table ID.
@@ -431,11 +433,12 @@ public void testAlterTableHandler() throws Exception {
431433

432434
// Test altering an unsynchronized table is accepted.
433435
{
434-
table.getParameters().clear();
436+
table = initTable.deepCopy();
435437
table.setTableType(TableType.EXTERNAL_TABLE.name());
436438
table.putToParameters(KuduMetastorePlugin.EXTERNAL_TABLE_KEY, "TRUE");
437439
table.putToParameters(KuduMetastorePlugin.EXTERNAL_PURGE_KEY, "FALSE");
438440
client.createTable(table);
441+
table = client.getTable(table.getDbName(), table.getTableName());
439442
try {
440443
client.alter_table(table.getDbName(), table.getTableName(), table);
441444
} finally {

0 commit comments

Comments
 (0)