From eb7aa8c0489e39471784ac7c60fa656ecd17bd09 Mon Sep 17 00:00:00 2001 From: Ge Gao Date: Fri, 6 Mar 2026 15:51:44 -0800 Subject: [PATCH] refactor: HivePartitionManager.parsePartition to instance method and remove timeZone argument (#27284) Summary: Convert parsePartition from a static method to an instance method in HivePartitionManager (presto-facebook-trunk), removing the DateTimeZone timeZone parameter. Then parsePartition could use the timeZone member field of the HivePartitionManager instance instead of requiring callers to pass. Update call sites within HivePartitionManager, TestMetastoreHiveStatisticsProvider, and VectorSearchOptimizerUtils. == NO RELEASE NOTE == Reviewed By: skyelves Differential Revision: D95603597 --- .../com/facebook/presto/hive/HivePartitionManager.java | 10 +++++----- .../TestMetastoreHiveStatisticsProvider.java | 9 ++++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/presto-hive/src/main/java/com/facebook/presto/hive/HivePartitionManager.java b/presto-hive/src/main/java/com/facebook/presto/hive/HivePartitionManager.java index 0829404178f31..b62b9e62e513f 100644 --- a/presto-hive/src/main/java/com/facebook/presto/hive/HivePartitionManager.java +++ b/presto-hive/src/main/java/com/facebook/presto/hive/HivePartitionManager.java @@ -207,7 +207,7 @@ private List getPartitionListFromPartitionNames( { if (isOptimizeParsingOfPartitionValues(session) && partitionNames.size() >= getOptimizeParsingOfPartitionValuesThreshold(session)) { List partitionList = partitionNames.stream() - .map(partitionNameWithVersion -> parsePartition(tableName, partitionNameWithVersion, partitionColumns, partitionTypes, timeZone)) + .map(partitionNameWithVersion -> parsePartition(tableName, partitionNameWithVersion, partitionColumns, partitionTypes)) .collect(toImmutableList()); Map domains = constraint.getSummary().getDomains().get(); @@ -425,6 +425,7 @@ public HivePartitionResult getPartitions(SemiTransactionalHiveMetastore metastor Table table = getTable(session, metastore, hiveTableHandle, isOfflineDataDebugModeEnabled(session)); List partitionColumns = getPartitionKeyColumnHandles(table); + List partitionColumnTypes = partitionColumns.stream() .map(column -> typeManager.getType(column.getTypeSignature())) .collect(toImmutableList()); @@ -455,7 +456,7 @@ private Optional parseValuesAndFilterPartition( List partitionColumnTypes, Constraint constraint) { - HivePartition partition = parsePartition(tableName, partitionNameWithVersion, partitionColumns, partitionColumnTypes, timeZone); + HivePartition partition = parsePartition(tableName, partitionNameWithVersion, partitionColumns, partitionColumnTypes); Map domains = constraint.getSummary().getDomains().get(); for (HiveColumnHandle column : partitionColumns) { @@ -512,12 +513,11 @@ private List getAllPartitionNames(ConnectorSession ses .orElseThrow(() -> new TableNotFoundException(hiveTableHandle.getSchemaTableName())); } - public static HivePartition parsePartition( + public HivePartition parsePartition( SchemaTableName tableName, PartitionNameWithVersion partitionNameWithVersion, List partitionColumns, - List partitionColumnTypes, - DateTimeZone timeZone) + List partitionColumnTypes) { List partitionColumnNames = partitionColumns.stream() .map(HiveColumnHandle::getName) diff --git a/presto-hive/src/test/java/com/facebook/presto/hive/statistics/TestMetastoreHiveStatisticsProvider.java b/presto-hive/src/test/java/com/facebook/presto/hive/statistics/TestMetastoreHiveStatisticsProvider.java index b9dcdf6979db1..d2c5edd9bbefa 100644 --- a/presto-hive/src/test/java/com/facebook/presto/hive/statistics/TestMetastoreHiveStatisticsProvider.java +++ b/presto-hive/src/test/java/com/facebook/presto/hive/statistics/TestMetastoreHiveStatisticsProvider.java @@ -16,11 +16,13 @@ import com.facebook.presto.cache.CacheConfig; import com.facebook.presto.common.predicate.NullableValue; import com.facebook.presto.common.type.DecimalType; +import com.facebook.presto.common.type.TestingTypeManager; import com.facebook.presto.common.type.Type; import com.facebook.presto.hive.HiveBasicStatistics; import com.facebook.presto.hive.HiveClientConfig; import com.facebook.presto.hive.HiveColumnHandle; import com.facebook.presto.hive.HivePartition; +import com.facebook.presto.hive.HivePartitionManager; import com.facebook.presto.hive.HiveSessionProperties; import com.facebook.presto.hive.NamenodeStats; import com.facebook.presto.hive.OrcFileWriterConfig; @@ -65,7 +67,6 @@ import static com.facebook.presto.hive.BaseHiveColumnHandle.ColumnType.REGULAR; import static com.facebook.presto.hive.HiveErrorCode.HIVE_CORRUPTED_COLUMN_STATISTICS; import static com.facebook.presto.hive.HivePartition.UNPARTITIONED_ID; -import static com.facebook.presto.hive.HivePartitionManager.parsePartition; import static com.facebook.presto.hive.HiveTestUtils.DO_NOTHING_DIRECTORY_LISTER; import static com.facebook.presto.hive.HiveTestUtils.HDFS_ENVIRONMENT; import static com.facebook.presto.hive.HiveType.HIVE_LONG; @@ -110,6 +111,8 @@ public class TestMetastoreHiveStatisticsProvider private static final QuickStatsProvider quickStatsProvider = new QuickStatsProvider(new TestingExtendedHiveMetastore(), HDFS_ENVIRONMENT, DO_NOTHING_DIRECTORY_LISTER, new HiveClientConfig(), new NamenodeStats(), ImmutableList.of()); + private final HivePartitionManager hivePartitionManager = new HivePartitionManager(new TestingTypeManager(), new HiveClientConfig()); + @Test public void testGetPartitionsSample() { @@ -825,9 +828,9 @@ private static String invalidColumnStatistics(String message) return format("Corrupted partition statistics (Table: %s Partition: [%s] Column: %s): %s", TABLE, PARTITION, COLUMN, message); } - private static HivePartition partition(String name) + private HivePartition partition(String name) { - return parsePartition(TABLE, new PartitionNameWithVersion(name, Optional.empty()), ImmutableList.of(PARTITION_COLUMN_1, PARTITION_COLUMN_2), ImmutableList.of(VARCHAR, BIGINT), DateTimeZone.getDefault()); + return hivePartitionManager.parsePartition(TABLE, new PartitionNameWithVersion(name, Optional.empty()), ImmutableList.of(PARTITION_COLUMN_1, PARTITION_COLUMN_2), ImmutableList.of(VARCHAR, BIGINT)); } private static PartitionStatistics rowsCount(long rowsCount)