-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Refactor HiveStatisticsProvider and statistics SPI #11463
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
Changes from all commits
04920e5
351a61f
31ce369
aed92f8
1ff1e28
b3827bf
f847336
845a0d8
9229cda
5b9a58f
ea3a814
5f5e662
1344eb9
652112e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -137,6 +137,7 @@ public class HiveClientConfig | |
|
|
||
| private boolean tableStatisticsEnabled = true; | ||
| private int partitionStatisticsSampleSize = 100; | ||
| private boolean ignoreCorruptedStatistics; | ||
|
||
| private boolean collectColumnStatisticsOnWrite; | ||
|
|
||
| public int getMaxInitialSplits() | ||
|
|
@@ -1094,6 +1095,19 @@ public HiveClientConfig setPartitionStatisticsSampleSize(int partitionStatistics | |
| return this; | ||
| } | ||
|
|
||
| public boolean isIgnoreCorruptedStatistics() | ||
| { | ||
| return ignoreCorruptedStatistics; | ||
| } | ||
|
|
||
| @Config("hive.ignore-corrupted-statistics") | ||
| @ConfigDescription("Ignore corrupted statistics rather than failing") | ||
| public HiveClientConfig setIgnoreCorruptedStatistics(boolean ignoreCorruptedStatistics) | ||
| { | ||
| this.ignoreCorruptedStatistics = ignoreCorruptedStatistics; | ||
| return this; | ||
| } | ||
|
|
||
| public boolean isCollectColumnStatisticsOnWrite() | ||
| { | ||
| return collectColumnStatisticsOnWrite; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -123,7 +123,7 @@ | |
| import static com.facebook.presto.hive.HiveErrorCode.HIVE_UNKNOWN_ERROR; | ||
| import static com.facebook.presto.hive.HiveErrorCode.HIVE_UNSUPPORTED_FORMAT; | ||
| import static com.facebook.presto.hive.HiveErrorCode.HIVE_WRITER_CLOSE_ERROR; | ||
| import static com.facebook.presto.hive.HivePartitionManager.extractPartitionKeyValues; | ||
| import static com.facebook.presto.hive.HivePartitionManager.extractPartitionValues; | ||
| import static com.facebook.presto.hive.HiveSessionProperties.getHiveStorageFormat; | ||
| import static com.facebook.presto.hive.HiveSessionProperties.isBucketExecutionEnabled; | ||
| import static com.facebook.presto.hive.HiveSessionProperties.isCollectColumnStatisticsOnWrite; | ||
|
|
@@ -180,7 +180,6 @@ | |
| import static com.facebook.presto.spi.StandardErrorCode.NOT_SUPPORTED; | ||
| import static com.facebook.presto.spi.StandardErrorCode.SCHEMA_NOT_EMPTY; | ||
| import static com.facebook.presto.spi.predicate.TupleDomain.withColumnDomains; | ||
| import static com.facebook.presto.spi.statistics.TableStatistics.EMPTY_STATISTICS; | ||
| import static com.google.common.base.MoreObjects.firstNonNull; | ||
| import static com.google.common.base.Preconditions.checkArgument; | ||
| import static com.google.common.base.Verify.verify; | ||
|
|
@@ -525,14 +524,16 @@ public Map<SchemaTableName, List<ColumnMetadata>> listTableColumns(ConnectorSess | |
| public TableStatistics getTableStatistics(ConnectorSession session, ConnectorTableHandle tableHandle, Constraint<ColumnHandle> constraint) | ||
| { | ||
| if (!isStatisticsEnabled(session)) { | ||
|
||
| return EMPTY_STATISTICS; | ||
| return TableStatistics.empty(); | ||
| } | ||
| List<HivePartition> hivePartitions = getPartitionsAsList(tableHandle, constraint); | ||
| Map<String, ColumnHandle> tableColumns = getColumnHandles(session, tableHandle) | ||
| Map<String, ColumnHandle> columns = getColumnHandles(session, tableHandle) | ||
| .entrySet().stream() | ||
| .filter(entry -> !((HiveColumnHandle) entry.getValue()).isHidden()) | ||
| .collect(toImmutableMap(Map.Entry::getKey, Map.Entry::getValue)); | ||
| return hiveStatisticsProvider.getTableStatistics(session, tableHandle, hivePartitions, tableColumns); | ||
| Map<String, Type> columnTypes = columns.entrySet().stream() | ||
| .collect(toImmutableMap(Map.Entry::getKey, entry -> getColumnMetadata(session, tableHandle, entry.getValue()).getType())); | ||
| List<HivePartition> partitions = getPartitionsAsList(tableHandle, constraint); | ||
| return hiveStatisticsProvider.getTableStatistics(session, ((HiveTableHandle) tableHandle).getSchemaTableName(), columns, columnTypes, partitions); | ||
| } | ||
|
|
||
| private List<HivePartition> getPartitionsAsList(ConnectorTableHandle tableHandle, Constraint<ColumnHandle> constraint) | ||
|
|
@@ -1272,7 +1273,7 @@ private Partition buildPartitionObject(ConnectorSession session, Table table, Pa | |
| .setDatabaseName(table.getDatabaseName()) | ||
| .setTableName(table.getTableName()) | ||
| .setColumns(table.getDataColumns()) | ||
| .setValues(extractPartitionKeyValues(partitionUpdate.getName())) | ||
| .setValues(extractPartitionValues(partitionUpdate.getName())) | ||
| .setParameters(ImmutableMap.<String, String>builder() | ||
| .put(PRESTO_VERSION_NAME, prestoVersion) | ||
| .put(PRESTO_QUERY_ID_NAME, session.getQueryId()) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.