Search in sources :

Example 1 with TableScanNode

use of org.apache.ignite.internal.sql.engine.exec.rel.TableScanNode in project ignite-3 by apache.

the class LogicalRelImplementor method visit.

/**
 * {@inheritDoc}
 */
@Override
public Node<RowT> visit(IgniteTableScan rel) {
    RexNode condition = rel.condition();
    List<RexNode> projects = rel.projects();
    ImmutableBitSet requiredColumns = rel.requiredColumns();
    InternalIgniteTable tbl = rel.getTable().unwrap(InternalIgniteTable.class);
    assert tbl != null;
    IgniteTypeFactory typeFactory = ctx.getTypeFactory();
    RelDataType rowType = tbl.getRowType(typeFactory, requiredColumns);
    Predicate<RowT> filters = condition == null ? null : expressionFactory.predicate(condition, rowType);
    Function<RowT, RowT> prj = projects == null ? null : expressionFactory.project(projects, rowType);
    ColocationGroup group = ctx.group(rel.sourceId());
    if (!group.nodeIds().contains(ctx.localNodeId())) {
        return new ScanNode<>(ctx, rowType, Collections.emptyList());
    }
    return new TableScanNode<>(ctx, rowType, tbl, group.partitions(ctx.localNodeId()), filters, prj, requiredColumns);
}
Also used : ColocationGroup(org.apache.ignite.internal.sql.engine.metadata.ColocationGroup) ImmutableBitSet(org.apache.calcite.util.ImmutableBitSet) InternalIgniteTable(org.apache.ignite.internal.sql.engine.schema.InternalIgniteTable) TableScanNode(org.apache.ignite.internal.sql.engine.exec.rel.TableScanNode) IgniteTypeFactory(org.apache.ignite.internal.sql.engine.type.IgniteTypeFactory) RelDataType(org.apache.calcite.rel.type.RelDataType) ScanNode(org.apache.ignite.internal.sql.engine.exec.rel.ScanNode) TableScanNode(org.apache.ignite.internal.sql.engine.exec.rel.TableScanNode) RexNode(org.apache.calcite.rex.RexNode)

Aggregations

RelDataType (org.apache.calcite.rel.type.RelDataType)1 RexNode (org.apache.calcite.rex.RexNode)1 ImmutableBitSet (org.apache.calcite.util.ImmutableBitSet)1 ScanNode (org.apache.ignite.internal.sql.engine.exec.rel.ScanNode)1 TableScanNode (org.apache.ignite.internal.sql.engine.exec.rel.TableScanNode)1 ColocationGroup (org.apache.ignite.internal.sql.engine.metadata.ColocationGroup)1 InternalIgniteTable (org.apache.ignite.internal.sql.engine.schema.InternalIgniteTable)1 IgniteTypeFactory (org.apache.ignite.internal.sql.engine.type.IgniteTypeFactory)1