Search in sources :

Example 1 with ScanNode

use of org.apache.ignite.internal.sql.engine.exec.rel.ScanNode 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)

Example 2 with ScanNode

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

the class LogicalRelImplementor method visit.

/**
 * {@inheritDoc}
 */
@Override
public Node<RowT> visit(IgniteIndexScan rel) {
    // TODO: fix this
    // RexNode condition = rel.condition();
    // List<RexNode> projects = rel.projects();
    InternalIgniteTable tbl = rel.getTable().unwrap(InternalIgniteTable.class);
    IgniteTypeFactory typeFactory = ctx.getTypeFactory();
    ImmutableBitSet requiredColumns = rel.requiredColumns();
    // List<RexNode> lowerCond = rel.lowerBound();
    // List<RexNode> upperCond = rel.upperBound();
    RelDataType rowType = tbl.getRowType(typeFactory, requiredColumns);
    // Predicate<Row> filters = condition == null ? null : expressionFactory.predicate(condition, rowType);
    // Supplier<Row> lower = lowerCond == null ? null : expressionFactory.rowSource(lowerCond);
    // Supplier<Row> upper = upperCond == null ? null : expressionFactory.rowSource(upperCond);
    // Function<Row, Row> prj = projects == null ? null : expressionFactory.project(projects, rowType);
    // 
    // IgniteIndex idx = tbl.getIndex(rel.indexName());
    // 
    // ColocationGroup group = ctx.group(rel.sourceId());
    Iterable<RowT> rowsIter = (Iterable<RowT>) List.of(new Object[] { 0, 0 }, // idx.scan(ctx, group, filters, lower, upper, prj, requiredColumns);
    new Object[] { 1, 1 });
    return new ScanNode<>(ctx, rowType, rowsIter);
}
Also used : InternalIgniteTable(org.apache.ignite.internal.sql.engine.schema.InternalIgniteTable) ImmutableBitSet(org.apache.calcite.util.ImmutableBitSet) 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)

Example 3 with ScanNode

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

the class LogicalRelImplementor method visit.

/**
 * {@inheritDoc}
 */
@Override
public Node<RowT> visit(IgniteValues rel) {
    List<RexLiteral> vals = Commons.flat(Commons.cast(rel.getTuples()));
    RelDataType rowType = rel.getRowType();
    return new ScanNode<>(ctx, rowType, expressionFactory.values(vals, rowType));
}
Also used : RexLiteral(org.apache.calcite.rex.RexLiteral) 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)

Example 4 with ScanNode

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

the class LogicalRelImplementor method visit.

/**
 * {@inheritDoc}
 */
@Override
public Node<RowT> visit(IgniteTableFunctionScan rel) {
    Supplier<Iterable<Object[]>> dataSupplier = expressionFactory.execute(rel.getCall());
    RelDataType rowType = rel.getRowType();
    RowFactory<RowT> rowFactory = ctx.rowHandler().factory(ctx.getTypeFactory(), rowType);
    return new ScanNode<>(ctx, rowType, new TableFunctionScan<>(dataSupplier, rowFactory));
}
Also used : 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)

Aggregations

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