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

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

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

origin: Qihoo360/Quicksql

/**
 * Returns whether the fields on the leading edge of the project list are
 * the input fields.
 *
 * @param fail Whether to throw an assert failure if does not project
 *             identity
 */
public boolean projectsIdentity(final boolean fail) {
 final int fieldCount = inputRowType.getFieldCount();
 if (projects.size() < fieldCount) {
  assert !fail
    : "program '" + toString()
    + "' does not project identity for input row type '"
    + inputRowType + "'";
  return false;
 }
 for (int i = 0; i < fieldCount; i++) {
  RexLocalRef project = projects.get(i);
  if (project.index != i) {
   assert !fail
     : "program " + toString()
     + "' does not project identity for input row type '"
     + inputRowType + "', field #" + i;
   return false;
  }
 }
 return true;
}
origin: org.apache.calcite/calcite-core

/**
 * Returns whether the fields on the leading edge of the project list are
 * the input fields.
 *
 * @param fail Whether to throw an assert failure if does not project
 *             identity
 */
public boolean projectsIdentity(final boolean fail) {
 final int fieldCount = inputRowType.getFieldCount();
 if (projects.size() < fieldCount) {
  assert !fail
    : "program '" + toString()
    + "' does not project identity for input row type '"
    + inputRowType + "'";
  return false;
 }
 for (int i = 0; i < fieldCount; i++) {
  RexLocalRef project = projects.get(i);
  if (project.index != i) {
   assert !fail
     : "program " + toString()
     + "' does not project identity for input row type '"
     + inputRowType + "', field #" + i;
   return false;
  }
 }
 return true;
}
origin: org.apache.calcite/calcite-core

PrintWriter traceWriter = new PrintWriter(traceMsg);
traceWriter.println("FarragoAutoCalcRule result expressions for: ");
traceWriter.println(program.toString());
origin: Qihoo360/Quicksql

PrintWriter traceWriter = new PrintWriter(traceMsg);
traceWriter.println("FarragoAutoCalcRule result expressions for: ");
traceWriter.println(program.toString());
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: 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

/**
 * 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 and normalization of a RexProgram.
 */
@Test public void testNormalize() {
 final RexProgramBuilder builder = createProg(0);
 final String program = builder.getProgram(true).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])",
   program);
}
origin: org.apache.calcite/calcite-core

/**
 * Tests construction and normalization of a RexProgram.
 */
@Test public void testNormalize() {
 final RexProgramBuilder builder = createProg(0);
 final String program = builder.getProgram(true).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])",
   program);
}
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: org.apache.calcite/calcite-core

/**
 * Tests construction and normalization of a RexProgram.
 */
@Test public void testElimDups() {
 final RexProgramBuilder builder = createProg(1);
 final String unnormalizedProgram = builder.getProgram(false).toString();
 TestUtil.assertEqualsVerbose(
   "(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)], a=[$t7], b=[$t6])",
   unnormalizedProgram);
 // normalize eliminates duplicates (specifically "+($0, $1)")
 final RexProgramBuilder builder2 = createProg(1);
 final String program2 = builder2.getProgram(true).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, $t4)], a=[$t5], b=[$t6])",
   program2);
}
origin: Qihoo360/Quicksql

/**
 * Checks translation of AND(x, x).
 */
@Test public void testDuplicateAnd() {
 // RexProgramBuilder used to translate AND(x, x) to x.
 // Now it translates it to AND(x, x).
 // The optimization of AND(x, x) => x occurs at a higher level.
 final RexProgramBuilder builder = createProg(2);
 final String program = builder.getProgram(true).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)], expr#7=[>($t2, $t0)], "
     + "a=[$t5], b=[$t6], $condition=[$t7])",
   program);
}
origin: Qihoo360/Quicksql

/**
 * Tests construction and normalization of a RexProgram.
 */
@Test public void testElimDups() {
 final RexProgramBuilder builder = createProg(1);
 final String unnormalizedProgram = builder.getProgram(false).toString();
 TestUtil.assertEqualsVerbose(
   "(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)], a=[$t7], b=[$t6])",
   unnormalizedProgram);
 // normalize eliminates duplicates (specifically "+($0, $1)")
 final RexProgramBuilder builder2 = createProg(1);
 final String program2 = builder2.getProgram(true).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, $t4)], a=[$t5], b=[$t6])",
   program2);
}
origin: org.apache.calcite/calcite-core

/**
 * Checks translation of AND(x, x).
 */
@Test public void testDuplicateAnd() {
 // RexProgramBuilder used to translate AND(x, x) to x.
 // Now it translates it to AND(x, x).
 // The optimization of AND(x, x) => x occurs at a higher level.
 final RexProgramBuilder builder = createProg(2);
 final String program = builder.getProgram(true).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)], expr#7=[>($t2, $t0)], "
     + "a=[$t5], b=[$t6], $condition=[$t7])",
   program);
}
org.apache.calcite.rexRexProgramtoString

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
  • normalize
  • <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
  • findViewById (Activity)
  • startActivity (Activity)
  • getResourceAsStream (ClassLoader)
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • String (java.lang)
  • Permission (java.security)
    Legacy security code; do not use.
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • JTable (javax.swing)
  • Top Vim plugins
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