use of io.prestosql.cost.StatsProvider in project hetu-core by openlookeng.
the class MarkDistinctMatcher method detailMatches.
@Override
public MatchResult detailMatches(PlanNode node, StatsProvider stats, Session session, Metadata metadata, SymbolAliases symbolAliases) {
checkState(shapeMatches(node), "Plan testing framework error: shapeMatches returned false in detailMatches in %s", this.getClass().getName());
MarkDistinctNode markDistinctNode = (MarkDistinctNode) node;
if (!markDistinctNode.getHashSymbol().equals(hashSymbol.map(alias -> alias.toSymbol(symbolAliases)))) {
return NO_MATCH;
}
if (!ImmutableSet.copyOf(markDistinctNode.getDistinctSymbols()).equals(distinctSymbols.stream().map(alias -> alias.toSymbol(symbolAliases)).collect(toImmutableSet()))) {
return NO_MATCH;
}
return match(markerSymbol.toString(), toSymbolReference(markDistinctNode.getMarkerSymbol()));
}
use of io.prestosql.cost.StatsProvider in project hetu-core by openlookeng.
the class RowNumberMatcher method detailMatches.
@Override
public MatchResult detailMatches(PlanNode node, StatsProvider stats, Session session, Metadata metadata, SymbolAliases symbolAliases) {
checkState(shapeMatches(node), "Plan testing framework error: shapeMatches returned false in detailMatches in %s", this.getClass().getName());
RowNumberNode rowNumberNode = (RowNumberNode) node;
if (partitionBy.isPresent()) {
List<Symbol> expected = partitionBy.get().stream().map(alias -> alias.toSymbol(symbolAliases)).collect(toImmutableList());
if (!expected.equals(rowNumberNode.getPartitionBy())) {
return NO_MATCH;
}
}
if (rowNumberSymbol.isPresent()) {
Symbol expected = rowNumberSymbol.get().toSymbol(symbolAliases);
if (!expected.equals(rowNumberNode.getRowNumberSymbol())) {
return NO_MATCH;
}
}
if (maxRowCountPerPartition.isPresent()) {
if (!maxRowCountPerPartition.get().equals(rowNumberNode.getMaxRowCountPerPartition())) {
return NO_MATCH;
}
}
if (hashSymbol.isPresent()) {
Optional<Symbol> expected = hashSymbol.get().map(alias -> alias.toSymbol(symbolAliases));
if (!expected.equals(rowNumberNode.getHashSymbol())) {
return NO_MATCH;
}
}
return match();
}
use of io.prestosql.cost.StatsProvider in project hetu-core by openlookeng.
the class SemiJoinMatcher method detailMatches.
@Override
public MatchResult detailMatches(PlanNode node, StatsProvider stats, Session session, Metadata metadata, SymbolAliases symbolAliases) {
checkState(shapeMatches(node), "Plan testing framework error: shapeMatches returned false in detailMatches in %s", this.getClass().getName());
SemiJoinNode semiJoinNode = (SemiJoinNode) node;
if (!(symbolAliases.get(sourceSymbolAlias).equals(toSymbolReference(semiJoinNode.getSourceJoinSymbol())) && symbolAliases.get(filteringSymbolAlias).equals(toSymbolReference(semiJoinNode.getFilteringSourceJoinSymbol())))) {
return NO_MATCH;
}
if (distributionType.isPresent() && !distributionType.equals(semiJoinNode.getDistributionType())) {
return NO_MATCH;
}
if (hasDynamicFilter.isPresent()) {
if (hasDynamicFilter.get()) {
if (!semiJoinNode.getDynamicFilterId().isPresent()) {
return NO_MATCH;
}
String dynamicFilterId = semiJoinNode.getDynamicFilterId().get();
List<DynamicFilters.Descriptor> matchingDescriptors = searchFrom(semiJoinNode.getSource()).where(FilterNode.class::isInstance).findAll().stream().flatMap(filterNode -> extractExpressions(filterNode).stream()).flatMap(expression -> extractDynamicFilters(expression).getDynamicConjuncts().stream()).filter(descriptor -> descriptor.getId().equals(dynamicFilterId)).collect(toImmutableList());
boolean sourceSymbolsMatch = matchingDescriptors.stream().map(descriptor -> new Symbol(((VariableReferenceExpression) descriptor.getInput()).getName())).allMatch(sourceSymbol -> symbolAliases.get(sourceSymbolAlias).equals(toSymbolReference(sourceSymbol)));
if (!matchingDescriptors.isEmpty() && sourceSymbolsMatch) {
return match(outputAlias, toSymbolReference(semiJoinNode.getSemiJoinOutput()));
}
return NO_MATCH;
}
if (semiJoinNode.getDynamicFilterId().isPresent()) {
return NO_MATCH;
}
}
return match(outputAlias, toSymbolReference(semiJoinNode.getSemiJoinOutput()));
}
use of io.prestosql.cost.StatsProvider in project hetu-core by openlookeng.
the class TableWriterMatcher method detailMatches.
@Override
public MatchResult detailMatches(PlanNode node, StatsProvider stats, Session session, Metadata metadata, SymbolAliases symbolAliases) {
checkState(shapeMatches(node), "Plan testing framework error: shapeMatches returned false in detailMatches in %s", this.getClass().getName());
TableWriterNode tableWriterNode = (TableWriterNode) node;
if (!tableWriterNode.getColumnNames().equals(columnNames)) {
return NO_MATCH;
}
if (!columns.stream().map(s -> SymbolUtils.from(symbolAliases.get(s))).collect(toImmutableList()).equals(tableWriterNode.getColumns())) {
return NO_MATCH;
}
return match();
}
use of io.prestosql.cost.StatsProvider in project hetu-core by openlookeng.
the class PlanAssert method assertPlan.
public static void assertPlan(Session session, Metadata metadata, StatsCalculator statsCalculator, Plan actual, Lookup lookup, PlanMatchPattern pattern) {
StatsProvider statsProvider = new CachingStatsProvider(statsCalculator, session, actual.getTypes());
assertPlan(session, metadata, statsProvider, actual, lookup, pattern);
}
Aggregations