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());
}
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);
}
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());
}
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());
}
Aggregations