use of io.trino.sql.planner.plan.IndexSourceNode in project trino by trinodb.
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());
}
use of io.trino.sql.planner.plan.IndexSourceNode in project trino by trinodb.
the class PruneIndexSourceColumns method pushDownProjectOff.
@Override
protected Optional<PlanNode> pushDownProjectOff(Context context, 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()));
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));
}
use of io.trino.sql.planner.plan.IndexSourceNode in project trino by trinodb.
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;
}
return match();
}
Aggregations