From b8cf57429591a52cf05902e6852131483bf8054b Mon Sep 17 00:00:00 2001 From: Dmitriy Fingerman Date: Fri, 18 Oct 2024 09:28:55 -0400 Subject: [PATCH] Review comments Oct 18. --- .../cli/TestIcebergLlapLocalCompactorCliDriver.java | 8 ++++---- .../hadoop/hive/ql/parse/TestParseOptimizeTable.java | 12 ++++++------ .../storage/compact/AlterTableCompactOperation.java | 6 ++++-- .../hadoop/hive/ql/txn/compactor/Initiator.java | 2 -- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/itests/qtest-iceberg/src/test/java/org/apache/hadoop/hive/cli/TestIcebergLlapLocalCompactorCliDriver.java b/itests/qtest-iceberg/src/test/java/org/apache/hadoop/hive/cli/TestIcebergLlapLocalCompactorCliDriver.java index af1f079b452d..3b41b2eb4307 100644 --- a/itests/qtest-iceberg/src/test/java/org/apache/hadoop/hive/cli/TestIcebergLlapLocalCompactorCliDriver.java +++ b/itests/qtest-iceberg/src/test/java/org/apache/hadoop/hive/cli/TestIcebergLlapLocalCompactorCliDriver.java @@ -41,8 +41,8 @@ public class TestIcebergLlapLocalCompactorCliDriver { static CliAdapter adapter = new CliConfigs.IcebergLlapLocalCompactorCliConfig().getCliAdapter(); private static final AtomicBoolean stop = new AtomicBoolean(); - private static final String defaultPoolName = null; - private static final String icebergPoolName = "iceberg"; + private static final String DEFAULT_POOL_NAME = null; + private static final String ICEBERG_POOL_NAME = "iceberg"; private static Worker worker; @Parameters(name ="{0}") @@ -52,8 +52,8 @@ public static List getParameters() throws Exception { @BeforeClass public static void setup() throws Exception { - setupWorker(defaultPoolName); - setupWorker(icebergPoolName); + setupWorker(DEFAULT_POOL_NAME); + setupWorker(ICEBERG_POOL_NAME); } private static void setupWorker(String poolName) throws Exception { diff --git a/parser/src/test/org/apache/hadoop/hive/ql/parse/TestParseOptimizeTable.java b/parser/src/test/org/apache/hadoop/hive/ql/parse/TestParseOptimizeTable.java index dec6f3cf77b9..db5c2a060707 100644 --- a/parser/src/test/org/apache/hadoop/hive/ql/parse/TestParseOptimizeTable.java +++ b/parser/src/test/org/apache/hadoop/hive/ql/parse/TestParseOptimizeTable.java @@ -28,7 +28,7 @@ public class TestParseOptimizeTable { @Test public void testOptimizeTableWithWhere() throws Exception { - String EXPECTED_WHERE_FILTER = "\n" + + String expectedWhereFilter = "\n" + "nil\n" + " TOK_ALTERTABLE\n" + " TOK_TABNAME\n" + @@ -52,13 +52,13 @@ public void testOptimizeTableWithWhere() throws Exception { ASTNode tree = parseDriver.parse( " optimize table tbl0 rewrite data where (col01 in ('A', 'B') and col02 < '2024-09-17 00:00:00')", null).getTree(); - assertThat(tree.dump(), is(EXPECTED_WHERE_FILTER)); + assertThat(tree.dump(), is(expectedWhereFilter)); } @Test public void testOptimizeTableWithOrderBy() throws Exception { - String EXPECTED_ORDER_BY = "\n" + + String expectedOrderBy = "\n" + "nil\n" + " TOK_ALTERTABLE\n" + " TOK_TABNAME\n" + @@ -75,13 +75,13 @@ public void testOptimizeTableWithOrderBy() throws Exception { ASTNode tree = parseDriver.parse( " optimize table tbl0 rewrite data order by col01 desc", null).getTree(); - assertThat(tree.dump(), is(EXPECTED_ORDER_BY)); + assertThat(tree.dump(), is(expectedOrderBy)); } @Test public void testOptimizeTableWithPool() throws Exception { - String EXPECTED_WITH_COMPACT_POOL = "\n" + + String expectedWithCompactPool = "\n" + "nil\n" + " TOK_ALTERTABLE\n" + " TOK_TABNAME\n" + @@ -95,6 +95,6 @@ public void testOptimizeTableWithPool() throws Exception { ASTNode tree = parseDriver.parse( " optimize table tbl0 rewrite data pool 'iceberg'", null).getTree(); - assertThat(tree.dump(), is(EXPECTED_WITH_COMPACT_POOL)); + assertThat(tree.dump(), is(expectedWithCompactPool)); } } diff --git a/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/storage/compact/AlterTableCompactOperation.java b/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/storage/compact/AlterTableCompactOperation.java index 5256e14ed8b2..842ac8cc8784 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/storage/compact/AlterTableCompactOperation.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/storage/compact/AlterTableCompactOperation.java @@ -92,8 +92,10 @@ else if (desc.getPartitionSpec() != null) { CompactionRequest compactionRequest = new CompactionRequest(table.getDbName(), table.getTableName(), compactionTypeStr2ThriftType(desc.getCompactionType())); - compactionRequest.setPoolName(ObjectUtils.defaultIfNull(desc.getPoolName(), - CompactorUtil.getPoolName(context.getConf(), table.getTTable(), metadataCache))); + String poolName = ObjectUtils.defaultIfNull(desc.getPoolName(), + CompactorUtil.getPoolName(context.getConf(), table.getTTable(), metadataCache)); + + compactionRequest.setPoolName(poolName); compactionRequest.setProperties(desc.getProperties()); compactionRequest.setInitiatorId(JavaUtils.hostname() + "-" + HiveMetaStoreClient.MANUALLY_INITIATED_COMPACTION); compactionRequest.setInitiatorVersion(HiveMetaStoreClient.class.getPackage().getImplementationVersion()); diff --git a/ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/Initiator.java b/ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/Initiator.java index 3c50980428c9..8a1bcb987335 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/Initiator.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/Initiator.java @@ -19,10 +19,8 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Sets; -import org.apache.commons.lang3.StringUtils; import org.apache.hadoop.hive.common.ServerUtils; import org.apache.hadoop.hive.common.ValidTxnList; -import org.apache.hadoop.hive.conf.Constants; import org.apache.hadoop.hive.conf.HiveConf; import org.apache.hadoop.hive.metastore.api.*; import org.apache.hadoop.hive.metastore.conf.MetastoreConf;