use of io.prestosql.sql.planner.plan.IndexSourceNode in project hetu-core by openlookeng.
the class PruneIndexSourceColumns method pushDownProjectOff.
@Override
protected Optional<PlanNode> pushDownProjectOff(PlanNodeIdAllocator idAllocator, IndexSourceNode indexSourceNode, Set<Symbol> referencedOutputs) {
Set<Symbol> prunedLookupSymbols = indexSourceNode.getLookupSymbols().stream().filter(referencedOutputs::contains).collect(toImmutableSet());
Map<Symbol, ColumnHandle> prunedAssignments = Maps.filterEntries(indexSourceNode.getAssignments(), entry -> referencedOutputs.contains(entry.getKey()) || tupleDomainReferencesColumnHandle(indexSourceNode.getCurrentConstraint(), entry.getValue()));
List<Symbol> prunedOutputList = indexSourceNode.getOutputSymbols().stream().filter(referencedOutputs::contains).collect(toImmutableList());
return Optional.of(new IndexSourceNode(indexSourceNode.getId(), indexSourceNode.getIndexHandle(), indexSourceNode.getTableHandle(), prunedLookupSymbols, prunedOutputList, prunedAssignments, indexSourceNode.getCurrentConstraint()));
}
use of io.prestosql.sql.planner.plan.IndexSourceNode in project hetu-core by openlookeng.
the class IndexSourceMatcher 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());
IndexSourceNode indexSourceNode = (IndexSourceNode) node;
TableMetadata tableMetadata = metadata.getTableMetadata(session, indexSourceNode.getTableHandle());
String actualTableName = tableMetadata.getTable().getTableName();
if (!expectedTableName.equalsIgnoreCase(actualTableName)) {
return NO_MATCH;
}
if (expectedConstraint.isPresent() && !domainsMatch(expectedConstraint, indexSourceNode.getCurrentConstraint(), indexSourceNode.getTableHandle(), session, metadata)) {
return NO_MATCH;
}
return match();
}
use of io.prestosql.sql.planner.plan.IndexSourceNode in project hetu-core by openlookeng.
the class ColumnReference method getAssignedSymbol.
@Override
public Optional<Symbol> getAssignedSymbol(PlanNode node, Session session, Metadata metadata, SymbolAliases symbolAliases) {
TableHandle tableHandle;
Map<Symbol, ColumnHandle> assignments;
if (node instanceof TableScanNode) {
TableScanNode tableScanNode = (TableScanNode) node;
tableHandle = tableScanNode.getTable();
assignments = tableScanNode.getAssignments();
} else if (node instanceof IndexSourceNode) {
IndexSourceNode indexSourceNode = (IndexSourceNode) node;
tableHandle = indexSourceNode.getTableHandle();
assignments = indexSourceNode.getAssignments();
} else {
return Optional.empty();
}
TableMetadata tableMetadata = metadata.getTableMetadata(session, tableHandle);
String actualTableName = tableMetadata.getTable().getTableName();
// Wrong table -> doesn't match.
if (!tableName.equalsIgnoreCase(actualTableName)) {
return Optional.empty();
}
Optional<ColumnHandle> columnHandle = getColumnHandle(tableHandle, session, metadata);
checkState(columnHandle.isPresent(), "Table %s doesn't have column %s. Typo in test?", tableName, columnName);
return getAssignedSymbol(assignments, columnHandle.get());
}
Aggregations