Search in sources :

Example 6 with HiveOffloadExpression

use of io.prestosql.plugin.hive.HiveOffloadExpression in project boostkit-bigdata by kunpengcompute.

the class TestHivePushdownUtil method matchFilterOffloadWithAlias.

protected static void matchFilterOffloadWithAlias(PlanNode node, String predicate) {
    HiveOffloadExpression expression = getCheckedOffloadExpression(node);
    assertTrue(expression.isPresent());
    assertEquals(predicate, expression.getFilterExpression().toString());
}
Also used : HiveOffloadExpression(io.prestosql.plugin.hive.HiveOffloadExpression)

Example 7 with HiveOffloadExpression

use of io.prestosql.plugin.hive.HiveOffloadExpression in project boostkit-bigdata by kunpengcompute.

the class TestHivePushdownUtil method matchAggregatorOffload.

protected static void matchAggregatorOffload(PlanNode node, AggregationInfo aggregationInfoExpected) {
    HiveOffloadExpression expression = getCheckedOffloadExpression(node);
    assertTrue(expression.isPresent());
    assertTrue(expression.getAggregations().isPresent());
    AggregationInfo aggregationInfo = expression.getAggregations().get();
    assertEquals(aggregationInfoExpected, aggregationInfo);
}
Also used : HiveOffloadExpression(io.prestosql.plugin.hive.HiveOffloadExpression) AggregationInfo(com.huawei.boostkit.omnidata.model.AggregationInfo)

Example 8 with HiveOffloadExpression

use of io.prestosql.plugin.hive.HiveOffloadExpression in project boostkit-bigdata by kunpengcompute.

the class TestHivePushdownUtil method matchProjection.

protected static void matchProjection(PlanNode node, Map<Symbol, RowExpression> projections) {
    HiveOffloadExpression expression = getCheckedOffloadExpression(node);
    assertTrue(expression.isPresent());
    assertTrue(!expression.getProjections().isEmpty());
    assertEquals(projections, expression.getProjections());
}
Also used : HiveOffloadExpression(io.prestosql.plugin.hive.HiveOffloadExpression)

Example 9 with HiveOffloadExpression

use of io.prestosql.plugin.hive.HiveOffloadExpression in project boostkit-bigdata by kunpengcompute.

the class HiveFilterPushdown method pushdownFilter.

private static ConnectorPushdownFilterResult pushdownFilter(HiveMetadata metadata, ConnectorSession session, ConnectorTableHandle tableHandle, RowExpression predicate, Map<String, Type> typesMap, RowExpressionService rowExpressionService, StandardFunctionResolution functionResolution, FunctionMetadataManager functionMetadataManager, FilterStatsCalculatorService filterCalculatorService) {
    checkArgument(!FALSE_CONSTANT.equals(predicate), "Cannot pushdown filter that is always false");
    checkArgument(tableHandle instanceof HiveTableHandle, "Only supports hive TableHandle");
    LogicalRowExpressions logicalRowExpressions = new LogicalRowExpressions(rowExpressionService.getDeterminismEvaluator(), functionResolution, functionMetadataManager);
    ExpressionExtractResult expressionExtractResult = extractOffloadExpression(predicate, logicalRowExpressions, rowExpressionService);
    if (TRUE_CONSTANT.equals(expressionExtractResult.getOffloadExpression())) {
        return new ConnectorPushdownFilterResult(Optional.empty(), TRUE_CONSTANT);
    }
    HiveTableHandle hiveTableHandle = (HiveTableHandle) tableHandle;
    Map<String, ColumnHandle> columnHandlesMap = metadata.getColumnHandles(session, tableHandle);
    HiveOffloadExpression oldOffloadExpression = hiveTableHandle.getOffloadExpression();
    RowExpression filterExpression = TRUE_CONSTANT.equals(oldOffloadExpression.getFilterExpression()) ? expressionExtractResult.getOffloadExpression() : logicalRowExpressions.combineConjuncts(oldOffloadExpression.getFilterExpression(), expressionExtractResult.getOffloadExpression());
    RowExpression optimizedExpression = filterExpression;
    if (true != determineOffloadExpression(optimizedExpression, tableHandle, metadata, session, rowExpressionService, columnHandlesMap, filterCalculatorService, typesMap)) {
        return new ConnectorPushdownFilterResult(Optional.empty(), TRUE_CONSTANT);
    }
    Set<HiveColumnHandle> offloadColumns = HivePushdownUtil.extractAll(optimizedExpression).stream().map(entry -> (HiveColumnHandle) columnHandlesMap.get(entry.getName())).collect(Collectors.toSet());
    Optional<ConnectorTableHandle> newTableHandle = Optional.of(hiveTableHandle.withOffloadExpression(oldOffloadExpression.updateFilter(optimizedExpression, offloadColumns)));
    return new ConnectorPushdownFilterResult(newTableHandle, expressionExtractResult.getRemainingExpression());
}
Also used : ConnectorMetadata(io.prestosql.spi.connector.ConnectorMetadata) HivePartitionManager(io.prestosql.plugin.hive.HivePartitionManager) TableStatistics(io.prestosql.spi.statistics.TableStatistics) HiveTableHandle(io.prestosql.plugin.hive.HiveTableHandle) ConstantExpression(io.prestosql.spi.relation.ConstantExpression) FALSE_CONSTANT(io.prestosql.expressions.LogicalRowExpressions.FALSE_CONSTANT) LogicalRowExpressions(io.prestosql.expressions.LogicalRowExpressions) HiveColumnHandle(io.prestosql.plugin.hive.HiveColumnHandle) NullableValue(io.prestosql.spi.predicate.NullableValue) CallExpression(io.prestosql.spi.relation.CallExpression) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) ConnectorSession(io.prestosql.spi.connector.ConnectorSession) FilterNode(io.prestosql.spi.plan.FilterNode) Map(java.util.Map) FunctionMetadataManager(io.prestosql.spi.function.FunctionMetadataManager) Type(io.prestosql.spi.type.Type) RowExpressionNodeInliner.replaceExpression(io.prestosql.expressions.RowExpressionNodeInliner.replaceExpression) Constraint(io.prestosql.spi.connector.Constraint) BiMap(com.google.common.collect.BiMap) ImmutableSet(com.google.common.collect.ImmutableSet) DomainTranslator(io.prestosql.spi.relation.DomainTranslator) PlanVisitor(io.prestosql.spi.plan.PlanVisitor) TableScanNode(io.prestosql.spi.plan.TableScanNode) Set(java.util.Set) PlanNode(io.prestosql.spi.plan.PlanNode) Collectors(java.util.stream.Collectors) Preconditions.checkState(com.google.common.base.Preconditions.checkState) RowExpressionService(io.prestosql.spi.relation.RowExpressionService) List(java.util.List) ImmutableMap.toImmutableMap(com.google.common.collect.ImmutableMap.toImmutableMap) HiveOffloadExpression(io.prestosql.plugin.hive.HiveOffloadExpression) Optional(java.util.Optional) LogicalRowExpressions.extractConjuncts(io.prestosql.expressions.LogicalRowExpressions.extractConjuncts) TRUE_CONSTANT(io.prestosql.expressions.LogicalRowExpressions.TRUE_CONSTANT) Logger(io.airlift.log.Logger) HiveSessionProperties(io.prestosql.plugin.hive.HiveSessionProperties) StandardFunctionResolution(io.prestosql.spi.function.StandardFunctionResolution) TableHandle(io.prestosql.spi.metadata.TableHandle) Function(java.util.function.Function) ArrayList(java.util.ArrayList) HiveTransactionManager(io.prestosql.plugin.hive.HiveTransactionManager) LinkedHashMap(java.util.LinkedHashMap) ImmutableList(com.google.common.collect.ImmutableList) OmniExpressionChecker(com.huawei.boostkit.omnidata.expression.OmniExpressionChecker) HivePushdownUtil.isColumnsCanOffload(io.prestosql.plugin.hive.rule.HivePushdownUtil.isColumnsCanOffload) Objects.requireNonNull(java.util.Objects.requireNonNull) ConnectorPlanOptimizer(io.prestosql.spi.ConnectorPlanOptimizer) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) HiveMetadata(io.prestosql.plugin.hive.HiveMetadata) Symbol(io.prestosql.spi.plan.Symbol) HivePushdownUtil.checkStorageFormat(io.prestosql.plugin.hive.rule.HivePushdownUtil.checkStorageFormat) FilterStatsCalculatorService(io.prestosql.spi.plan.FilterStatsCalculatorService) ConnectorTableHandle(io.prestosql.spi.connector.ConnectorTableHandle) TupleDomain(io.prestosql.spi.predicate.TupleDomain) VariableReferenceExpression(io.prestosql.spi.relation.VariableReferenceExpression) SymbolAllocator(io.prestosql.spi.SymbolAllocator) ConnectorTableMetadata(io.prestosql.spi.connector.ConnectorTableMetadata) Estimate(io.prestosql.spi.statistics.Estimate) ValuesNode(io.prestosql.spi.plan.ValuesNode) BASIC_COLUMN_EXTRACTOR(io.prestosql.spi.relation.DomainTranslator.BASIC_COLUMN_EXTRACTOR) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) Sets.intersection(com.google.common.collect.Sets.intersection) PlanNodeIdAllocator(io.prestosql.spi.plan.PlanNodeIdAllocator) RowExpression(io.prestosql.spi.relation.RowExpression) ImmutableBiMap.toImmutableBiMap(com.google.common.collect.ImmutableBiMap.toImmutableBiMap) HiveColumnHandle(io.prestosql.plugin.hive.HiveColumnHandle) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) LogicalRowExpressions(io.prestosql.expressions.LogicalRowExpressions) RowExpression(io.prestosql.spi.relation.RowExpression) ConnectorTableHandle(io.prestosql.spi.connector.ConnectorTableHandle) HiveTableHandle(io.prestosql.plugin.hive.HiveTableHandle) HiveOffloadExpression(io.prestosql.plugin.hive.HiveOffloadExpression) HiveColumnHandle(io.prestosql.plugin.hive.HiveColumnHandle)

Aggregations

HiveOffloadExpression (io.prestosql.plugin.hive.HiveOffloadExpression)9 ImmutableList (com.google.common.collect.ImmutableList)3 HiveColumnHandle (io.prestosql.plugin.hive.HiveColumnHandle)3 HiveTableHandle (io.prestosql.plugin.hive.HiveTableHandle)3 ConnectorTableHandle (io.prestosql.spi.connector.ConnectorTableHandle)3 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)2 BiMap (com.google.common.collect.BiMap)2 ImmutableBiMap.toImmutableBiMap (com.google.common.collect.ImmutableBiMap.toImmutableBiMap)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 OmniExpressionChecker (com.huawei.boostkit.omnidata.expression.OmniExpressionChecker)2 AggregationInfo (com.huawei.boostkit.omnidata.model.AggregationInfo)2 TRUE_CONSTANT (io.prestosql.expressions.LogicalRowExpressions.TRUE_CONSTANT)2 RowExpressionNodeInliner.replaceExpression (io.prestosql.expressions.RowExpressionNodeInliner.replaceExpression)2 DUMMY_OFFLOADED (io.prestosql.plugin.hive.HiveColumnHandle.ColumnType.DUMMY_OFFLOADED)2 DUMMY_OFFLOADED_COLUMN_INDEX (io.prestosql.plugin.hive.HiveColumnHandle.DUMMY_OFFLOADED_COLUMN_INDEX)2 ColumnHandle (io.prestosql.spi.connector.ColumnHandle)2 TableHandle (io.prestosql.spi.metadata.TableHandle)2 Symbol (io.prestosql.spi.plan.Symbol)2 TableScanNode (io.prestosql.spi.plan.TableScanNode)2 RowExpression (io.prestosql.spi.relation.RowExpression)2