Search in sources :

Example 1 with LogicalMatch

use of org.apache.calcite.rel.logical.LogicalMatch in project coral by linkedin.

the class IRRelToSparkRelTransformer method transform.

/**
 * This API is used to transforms IR RelNode to make it compatible with spark.
 *
 * @return [[SparkRelInfo]] containing the Spark RelNode and list of standard UDFs.
 */
static SparkRelInfo transform(RelNode calciteNode) {
    Set<SparkUDFInfo> sparkUDFInfos = new HashSet<>();
    RelShuttle converter = new RelShuttleImpl() {

        @Override
        public RelNode visit(LogicalProject project) {
            return super.visit(project).accept(getSparkRexConverter(project));
        }

        @Override
        public RelNode visit(LogicalFilter inputFilter) {
            return super.visit(inputFilter).accept(getSparkRexConverter(inputFilter));
        }

        @Override
        public RelNode visit(LogicalAggregate aggregate) {
            return super.visit(aggregate).accept(getSparkRexConverter(aggregate));
        }

        @Override
        public RelNode visit(LogicalMatch match) {
            return super.visit(match).accept(getSparkRexConverter(match));
        }

        @Override
        public RelNode visit(TableScan scan) {
            return super.visit(scan).accept(getSparkRexConverter(scan));
        }

        @Override
        public RelNode visit(TableFunctionScan scan) {
            return super.visit(scan).accept(getSparkRexConverter(scan));
        }

        @Override
        public RelNode visit(LogicalValues values) {
            return super.visit(values).accept(getSparkRexConverter(values));
        }

        @Override
        public RelNode visit(LogicalJoin join) {
            return super.visit(join).accept(getSparkRexConverter(join));
        }

        @Override
        public RelNode visit(LogicalCorrelate correlate) {
            return super.visit(correlate).accept(getSparkRexConverter(correlate));
        }

        @Override
        public RelNode visit(LogicalUnion union) {
            return super.visit(union).accept(getSparkRexConverter(union));
        }

        @Override
        public RelNode visit(LogicalIntersect intersect) {
            return super.visit(intersect).accept(getSparkRexConverter(intersect));
        }

        @Override
        public RelNode visit(LogicalMinus minus) {
            return super.visit(minus).accept(getSparkRexConverter(minus));
        }

        @Override
        public RelNode visit(LogicalSort sort) {
            return super.visit(sort).accept(getSparkRexConverter(sort));
        }

        @Override
        public RelNode visit(LogicalExchange exchange) {
            return super.visit(exchange).accept(getSparkRexConverter(exchange));
        }

        @Override
        public RelNode visit(RelNode other) {
            return super.visit(other).accept(getSparkRexConverter(other));
        }

        private SparkRexConverter getSparkRexConverter(RelNode node) {
            return new SparkRexConverter(node.getCluster().getRexBuilder(), sparkUDFInfos);
        }
    };
    return new SparkRelInfo(calciteNode.accept(converter), new ArrayList<>(sparkUDFInfos));
}
Also used : TableScan(org.apache.calcite.rel.core.TableScan) SparkUDFInfo(com.linkedin.coral.spark.containers.SparkUDFInfo) LogicalUnion(org.apache.calcite.rel.logical.LogicalUnion) LogicalFilter(org.apache.calcite.rel.logical.LogicalFilter) LogicalMinus(org.apache.calcite.rel.logical.LogicalMinus) RelShuttle(org.apache.calcite.rel.RelShuttle) RelShuttleImpl(org.apache.calcite.rel.RelShuttleImpl) LogicalCorrelate(org.apache.calcite.rel.logical.LogicalCorrelate) LogicalSort(org.apache.calcite.rel.logical.LogicalSort) LogicalValues(org.apache.calcite.rel.logical.LogicalValues) LogicalAggregate(org.apache.calcite.rel.logical.LogicalAggregate) TableFunctionScan(org.apache.calcite.rel.core.TableFunctionScan) RelNode(org.apache.calcite.rel.RelNode) SparkRelInfo(com.linkedin.coral.spark.containers.SparkRelInfo) LogicalJoin(org.apache.calcite.rel.logical.LogicalJoin) LogicalExchange(org.apache.calcite.rel.logical.LogicalExchange) LogicalMatch(org.apache.calcite.rel.logical.LogicalMatch) LogicalIntersect(org.apache.calcite.rel.logical.LogicalIntersect) LogicalProject(org.apache.calcite.rel.logical.LogicalProject) HashSet(java.util.HashSet)

Example 2 with LogicalMatch

use of org.apache.calcite.rel.logical.LogicalMatch in project calcite by apache.

the class MatchRule method onMatch.

// ~ Methods ----------------------------------------------------------------
@Override
public void onMatch(RelOptRuleCall call) {
    final LogicalMatch oldRel = call.rel(0);
    final RelNode match = LogicalMatch.create(oldRel.getCluster(), oldRel.getTraitSet(), oldRel.getInput(), oldRel.getRowType(), oldRel.getPattern(), oldRel.isStrictStart(), oldRel.isStrictEnd(), oldRel.getPatternDefinitions(), oldRel.getMeasures(), oldRel.getAfter(), oldRel.getSubsets(), oldRel.isAllRows(), oldRel.getPartitionKeys(), oldRel.getOrderKeys(), oldRel.getInterval());
    call.transformTo(match);
}
Also used : RelNode(org.apache.calcite.rel.RelNode) LogicalMatch(org.apache.calcite.rel.logical.LogicalMatch)

Aggregations

RelNode (org.apache.calcite.rel.RelNode)2 LogicalMatch (org.apache.calcite.rel.logical.LogicalMatch)2 SparkRelInfo (com.linkedin.coral.spark.containers.SparkRelInfo)1 SparkUDFInfo (com.linkedin.coral.spark.containers.SparkUDFInfo)1 HashSet (java.util.HashSet)1 RelShuttle (org.apache.calcite.rel.RelShuttle)1 RelShuttleImpl (org.apache.calcite.rel.RelShuttleImpl)1 TableFunctionScan (org.apache.calcite.rel.core.TableFunctionScan)1 TableScan (org.apache.calcite.rel.core.TableScan)1 LogicalAggregate (org.apache.calcite.rel.logical.LogicalAggregate)1 LogicalCorrelate (org.apache.calcite.rel.logical.LogicalCorrelate)1 LogicalExchange (org.apache.calcite.rel.logical.LogicalExchange)1 LogicalFilter (org.apache.calcite.rel.logical.LogicalFilter)1 LogicalIntersect (org.apache.calcite.rel.logical.LogicalIntersect)1 LogicalJoin (org.apache.calcite.rel.logical.LogicalJoin)1 LogicalMinus (org.apache.calcite.rel.logical.LogicalMinus)1 LogicalProject (org.apache.calcite.rel.logical.LogicalProject)1 LogicalSort (org.apache.calcite.rel.logical.LogicalSort)1 LogicalUnion (org.apache.calcite.rel.logical.LogicalUnion)1 LogicalValues (org.apache.calcite.rel.logical.LogicalValues)1