Search in sources :

Example 1 with EnumerableRel

use of org.apache.calcite.adapter.enumerable.EnumerableRel in project calcite by apache.

the class EnumerableToSparkConverter method implementSpark.

public Result implementSpark(Implementor implementor) {
    // Generate:
    // Enumerable source = ...;
    // return SparkRuntime.createRdd(sparkContext, source);
    final BlockBuilder list = new BlockBuilder();
    final EnumerableRel child = (EnumerableRel) getInput();
    final PhysType physType = PhysTypeImpl.of(implementor.getTypeFactory(), getRowType(), JavaRowFormat.CUSTOM);
    // TODO:
    final Expression source = null;
    final Expression sparkContext = Expressions.call(SparkMethod.GET_SPARK_CONTEXT.method, implementor.getRootExpression());
    final Expression rdd = list.append("rdd", Expressions.call(SparkMethod.CREATE_RDD.method, sparkContext, source));
    list.add(Expressions.return_(null, rdd));
    return implementor.result(physType, list.toBlock());
}
Also used : PhysType(org.apache.calcite.adapter.enumerable.PhysType) Expression(org.apache.calcite.linq4j.tree.Expression) BlockBuilder(org.apache.calcite.linq4j.tree.BlockBuilder) EnumerableRel(org.apache.calcite.adapter.enumerable.EnumerableRel)

Aggregations

EnumerableRel (org.apache.calcite.adapter.enumerable.EnumerableRel)1 PhysType (org.apache.calcite.adapter.enumerable.PhysType)1 BlockBuilder (org.apache.calcite.linq4j.tree.BlockBuilder)1 Expression (org.apache.calcite.linq4j.tree.Expression)1