Java Code Examples for org.apache.calcite.rel.core.Calc#getProgram()
The following examples show how to use
org.apache.calcite.rel.core.Calc#getProgram() .
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 |
/** @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 |
/** * @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 |
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 |
/** @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: RelMdUniqueKeys.java From calcite with Apache License 2.0 | 5 votes |
public Set<ImmutableBitSet> getUniqueKeys(Calc rel, RelMetadataQuery mq, boolean ignoreNulls) { RexProgram program = rel.getProgram(); Permutation permutation = program.getPermutation(); return getProjectUniqueKeys(rel, mq, ignoreNulls, Lists.transform(program.getProjectList(), program::expandLocalRef)); }
Example 6
Source File: RelMdSelectivity.java From calcite with Apache License 2.0 | 5 votes |
public Double getSelectivity(Calc rel, RelMetadataQuery mq, RexNode predicate) { final RexProgram rexProgram = rel.getProgram(); final RexLocalRef programCondition = rexProgram.getCondition(); if (programCondition == null) { return getSelectivity(rel.getInput(), mq, predicate); } else { return mq.getSelectivity(rel.getInput(), RelMdUtil.minusPreds( rel.getCluster().getRexBuilder(), predicate, rexProgram.expandLocalRef(programCondition))); } }
Example 7
Source File: RelMdColumnUniqueness.java From calcite with Apache License 2.0 | 5 votes |
public Boolean areColumnsUnique(Calc rel, RelMetadataQuery mq, ImmutableBitSet columns, boolean ignoreNulls) { columns = decorateWithConstantColumnsFromPredicates(columns, rel, mq); RexProgram program = rel.getProgram(); return areProjectColumnsUnique(rel, mq, columns, ignoreNulls, Lists.transform(program.getProjectList(), program::expandLocalRef)); }
Example 8
Source File: JdbcRules.java From calcite with Apache License 2.0 | 5 votes |
public RelNode convert(RelNode rel) { final Calc calc = (Calc) rel; // If there's a multiset, let FarragoMultisetSplitter work on it // first. if (RexMultisetUtil.containsMultiset(calc.getProgram())) { return null; } return new JdbcCalc(rel.getCluster(), rel.getTraitSet().replace(out), convert(calc.getInput(), calc.getTraitSet().replace(out)), calc.getProgram()); }