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

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

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

origin: apache/storm

List<RexLocalRef> projectList = program.getProjectList();
if (projectList != null && !projectList.isEmpty()) {
  List<RexNode> expandedNodes = new ArrayList<>();
origin: Qihoo360/Quicksql

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

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();
}
origin: qubole/quark

 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();
 }
}
origin: qubole/quark

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

  public void onMatch(RelOptRuleCall call) {
    final Aggregate aggregate = call.rel(0);
    final Calc calc = call.rel(1);
    final RexProgram program = calc.getProgram();
    final List<RexNode> projects = new ArrayList<>();
    for (RexLocalRef localRef : program.getProjectList()) {
      projects.add(program.expandLocalRef(localRef));
    }
    final Project project = LogicalProject.create(calc.getInput(), projects, calc.getRowType());
    RelNode x = AggregateProjectMergeRule.apply(call, aggregate, project);
    if (x != null) {
      call.transformTo(x);
    }
  }
}
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

null, null)
.setCorrelates(correlates)
.translateList(program.getProjectList(), storageTypes);
origin: org.apache.calcite/calcite-core

assert program.isValid(Litmus.THROW, null);
final RelDataType inputRowType = program.getInputRowType();
final List<RexLocalRef> projectRefs = program.getProjectList();
final RexLocalRef conditionRef = program.getCondition();
final List<RexNode> exprs = program.getExprList();
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: Qihoo360/Quicksql

 public RelNode accept(RexShuttle shuttle) {
  List<RexNode> oldExprs = program.getExprList();
  List<RexNode> exprs = shuttle.apply(oldExprs);
  List<RexLocalRef> oldProjects = program.getProjectList();
  List<RexLocalRef> projects = shuttle.apply(oldProjects);
  RexLocalRef oldCondition = program.getCondition();
  RexNode condition;
  if (oldCondition != null) {
   condition = shuttle.apply(oldCondition);
   assert condition instanceof RexLocalRef
     : "Invalid condition after rewrite. Expected RexLocalRef, got "
     + condition;
  } else {
   condition = null;
  }
  if (exprs == oldExprs
    && projects == oldProjects
    && condition == oldCondition) {
   return this;
  }
  return copy(traitSet, getInput(),
    new RexProgram(program.getInputRowType(),
      exprs,
      projects,
      (RexLocalRef) condition,
      program.getOutputRowType()));
 }
}
origin: org.apache.calcite/calcite-core

 public RelNode accept(RexShuttle shuttle) {
  List<RexNode> oldExprs = program.getExprList();
  List<RexNode> exprs = shuttle.apply(oldExprs);
  List<RexLocalRef> oldProjects = program.getProjectList();
  List<RexLocalRef> projects = shuttle.apply(oldProjects);
  RexLocalRef oldCondition = program.getCondition();
  RexNode condition;
  if (oldCondition != null) {
   condition = shuttle.apply(oldCondition);
   assert condition instanceof RexLocalRef
     : "Invalid condition after rewrite. Expected RexLocalRef, got "
     + condition;
  } else {
   condition = null;
  }
  if (exprs == oldExprs
    && projects == oldProjects
    && condition == oldCondition) {
   return this;
  }
  return copy(traitSet, getInput(),
    new RexProgram(program.getInputRowType(),
      exprs,
      projects,
      (RexLocalRef) condition,
      program.getOutputRowType()));
 }
}
origin: qubole/quark

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

/** @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: Qihoo360/Quicksql

public void onMatch(RelOptRuleCall call) {
 LogicalCalc calc = call.rel(0);
 // Expand decimals in every expression in this program. If no
 // expression changes, don't apply the rule.
 final RexProgram program = calc.getProgram();
 if (!RexUtil.requiresDecimalExpansion(program, true)) {
  return;
 }
 final RexBuilder rexBuilder = calc.getCluster().getRexBuilder();
 final RexShuttle shuttle = new DecimalShuttle(rexBuilder);
 RexProgramBuilder programBuilder =
   RexProgramBuilder.create(
     rexBuilder,
     calc.getInput().getRowType(),
     program.getExprList(),
     program.getProjectList(),
     program.getCondition(),
     program.getOutputRowType(),
     shuttle,
     true);
 final RexProgram newProgram = programBuilder.getProgram();
 LogicalCalc newCalc = LogicalCalc.create(calc.getInput(), newProgram);
 call.transformTo(newCalc);
}
origin: org.apache.calcite/calcite-core

public void onMatch(RelOptRuleCall call) {
 LogicalCalc calc = call.rel(0);
 // Expand decimals in every expression in this program. If no
 // expression changes, don't apply the rule.
 final RexProgram program = calc.getProgram();
 if (!RexUtil.requiresDecimalExpansion(program, true)) {
  return;
 }
 final RexBuilder rexBuilder = calc.getCluster().getRexBuilder();
 final RexShuttle shuttle = new DecimalShuttle(rexBuilder);
 RexProgramBuilder programBuilder =
   RexProgramBuilder.create(
     rexBuilder,
     calc.getInput().getRowType(),
     program.getExprList(),
     program.getProjectList(),
     program.getCondition(),
     program.getOutputRowType(),
     shuttle,
     true);
 final RexProgram newProgram = programBuilder.getProgram();
 LogicalCalc newCalc = LogicalCalc.create(calc.getInput(), newProgram);
 call.transformTo(newCalc);
}
org.apache.calcite.rexRexProgramgetProjectList

Javadoc

Returns an array of references to the expressions which this program is to project. Never null, may be empty.

Popular methods of RexProgram

  • expandLocalRef
    Fully expands a RexLocalRef back into a pure RexNode tree containing no RexLocalRefs (reversing the
  • getCondition
    Returns the field reference of this program's filter condition, or null if there is no condition.
  • getInputRowType
    Returns the type of the input row to the program.
  • 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

  • Running tasks concurrently on multiple threads
  • setScale (BigDecimal)
  • notifyDataSetChanged (ArrayAdapter)
  • runOnUiThread (Activity)
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • BoxLayout (javax.swing)
  • JTextField (javax.swing)
  • Top plugins for Android Studio
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