Java Code Examples for org.apache.calcite.linq4j.tree.Expression#accept()

The following examples show how to use org.apache.calcite.linq4j.tree.Expression#accept() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExpressionTest.java    From calcite with Apache License 2.0 4 votes vote down vote up
@Test void testConstantExpression() {
  final Expression constant = Expressions.constant(
      new Object[] {
          1,
          new Object[] {
              (byte) 1, (short) 2, (int) 3, (long) 4,
              (float) 5, (double) 6, (char) 7, true, "string", null
          },
          new AllType(true, (byte) 100, (char) 101, (short) 102, 103,
              (long) 104, (float) 105, (double) 106, new BigDecimal(107),
              new BigInteger("108"), "109", null)
      });
  assertEquals(
      "new Object[] {\n"
          + "  1,\n"
          + "  new Object[] {\n"
          + "    (byte)1,\n"
          + "    (short)2,\n"
          + "    3,\n"
          + "    4L,\n"
          + "    5.0F,\n"
          + "    6.0D,\n"
          + "    (char)7,\n"
          + "    true,\n"
          + "    \"string\",\n"
          + "    null},\n"
          + "  new org.apache.calcite.linq4j.test.ExpressionTest.AllType(\n"
          + "    true,\n"
          + "    (byte)100,\n"
          + "    (char)101,\n"
          + "    (short)102,\n"
          + "    103,\n"
          + "    104L,\n"
          + "    105.0F,\n"
          + "    106.0D,\n"
          + "    java.math.BigDecimal.valueOf(107L),\n"
          + "    new java.math.BigInteger(\"108\"),\n"
          + "    \"109\",\n"
          + "    null)}",
      constant.toString());
  constant.accept(new Shuttle());
}
 
Example 2
Source File: DeterministicTest.java    From calcite with Apache License 2.0 4 votes vote down vote up
private boolean isConstant(Expression e) {
  Expression e2 =
      e.accept(
          new DeterministicCodeOptimizer(ClassDeclarationFinder.create()));
  return !e.equals(e2);
}
 
Example 3
Source File: RexImpTable.java    From calcite with Apache License 2.0 4 votes vote down vote up
static Expression optimize(Expression expression) {
  return expression.accept(new OptimizeShuttle());
}