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

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

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

origin: Qihoo360/Quicksql

@Deprecated // to be removed before 2.0
public static RexProgram normalize(
  RexBuilder rexBuilder,
  RexProgram program) {
 return program.normalize(rexBuilder, null);
}
origin: org.apache.calcite/calcite-core

@Deprecated // to be removed before 2.0
public static RexProgram normalize(
  RexBuilder rexBuilder,
  RexProgram program) {
 return program.normalize(rexBuilder, null);
}
origin: Qihoo360/Quicksql

@Deprecated // to be removed before 2.0
public RexProgram normalize(RexBuilder rexBuilder, boolean simplify) {
 final RelOptPredicateList predicates = RelOptPredicateList.EMPTY;
 return normalize(rexBuilder, simplify
   ? new RexSimplify(rexBuilder, predicates, RexUtil.EXECUTOR)
   : null);
}
origin: org.apache.calcite/calcite-core

@Deprecated // to be removed before 2.0
public RexProgram normalize(RexBuilder rexBuilder, boolean simplify) {
 final RelOptPredicateList predicates = RelOptPredicateList.EMPTY;
 return normalize(rexBuilder, simplify
   ? new RexSimplify(rexBuilder, predicates, RexUtil.EXECUTOR)
   : null);
}
origin: org.apache.calcite/calcite-core

  protected RelNode makeRel(RelOptCluster cluster,
    RelTraitSet traitSet, RelBuilder relBuilder, RelNode input,
    RexProgram program) {
   assert !program.containsAggs();
   program = program.normalize(cluster.getRexBuilder(), null);
   return super.makeRel(cluster, traitSet, relBuilder, input,
     program);
  }
},
origin: Qihoo360/Quicksql

  protected RelNode makeRel(RelOptCluster cluster,
    RelTraitSet traitSet, RelBuilder relBuilder, RelNode input,
    RexProgram program) {
   assert !program.containsAggs();
   program = program.normalize(cluster.getRexBuilder(), null);
   return super.makeRel(cluster, traitSet, relBuilder, input,
     program);
  }
},
origin: org.apache.calcite/calcite-core

/**
 * Returns whether this program is in canonical form.
 *
 * @param litmus     What to do if an error is detected (program is not in
 *                   canonical form)
 * @param rexBuilder Rex builder
 * @return whether in canonical form
 */
public boolean isNormalized(Litmus litmus, RexBuilder rexBuilder) {
 final RexProgram normalizedProgram = normalize(rexBuilder, null);
 String normalized = normalizedProgram.toString();
 String string = toString();
 if (!normalized.equals(string)) {
  final String message = "Program is not normalized:\n"
    + "program:    {}\n"
    + "normalized: {}\n";
  return litmus.fail(message, string, normalized);
 }
 return litmus.succeed();
}
origin: Qihoo360/Quicksql

/**
 * Returns whether this program is in canonical form.
 *
 * @param litmus     What to do if an error is detected (program is not in
 *                   canonical form)
 * @param rexBuilder Rex builder
 * @return whether in canonical form
 */
public boolean isNormalized(Litmus litmus, RexBuilder rexBuilder) {
 final RexProgram normalizedProgram = normalize(rexBuilder, null);
 String normalized = normalizedProgram.toString();
 String string = toString();
 if (!normalized.equals(string)) {
  final String message = "Program is not normalized:\n"
    + "program:    {}\n"
    + "normalized: {}\n";
  return litmus.fail(message, string, normalized);
 }
 return litmus.succeed();
}
origin: Qihoo360/Quicksql

/**
 * Tests how the condition is simplified.
 */
@Test public void testSimplifyCondition() {
 final RexProgram program = createProg(3).getProgram(false);
 assertThat(program.toString(),
   is("(expr#0..1=[{inputs}], expr#2=[+($0, 1)], expr#3=[77], "
     + "expr#4=[+($0, $1)], expr#5=[+($0, 1)], expr#6=[+($0, $t5)], "
     + "expr#7=[+($t4, $t2)], expr#8=[5], expr#9=[>($t2, $t8)], "
     + "expr#10=[true], expr#11=[IS NOT NULL($t5)], expr#12=[false], "
     + "expr#13=[null], expr#14=[CASE($t9, $t10, $t11, $t12, $t13)], "
     + "expr#15=[NOT($t14)], a=[$t7], b=[$t6], $condition=[$t15])"));
 assertThat(program.normalize(rexBuilder, simplify).toString(),
   is("(expr#0..1=[{inputs}], expr#2=[+($t0, $t1)], expr#3=[1], "
     + "expr#4=[+($t0, $t3)], expr#5=[+($t2, $t4)], "
     + "expr#6=[+($t0, $t4)], expr#7=[5], expr#8=[>($t4, $t7)], "
     + "expr#9=[CAST($t8):BOOLEAN], expr#10=[IS FALSE($t9)], "
     + "a=[$t5], b=[$t6], $condition=[$t10])"));
}
origin: org.apache.calcite/calcite-core

/**
 * Tests how the condition is simplified.
 */
@Test public void testSimplifyCondition() {
 final RexProgram program = createProg(3).getProgram(false);
 assertThat(program.toString(),
   is("(expr#0..1=[{inputs}], expr#2=[+($0, 1)], expr#3=[77], "
     + "expr#4=[+($0, $1)], expr#5=[+($0, 1)], expr#6=[+($0, $t5)], "
     + "expr#7=[+($t4, $t2)], expr#8=[5], expr#9=[>($t2, $t8)], "
     + "expr#10=[true], expr#11=[IS NOT NULL($t5)], expr#12=[false], "
     + "expr#13=[null], expr#14=[CASE($t9, $t10, $t11, $t12, $t13)], "
     + "expr#15=[NOT($t14)], a=[$t7], b=[$t6], $condition=[$t15])"));
 assertThat(program.normalize(rexBuilder, simplify).toString(),
   is("(expr#0..1=[{inputs}], expr#2=[+($t0, $t1)], expr#3=[1], "
     + "expr#4=[+($t0, $t3)], expr#5=[+($t2, $t4)], "
     + "expr#6=[+($t0, $t4)], expr#7=[5], expr#8=[>($t4, $t7)], "
     + "expr#9=[NOT($t8)], "
     + "a=[$t5], b=[$t6], $condition=[$t9])"));
}
origin: Qihoo360/Quicksql

/**
 * Tests how the condition is simplified.
 */
@Test public void testSimplifyCondition2() {
 final RexProgram program = createProg(4).getProgram(false);
 assertThat(program.toString(),
   is("(expr#0..1=[{inputs}], expr#2=[+($0, 1)], expr#3=[77], "
     + "expr#4=[+($0, $1)], expr#5=[+($0, 1)], expr#6=[+($0, $t5)], "
     + "expr#7=[+($t4, $t2)], expr#8=[5], expr#9=[>($t2, $t8)], "
     + "expr#10=[true], expr#11=[IS NOT NULL($t5)], expr#12=[false], "
     + "expr#13=[null], expr#14=[CASE($t9, $t10, $t11, $t12, $t13)], "
     + "expr#15=[NOT($t14)], expr#16=[IS TRUE($t15)], a=[$t7], b=[$t6], "
     + "$condition=[$t16])"));
 assertThat(program.normalize(rexBuilder, simplify).toString(),
   is("(expr#0..1=[{inputs}], expr#2=[+($t0, $t1)], expr#3=[1], "
     + "expr#4=[+($t0, $t3)], expr#5=[+($t2, $t4)], "
     + "expr#6=[+($t0, $t4)], expr#7=[5], expr#8=[>($t4, $t7)], "
     + "expr#9=[CAST($t8):BOOLEAN], expr#10=[IS FALSE($t9)], "
     + "a=[$t5], b=[$t6], $condition=[$t10])"));
}
origin: org.apache.calcite/calcite-core

/**
 * Tests how the condition is simplified.
 */
@Test public void testSimplifyCondition2() {
 final RexProgram program = createProg(4).getProgram(false);
 assertThat(program.toString(),
   is("(expr#0..1=[{inputs}], expr#2=[+($0, 1)], expr#3=[77], "
     + "expr#4=[+($0, $1)], expr#5=[+($0, 1)], expr#6=[+($0, $t5)], "
     + "expr#7=[+($t4, $t2)], expr#8=[5], expr#9=[>($t2, $t8)], "
     + "expr#10=[true], expr#11=[IS NOT NULL($t5)], expr#12=[false], "
     + "expr#13=[null], expr#14=[CASE($t9, $t10, $t11, $t12, $t13)], "
     + "expr#15=[NOT($t14)], expr#16=[IS TRUE($t15)], a=[$t7], b=[$t6], "
     + "$condition=[$t16])"));
 assertThat(program.normalize(rexBuilder, simplify).toString(),
   is("(expr#0..1=[{inputs}], expr#2=[+($t0, $t1)], expr#3=[1], "
     + "expr#4=[+($t0, $t3)], expr#5=[+($t2, $t4)], "
     + "expr#6=[+($t0, $t4)], expr#7=[5], expr#8=[>($t4, $t7)], "
     + "expr#9=[NOT($t8)], "
     + "a=[$t5], b=[$t6], $condition=[$t9])"));
}
origin: Qihoo360/Quicksql

/**
 * Tests construction of a RexProgram.
 */
@Test public void testBuildProgram() {
 final RexProgramBuilder builder = createProg(0);
 final RexProgram program = builder.getProgram(false);
 final String programString = program.toString();
 TestUtil.assertEqualsVerbose(
   "(expr#0..1=[{inputs}], expr#2=[+($0, 1)], expr#3=[77], "
     + "expr#4=[+($0, $1)], expr#5=[+($0, $0)], expr#6=[+($t4, $t2)], "
     + "a=[$t6], b=[$t5])",
   programString);
 // Normalize the program using the RexProgramBuilder.normalize API.
 // Note that unused expression '77' is eliminated, input refs (e.g. $0)
 // become local refs (e.g. $t0), and constants are assigned to locals.
 final RexProgram normalizedProgram = program.normalize(rexBuilder, null);
 final String normalizedProgramString = normalizedProgram.toString();
 TestUtil.assertEqualsVerbose(
   "(expr#0..1=[{inputs}], expr#2=[+($t0, $t1)], expr#3=[1], "
     + "expr#4=[+($t0, $t3)], expr#5=[+($t2, $t4)], "
     + "expr#6=[+($t0, $t0)], a=[$t5], b=[$t6])",
   normalizedProgramString);
}
origin: org.apache.calcite/calcite-core

/**
 * Tests construction of a RexProgram.
 */
@Test public void testBuildProgram() {
 final RexProgramBuilder builder = createProg(0);
 final RexProgram program = builder.getProgram(false);
 final String programString = program.toString();
 TestUtil.assertEqualsVerbose(
   "(expr#0..1=[{inputs}], expr#2=[+($0, 1)], expr#3=[77], "
     + "expr#4=[+($0, $1)], expr#5=[+($0, $0)], expr#6=[+($t4, $t2)], "
     + "a=[$t6], b=[$t5])",
   programString);
 // Normalize the program using the RexProgramBuilder.normalize API.
 // Note that unused expression '77' is eliminated, input refs (e.g. $0)
 // become local refs (e.g. $t0), and constants are assigned to locals.
 final RexProgram normalizedProgram = program.normalize(rexBuilder, null);
 final String normalizedProgramString = normalizedProgram.toString();
 TestUtil.assertEqualsVerbose(
   "(expr#0..1=[{inputs}], expr#2=[+($t0, $t1)], expr#3=[1], "
     + "expr#4=[+($t0, $t3)], expr#5=[+($t2, $t4)], "
     + "expr#6=[+($t0, $t0)], a=[$t5], b=[$t6])",
   normalizedProgramString);
}
origin: Qihoo360/Quicksql

final RexSimplify simplify =
  new RexSimplify(rexBuilder, predicates, RexUtil.EXECUTOR);
final RexProgram program = this.program.normalize(rexBuilder, simplify);
origin: org.apache.calcite/calcite-core

final RexSimplify simplify =
  new RexSimplify(rexBuilder, predicates, RexUtil.EXECUTOR);
final RexProgram program = this.program.normalize(rexBuilder, simplify);
org.apache.calcite.rexRexProgramnormalize

Javadoc

Creates a simplified/normalized copy of this program.

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.
  • 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
  • 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

  • Finding current android device location
  • getApplicationContext (Context)
  • getExternalFilesDir (Context)
  • getSharedPreferences (Context)
  • Menu (java.awt)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • 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