public Result implement(EnumerableRelImplementor implementor, Prefer pref) {
    logger.debug("implementing enumerable");

    final DrillImplementor drillImplementor = new DrillImplementor(this.client == null);
    DrillRel input = (DrillRel) getChild();

    drillImplementor.go(input);
    String plan = drillImplementor.getJsonString();
    Hook.LOGICAL_PLAN.run(plan);

    // not quite sure where this list was supposed to be set earlier, leaving it null got me back
    // the full result set

    final List<String> fieldNameList = rowType.getFieldNames();
    // final List<String> fieldNameList = null;
    BlockStatement expr =
        new BlockBuilder()
            .append(
                Expressions.call(
                    OF_METHOD,
                    Expressions.constant(plan), //
                    Expressions.call(
                        Arrays.class,
                        "asList", //
                        Expressions.newArrayInit(
                            String.class, Functions.apply(fieldNameList, TO_LITERAL)) //
                        ),
                    Expressions.constant(Object.class), //
                    Expressions.variable(DataContext.class, "root")))
            .toBlock();
    final PhysType physType =
        PhysTypeImpl.of(
            implementor.getTypeFactory(), getRowType(), pref.prefer(JavaRowFormat.ARRAY));
    return new Result(expr, physType, JavaRowFormat.ARRAY);
  }
Ejemplo n.º 2
0
 @Override
 public LogicalOperator implement(DrillImplementor implementor) {
   LogicalOperator inputOp = implementor.visitChild(this, 0, getChild());
   Project.Builder builder = Project.builder();
   builder.setInput(inputOp);
   for (NamedExpression e : this.getProjectExpressions(implementor.getContext())) {
     builder.addExpr(e);
   }
   return builder.build();
 }
Ejemplo n.º 3
0
 @Override
 public LogicalOperator implement(DrillImplementor implementor) {
   Scan.Builder builder = Scan.builder();
   builder.storageEngine(drillTable.getStorageEngineName());
   builder.selection(new JSONOptions(drillTable.getSelection()));
   implementor.registerSource(drillTable);
   return builder.build();
 }