本文整理汇总了Java中org.apache.calcite.rex.RexProgram.getCondition方法的典型用法代码示例。如果您正苦于以下问题:Java RexProgram.getCondition方法的具体用法?Java RexProgram.getCondition怎么用?Java RexProgram.getCondition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.rex.RexProgram
的用法示例。
在下文中一共展示了RexProgram.getCondition方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitCalc
import org.apache.calcite.rex.RexProgram; //导入方法依赖的package包/类
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();
}
示例2: visit
import org.apache.calcite.rex.RexProgram; //导入方法依赖的package包/类
/** @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();
}
示例3: translateCondition
import org.apache.calcite.rex.RexProgram; //导入方法依赖的package包/类
public static Expression translateCondition(
RexProgram program,
JavaTypeFactory typeFactory,
BlockBuilder list,
InputGetter inputGetter,
Function1<String, InputGetter> correlates) {
if (program.getCondition() == null) {
return RexImpTable.TRUE_EXPR;
}
final ParameterExpression root = DataContext.ROOT;
RexToLixTranslator translator =
new RexToLixTranslator(program, typeFactory, root, inputGetter, list);
translator = translator.setCorrelates(correlates);
return translator.translate(
program.getCondition(),
RexImpTable.NullAs.FALSE);
}
示例4: estimateFilteredRows
import org.apache.calcite.rex.RexProgram; //导入方法依赖的package包/类
public static double estimateFilteredRows(RelNode child, RexProgram program,
RelMetadataQuery mq) {
// convert the program's RexLocalRef condition to an expanded RexNode
RexLocalRef programCondition = program.getCondition();
RexNode condition;
if (programCondition == null) {
condition = null;
} else {
condition = program.expandLocalRef(programCondition);
}
return estimateFilteredRows(child, condition, mq);
}
示例5: canImplement
import org.apache.calcite.rex.RexProgram; //导入方法依赖的package包/类
/**
* Returns whether this tester's <code>RelType</code> can implement a
* given program.
*
* @param program Program
* @return Whether this tester's <code>RelType</code> can implement a
* given program.
*/
public boolean canImplement(RexProgram program) {
if ((program.getCondition() != null)
&& !canImplement(program.getCondition(), true)) {
return false;
}
for (RexNode expr : program.getExprList()) {
if (!canImplement(expr, false)) {
return false;
}
}
return true;
}
示例6: rewriteRel
import org.apache.calcite.rex.RexProgram; //导入方法依赖的package包/类
public void rewriteRel(LogicalCalc rel) {
// Translate the child.
final RelNode newInput = getNewForOldRel(rel.getInput());
final RelOptCluster cluster = rel.getCluster();
RexProgramBuilder programBuilder =
new RexProgramBuilder(
newInput.getRowType(),
cluster.getRexBuilder());
// Convert the common expressions.
final RexProgram program = rel.getProgram();
final RewriteRexShuttle shuttle = new RewriteRexShuttle();
for (RexNode expr : program.getExprList()) {
programBuilder.registerInput(expr.accept(shuttle));
}
// Convert the projections.
final List<Pair<RexNode, String>> flattenedExpList = Lists.newArrayList();
List<String> fieldNames = rel.getRowType().getFieldNames();
flattenProjections(new RewriteRexShuttle(),
program.getProjectList(),
fieldNames,
"",
flattenedExpList);
// Register each of the new projections.
for (Pair<RexNode, String> flattenedExp : flattenedExpList) {
programBuilder.addProject(flattenedExp.left, flattenedExp.right);
}
// Translate the condition.
final RexLocalRef conditionRef = program.getCondition();
if (conditionRef != null) {
programBuilder.addCondition(
new RexLocalRef(
getNewForOldInput(conditionRef.getIndex()),
conditionRef.getType()));
}
RexProgram newProgram = programBuilder.getProgram();
// Create a new calc relational expression.
LogicalCalc newRel = LogicalCalc.create(newInput, newProgram);
setNewForOldRel(rel, newRel);
}