Java Code Examples for org.apache.calcite.rex.RexProgram#getProjectList()

The following examples show how to use org.apache.calcite.rex.RexProgram#getProjectList() . 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: RelToSqlConverter.java    From Bats with Apache License 2.0 6 votes vote down vote up
/** @see #dispatch */
public Result visit(Calc e) {
  Result x = visitChild(0, e.getInput());
  parseCorrelTable(e, x);
  final RexProgram program = e.getProgram();
  Builder builder =
      program.getCondition() != null
          ? x.builder(e, Clause.WHERE)
          : x.builder(e);
  if (!isStar(program)) {
    final List<SqlNode> selectList = new ArrayList<>();
    for (RexLocalRef ref : program.getProjectList()) {
      SqlNode sqlExpr = builder.context.toSql(program, ref);
      addSelect(selectList, sqlExpr, e.getRowType());
    }
    builder.setSelect(new SqlNodeList(selectList, POS));
  }

  if (program.getCondition() != null) {
    builder.setWhere(
        builder.context.toSql(program, program.getCondition()));
  }
  return builder.result();
}
 
Example 2
Source File: RelToSqlConverter.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
/**
 * @see #dispatch
 */
public Result visit(Calc e) {
  Result x = visitChild(0, e.getInput());
  parseCorrelTable(e, x);
  final RexProgram program = e.getProgram();
  Builder builder =
    program.getCondition() != null
      ? x.builder(e, Clause.WHERE)
      : x.builder(e);
  if (!isStar(program)) {
    final List<SqlNode> selectList = new ArrayList<>();
    for (RexLocalRef ref : program.getProjectList()) {
      SqlNode sqlExpr = builder.context.toSql(program, ref);
      addSelect(selectList, sqlExpr, e.getRowType());
    }
    builder.setSelect(new SqlNodeList(selectList, POS));
  }

  if (program.getCondition() != null) {
    builder.setWhere(
      builder.context.toSql(program, program.getCondition()));
  }
  return builder.result();
}
 
Example 3
Source File: RelToSqlConverter.java    From quark with Apache License 2.0 6 votes vote down vote up
public Result visitCalc(Calc e) {
  Result x = visitChild(0, e.getInput());
  final RexProgram program = e.getProgram();
  Builder builder =
      program.getCondition() != null
          ? x.builder(e, Clause.WHERE)
          : x.builder(e);
  if (!isStar(program)) {
    final List<SqlNode> selectList = new ArrayList<>();
    for (RexLocalRef ref : program.getProjectList()) {
      SqlNode sqlExpr = builder.context.toSql(program, ref);
      addSelect(selectList, sqlExpr, e.getRowType());
    }
    builder.setSelect(new SqlNodeList(selectList, POS));
  }

  if (program.getCondition() != null) {
    builder.setWhere(
        builder.context.toSql(program, program.getCondition()));
  }
  return builder.result();
}
 
Example 4
Source File: RelToSqlConverter.java    From calcite with Apache License 2.0 6 votes vote down vote up
/** @see #dispatch */
public Result visit(Calc e) {
  Result x = visitChild(0, e.getInput());
  parseCorrelTable(e, x);
  final RexProgram program = e.getProgram();
  Builder builder =
      program.getCondition() != null
          ? x.builder(e, Clause.WHERE)
          : x.builder(e);
  if (!isStar(program)) {
    final List<SqlNode> selectList = new ArrayList<>(program.getProjectList().size());
    for (RexLocalRef ref : program.getProjectList()) {
      SqlNode sqlExpr = builder.context.toSql(program, ref);
      addSelect(selectList, sqlExpr, e.getRowType());
    }
    builder.setSelect(new SqlNodeList(selectList, POS));
  }

  if (program.getCondition() != null) {
    builder.setWhere(
        builder.context.toSql(program, program.getCondition()));
  }
  return builder.result();
}
 
Example 5
Source File: SqlImplementor.java    From Bats with Apache License 2.0 5 votes vote down vote up
public static boolean isStar(RexProgram program) {
    int i = 0;
    for (RexLocalRef ref : program.getProjectList()) {
        if (ref.getIndex() != i++) {
            return false;
        }
    }
    return i == program.getInputRowType().getFieldCount();
}
 
Example 6
Source File: SqlImplementor.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
public static boolean isStar(RexProgram program) {
  int i = 0;
  for (RexLocalRef ref : program.getProjectList()) {
    if (ref.getIndex() != i++) {
      return false;
    }
  }
  return i == program.getInputRowType().getFieldCount();
}
 
Example 7
Source File: JoinCalcTransposeRule.java    From quark with Apache License 2.0 5 votes vote down vote up
private static boolean isStar(RexProgram program) {
  int i = 0;

  for (RexLocalRef ref : program.getProjectList()) {
    if (ref.getIndex() != i++) {
      return false;
    }
  }
  return i == program.getInputRowType().getFieldCount();
}
 
Example 8
Source File: RelToSqlConverter.java    From quark with Apache License 2.0 5 votes vote down vote up
private static boolean isStar(RexProgram program) {
  int i = 0;

  for (RexLocalRef ref : program.getProjectList()) {
    if (ref.getIndex() != i++) {
      return false;
    }
  }
  return i == program.getInputRowType().getFieldCount();
}
 
Example 9
Source File: SqlImplementor.java    From calcite with Apache License 2.0 5 votes vote down vote up
public static boolean isStar(RexProgram program) {
  int i = 0;
  for (RexLocalRef ref : program.getProjectList()) {
    if (ref.getIndex() != i++) {
      return false;
    }
  }
  return i == program.getInputRowType().getFieldCount();
}