Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private List<HivePartition> getPartitionListFromPartitionNames(
{
if (isOptimizeParsingOfPartitionValues(session) && partitionNames.size() >= getOptimizeParsingOfPartitionValuesThreshold(session)) {
List<HivePartition> partitionList = partitionNames.stream()
.map(partitionNameWithVersion -> parsePartition(tableName, partitionNameWithVersion, partitionColumns, partitionTypes, timeZone))
.map(partitionNameWithVersion -> parsePartition(tableName, partitionNameWithVersion, partitionColumns, partitionTypes))
.collect(toImmutableList());

Map<ColumnHandle, Domain> domains = constraint.getSummary().getDomains().get();
Expand Down Expand Up @@ -425,6 +425,7 @@ public HivePartitionResult getPartitions(SemiTransactionalHiveMetastore metastor
Table table = getTable(session, metastore, hiveTableHandle, isOfflineDataDebugModeEnabled(session));

List<HiveColumnHandle> partitionColumns = getPartitionKeyColumnHandles(table);

List<Type> partitionColumnTypes = partitionColumns.stream()
.map(column -> typeManager.getType(column.getTypeSignature()))
.collect(toImmutableList());
Expand Down Expand Up @@ -455,7 +456,7 @@ private Optional<HivePartition> parseValuesAndFilterPartition(
List<Type> partitionColumnTypes,
Constraint<ColumnHandle> constraint)
{
HivePartition partition = parsePartition(tableName, partitionNameWithVersion, partitionColumns, partitionColumnTypes, timeZone);
HivePartition partition = parsePartition(tableName, partitionNameWithVersion, partitionColumns, partitionColumnTypes);

Map<ColumnHandle, Domain> domains = constraint.getSummary().getDomains().get();
for (HiveColumnHandle column : partitionColumns) {
Expand Down Expand Up @@ -512,12 +513,11 @@ private List<PartitionNameWithVersion> getAllPartitionNames(ConnectorSession ses
.orElseThrow(() -> new TableNotFoundException(hiveTableHandle.getSchemaTableName()));
}

public static HivePartition parsePartition(
public HivePartition parsePartition(
SchemaTableName tableName,
PartitionNameWithVersion partitionNameWithVersion,
List<HiveColumnHandle> partitionColumns,
List<Type> partitionColumnTypes,
DateTimeZone timeZone)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is under the assumption that the timeZone used will always be the timeZone defined in the class?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, exactly. Checked all call sites, and all set this parameter to the timeZone member of the class, except unit tests.

(It's hard for the user to get the timezone configured in prod.)

List<Type> partitionColumnTypes)
{
List<String> partitionColumnNames = partitionColumns.stream()
.map(HiveColumnHandle::getName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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()
{
Expand Down Expand Up @@ -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)
Expand Down
Loading