org.apache.calcite.adapter.enumerable.EnumerableCalc Java Examples

The following examples show how to use org.apache.calcite.adapter.enumerable.EnumerableCalc. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OLAPFilterRel.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@Override
public EnumerableRel implementEnumerable(List<EnumerableRel> inputs) {
    // keep it for having clause
    RexBuilder rexBuilder = getCluster().getRexBuilder();
    RelDataType inputRowType = getInput().getRowType();
    RexProgramBuilder programBuilder = new RexProgramBuilder(inputRowType, rexBuilder);
    programBuilder.addIdentity();
    programBuilder.addCondition(this.condition);
    RexProgram program = programBuilder.getProgram();

    return new EnumerableCalc(getCluster(), getCluster().traitSetOf(EnumerableConvention.INSTANCE), //
            sole(inputs), program);
}
 
Example #2
Source File: OLAPFilterRel.java    From kylin with Apache License 2.0 5 votes vote down vote up
@Override
public EnumerableRel implementEnumerable(List<EnumerableRel> inputs) {
    // keep it for having clause
    RexBuilder rexBuilder = getCluster().getRexBuilder();
    RelDataType inputRowType = getInput().getRowType();
    RexProgramBuilder programBuilder = new RexProgramBuilder(inputRowType, rexBuilder);
    programBuilder.addIdentity();
    programBuilder.addCondition(this.condition);
    RexProgram program = programBuilder.getProgram();

    return new EnumerableCalc(getCluster(), getCluster().traitSetOf(EnumerableConvention.INSTANCE), //
            sole(inputs), program);
}
 
Example #3
Source File: CalcitePrepareImpl.java    From calcite with Apache License 2.0 4 votes vote down vote up
@Override protected PreparedResult implement(RelRoot root) {
  Hook.PLAN_BEFORE_IMPLEMENTATION.run(root);
  RelDataType resultType = root.rel.getRowType();
  boolean isDml = root.kind.belongsTo(SqlKind.DML);
  final Bindable bindable;
  if (resultConvention == BindableConvention.INSTANCE) {
    bindable = Interpreters.bindable(root.rel);
  } else {
    EnumerableRel enumerable = (EnumerableRel) root.rel;
    if (!root.isRefTrivial()) {
      final List<RexNode> projects = new ArrayList<>();
      final RexBuilder rexBuilder = enumerable.getCluster().getRexBuilder();
      for (int field : Pair.left(root.fields)) {
        projects.add(rexBuilder.makeInputRef(enumerable, field));
      }
      RexProgram program = RexProgram.create(enumerable.getRowType(),
          projects, null, root.validatedRowType, rexBuilder);
      enumerable = EnumerableCalc.create(enumerable, program);
    }

    try {
      CatalogReader.THREAD_LOCAL.set(catalogReader);
      final SqlConformance conformance = context.config().conformance();
      internalParameters.put("_conformance", conformance);
      bindable = EnumerableInterpretable.toBindable(internalParameters,
          context.spark(), enumerable, prefer);
    } finally {
      CatalogReader.THREAD_LOCAL.remove();
    }
  }

  if (timingTracer != null) {
    timingTracer.traceTime("end codegen");
  }

  if (timingTracer != null) {
    timingTracer.traceTime("end compilation");
  }

  return new PreparedResultImpl(
      resultType,
      parameterRowType,
      fieldOrigins,
      root.collation.getFieldCollations().isEmpty()
          ? ImmutableList.of()
          : ImmutableList.of(root.collation),
      root.rel,
      mapTableModOp(isDml, root.kind),
      isDml) {
    public String getCode() {
      throw new UnsupportedOperationException();
    }

    public Bindable getBindable(Meta.CursorFactory cursorFactory) {
      return bindable;
    }

    public Type getElementType() {
      return ((Typed) bindable).getElementType();
    }
  };
}
 
Example #4
Source File: RelUtils.java    From sql-gremlin with Apache License 2.0 2 votes vote down vote up
/**
 * Is this a RelNode we can convert into Gremlin?
 * @param node the node to check
 * @return true if a convert operation is supported
 */
public static Boolean isConvertable(RelNode node) {
    return !(node instanceof EnumerableAggregate || node instanceof EnumerableCalc
            || node instanceof EnumerableLimit || node instanceof EnumerableSort);
}