Tabnine Logo
RexProgram.getCondition
Code IndexAdd Tabnine to your IDE (free)

How to use
getCondition
method
in
org.apache.calcite.rex.RexProgram

Best Java code snippets using org.apache.calcite.rex.RexProgram.getCondition (Showing top 20 results out of 315)

origin: apache/storm

RexLocalRef condition = program.getCondition();
if (condition != null) {
  RexNode conditionNode = program.expandLocalRef(condition);
origin: Qihoo360/Quicksql

/**
 * Returns whether this program returns its input exactly.
 *
 * <p>This is a stronger condition than {@link #projectsIdentity(boolean)}.
 */
public boolean isTrivial() {
 return getCondition() == null && projectsOnlyIdentity();
}
origin: Qihoo360/Quicksql

 protected RelNode makeRel(RelOptCluster cluster, RelTraitSet traitSet,
   RelBuilder relBuilder, RelNode input, RexProgram program) {
  Preconditions.checkArgument(program.getCondition() == null,
    "WindowedAggregateRel cannot accept a condition");
  return LogicalWindow.create(cluster, traitSet, relBuilder, input,
    program);
 }
}
origin: org.apache.calcite/calcite-core

/**
 * Returns whether this program returns its input exactly.
 *
 * <p>This is a stronger condition than {@link #projectsIdentity(boolean)}.
 */
public boolean isTrivial() {
 return getCondition() == null && projectsOnlyIdentity();
}
origin: org.apache.calcite/calcite-core

 protected RelNode makeRel(RelOptCluster cluster, RelTraitSet traitSet,
   RelBuilder relBuilder, RelNode input, RexProgram program) {
  Preconditions.checkArgument(program.getCondition() == null,
    "WindowedAggregateRel cannot accept a condition");
  return LogicalWindow.create(cluster, traitSet, relBuilder, input,
    program);
 }
}
origin: org.apache.calcite/calcite-core

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);
}
origin: com.alibaba.blink/flink-table

@Override
public boolean matches(RelOptRuleCall call) {
  final Calc calc = call.rel(1);
  return calc.getProgram().getCondition() == null;
}
origin: Qihoo360/Quicksql

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);
}
origin: org.apache.calcite/calcite-core

 /**
  * 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;
 }
}
origin: Qihoo360/Quicksql

 /**
  * 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;
 }
}
origin: org.apache.calcite/calcite-core

public static Expression translateCondition(RexProgram program,
  JavaTypeFactory typeFactory, BlockBuilder list, InputGetter inputGetter,
  Function1<String, InputGetter> correlates, SqlConformance conformance) {
 if (program.getCondition() == null) {
  return RexImpTable.TRUE_EXPR;
 }
 final ParameterExpression root = DataContext.ROOT;
 RexToLixTranslator translator =
   new RexToLixTranslator(program, typeFactory, root, inputGetter, list,
     Collections.emptyMap(), new RexBuilder(typeFactory), conformance,
     null, null);
 translator = translator.setCorrelates(correlates);
 return translator.translate(
   program.getCondition(),
   RexImpTable.NullAs.FALSE);
}
origin: Qihoo360/Quicksql

public static Expression translateCondition(RexProgram program,
  JavaTypeFactory typeFactory, BlockBuilder list, InputGetter inputGetter,
  Function1<String, InputGetter> correlates, SqlConformance conformance) {
 if (program.getCondition() == null) {
  return RexImpTable.TRUE_EXPR;
 }
 final ParameterExpression root = DataContext.ROOT;
 RexToLixTranslator translator =
   new RexToLixTranslator(program, typeFactory, root, inputGetter, list,
     Collections.emptyMap(), new RexBuilder(typeFactory), conformance,
     null, null);
 translator = translator.setCorrelates(correlates);
 return translator.translate(
   program.getCondition(),
   RexImpTable.NullAs.FALSE);
}
origin: Qihoo360/Quicksql

private List<RexLocalRef> registerProjectsAndCondition(RexProgram program) {
 final List<RexNode> exprList = program.getExprList();
 final List<RexLocalRef> projectRefList = new ArrayList<>();
 final RexShuttle shuttle = new RegisterOutputShuttle(exprList);
 // For each project, lookup the expr and expand it so it is in terms of
 // bottomCalc's input fields
 for (RexLocalRef topProject : program.getProjectList()) {
  final RexNode topExpr = exprList.get(topProject.getIndex());
  final RexLocalRef expanded = (RexLocalRef) topExpr.accept(shuttle);
  // Remember the expr, but don't add to the project list yet.
  projectRefList.add(expanded);
 }
 // Similarly for the condition.
 final RexLocalRef topCondition = program.getCondition();
 if (topCondition != null) {
  final RexNode topExpr = exprList.get(topCondition.getIndex());
  final RexLocalRef expanded = (RexLocalRef) topExpr.accept(shuttle);
  addCondition(registerInput(expanded));
 }
 return projectRefList;
}
origin: org.apache.calcite/calcite-core

private List<RexLocalRef> registerProjectsAndCondition(RexProgram program) {
 final List<RexNode> exprList = program.getExprList();
 final List<RexLocalRef> projectRefList = new ArrayList<>();
 final RexShuttle shuttle = new RegisterOutputShuttle(exprList);
 // For each project, lookup the expr and expand it so it is in terms of
 // bottomCalc's input fields
 for (RexLocalRef topProject : program.getProjectList()) {
  final RexNode topExpr = exprList.get(topProject.getIndex());
  final RexLocalRef expanded = (RexLocalRef) topExpr.accept(shuttle);
  // Remember the expr, but don't add to the project list yet.
  projectRefList.add(expanded);
 }
 // Similarly for the condition.
 final RexLocalRef topCondition = program.getCondition();
 if (topCondition != null) {
  final RexNode topExpr = exprList.get(topCondition.getIndex());
  final RexLocalRef expanded = (RexLocalRef) topExpr.accept(shuttle);
  addCondition(registerInput(expanded));
 }
 return projectRefList;
}
origin: Qihoo360/Quicksql

 @Override protected RelNode handle(RelNode rel) {
  if (!(rel instanceof LogicalCalc)) {
   return rel;
  }
  final LogicalCalc calc = (LogicalCalc) rel;
  final RexProgram program = calc.getProgram();
  relBuilder.push(calc.getInput());
  if (program.getCondition() != null) {
   relBuilder.filter(
     program.expandLocalRef(program.getCondition()));
  }
  if (!program.projectsOnlyIdentity()) {
   relBuilder.project(
     Lists.transform(program.getProjectList(),
       program::expandLocalRef),
     calc.getRowType().getFieldNames());
  }
  return relBuilder.build();
 }
};
origin: org.apache.calcite/calcite-core

 @Override protected RelNode handle(RelNode rel) {
  if (!(rel instanceof LogicalCalc)) {
   return rel;
  }
  final LogicalCalc calc = (LogicalCalc) rel;
  final RexProgram program = calc.getProgram();
  relBuilder.push(calc.getInput());
  if (program.getCondition() != null) {
   relBuilder.filter(
     program.expandLocalRef(program.getCondition()));
  }
  if (!program.projectsOnlyIdentity()) {
   relBuilder.project(
     Lists.transform(program.getProjectList(),
       program::expandLocalRef),
     calc.getRowType().getFieldNames());
  }
  return relBuilder.build();
 }
};
origin: dremio/dremio-oss

public RexProgram copyOf(RexProgram program) {
 return new RexProgram(
  copyOf(program.getInputRowType()),
  copyRexNodes(program.getExprList()),
  Lists.transform(program.getProjectList(), COPY_REX_LOCAL_REF),
  (RexLocalRef) copyOf(program.getCondition()),
  copyOf(program.getOutputRowType())
 );
}
origin: Qihoo360/Quicksql

/** @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();
}
origin: dremio/dremio-oss

public void onMatch(RelOptRuleCall call) {
 final Filter topFilter = call.rel(0);
 final Filter bottomFilter = call.rel(1);
 // use RexPrograms to merge the two FilterRels into a single program
 // so we can convert the two LogicalFilter conditions to directly
 // reference the bottom LogicalFilter's child
 RexBuilder rexBuilder = topFilter.getCluster().getRexBuilder();
 RexProgram bottomProgram = createProgram(bottomFilter);
 RexProgram topProgram = createProgram(topFilter);
 RexProgram mergedProgram = RexProgramBuilder.mergePrograms(topProgram, bottomProgram, rexBuilder);
 RexNode newCondition = mergedProgram.expandLocalRef(mergedProgram.getCondition());
 final RelBuilder relBuilder = call.builder();
 relBuilder.push(bottomFilter.getInput()).filter(newCondition);
 call.transformTo(relBuilder.build());
}
origin: Qihoo360/Quicksql

public void onMatch(RelOptRuleCall call) {
 final Filter topFilter = call.rel(0);
 final Filter bottomFilter = call.rel(1);
 // use RexPrograms to merge the two FilterRels into a single program
 // so we can convert the two LogicalFilter conditions to directly
 // reference the bottom LogicalFilter's child
 RexBuilder rexBuilder = topFilter.getCluster().getRexBuilder();
 RexProgram bottomProgram = createProgram(bottomFilter);
 RexProgram topProgram = createProgram(topFilter);
 RexProgram mergedProgram =
   RexProgramBuilder.mergePrograms(
     topProgram,
     bottomProgram,
     rexBuilder);
 RexNode newCondition =
   mergedProgram.expandLocalRef(
     mergedProgram.getCondition());
 final RelBuilder relBuilder = call.builder();
 relBuilder.push(bottomFilter.getInput())
   .filter(newCondition);
 call.transformTo(relBuilder.build());
}
org.apache.calcite.rexRexProgramgetCondition

Javadoc

Returns the field reference of this program's filter condition, or null if there is no condition.

Popular methods of RexProgram

  • expandLocalRef
    Fully expands a RexLocalRef back into a pure RexNode tree containing no RexLocalRefs (reversing the
  • getInputRowType
    Returns the type of the input row to the program.
  • getProjectList
    Returns an array of references to the expressions which this program is to project. Never null, may
  • create
    Creates a program which calculates projections and filters rows based upon a condition. Does not att
  • getExprList
    Returns the common sub-expressions of this program.The list is never null but may be empty; each the
  • normalize
  • toString
  • <init>
    Creates a program.The expressions must be valid: they must not contain common expressions, forward r
  • containsAggs
    Returns whether this program contains windowed aggregate functions
  • getExprCount
    Returns the number of expressions in this program.
  • getOutputRowType
    Returns the type of the output row from this program.
  • collectExplainTerms
    Collects the expressions in this program into a list of terms and values.
  • getOutputRowType,
  • collectExplainTerms,
  • countTrivial,
  • createIdentity,
  • deduceCollations,
  • explainCalc,
  • getCollations,
  • getPermutation,
  • getSourceField

Popular in Java

  • Making http post requests using okhttp
  • getSharedPreferences (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • onCreateOptionsMenu (Activity)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now