Search in sources :

Example 1 with IndexSourceNode

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()));
}
Also used : ColumnHandle(io.prestosql.spi.connector.ColumnHandle) Symbol(io.prestosql.spi.plan.Symbol) IndexSourceNode(io.prestosql.sql.planner.plan.IndexSourceNode)

Example 2 with IndexSourceNode

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();
}
Also used : TableMetadata(io.prestosql.metadata.TableMetadata) IndexSourceNode(io.prestosql.sql.planner.plan.IndexSourceNode)

Example 3 with IndexSourceNode

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());
}
Also used : TableMetadata(io.prestosql.metadata.TableMetadata) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) TableScanNode(io.prestosql.spi.plan.TableScanNode) Symbol(io.prestosql.spi.plan.Symbol) IndexSourceNode(io.prestosql.sql.planner.plan.IndexSourceNode) TableHandle(io.prestosql.spi.metadata.TableHandle)

Aggregations

IndexSourceNode (io.prestosql.sql.planner.plan.IndexSourceNode)3 TableMetadata (io.prestosql.metadata.TableMetadata)2 ColumnHandle (io.prestosql.spi.connector.ColumnHandle)2 Symbol (io.prestosql.spi.plan.Symbol)2 TableHandle (io.prestosql.spi.metadata.TableHandle)1 TableScanNode (io.prestosql.spi.plan.TableScanNode)1