You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by jh...@apache.org on 2018/10/28 17:30:43 UTC

[1/3] calcite git commit: [CALCITE-2638] Constant reducer should not treat as constant an RexInputRef that points to a call to a dynamic or non-deterministic function (Danny Chan)

Repository: calcite
Updated Branches:
  refs/heads/master c5ff67031 -> 6284d3c88


[CALCITE-2638] Constant reducer should not treat as constant an RexInputRef that points to a call to a dynamic or non-deterministic function (Danny Chan)

ReducibleExprLocator was not treating a reference to a constant that
is a function call the same as if it were an inline function call.

Close apache/calcite#892


Project: http://git-wip-us.apache.org/repos/asf/calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/calcite/commit/0d31de79
Tree: http://git-wip-us.apache.org/repos/asf/calcite/tree/0d31de79
Diff: http://git-wip-us.apache.org/repos/asf/calcite/diff/0d31de79

Branch: refs/heads/master
Commit: 0d31de796e3120e63c48f5459f7be3c1164f57d3
Parents: c5ff670
Author: yuzhao.cyz <yu...@alibaba-inc.com>
Authored: Wed Oct 24 14:12:22 2018 +0800
Committer: Julian Hyde <jh...@apache.org>
Committed: Fri Oct 26 20:58:11 2018 -0700

----------------------------------------------------------------------
 .../rel/rules/ReduceExpressionsRule.java        |  9 ++-
 .../apache/calcite/test/RelOptRulesTest.java    | 67 ++++++++++++++++++++
 .../org/apache/calcite/test/RelOptRulesTest.xml | 44 +++++++++++++
 3 files changed, 118 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite/blob/0d31de79/core/src/main/java/org/apache/calcite/rel/rules/ReduceExpressionsRule.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/rules/ReduceExpressionsRule.java b/core/src/main/java/org/apache/calcite/rel/rules/ReduceExpressionsRule.java
index 3140ecf..5ba3d3c 100644
--- a/core/src/main/java/org/apache/calcite/rel/rules/ReduceExpressionsRule.java
+++ b/core/src/main/java/org/apache/calcite/rel/rules/ReduceExpressionsRule.java
@@ -909,8 +909,13 @@ public abstract class ReduceExpressionsRule extends RelOptRule {
     }
 
     @Override public Void visitInputRef(RexInputRef inputRef) {
-      if (constants.containsKey(inputRef)) {
-        stack.add(Constancy.REDUCIBLE_CONSTANT);
+      final RexNode constant = constants.get(inputRef);
+      if (constant != null) {
+        if (constant instanceof RexCall) {
+          constant.accept(this);
+        } else {
+          stack.add(Constancy.REDUCIBLE_CONSTANT);
+        }
         return null;
       }
       return pushVariable();

http://git-wip-us.apache.org/repos/asf/calcite/blob/0d31de79/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java b/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
index 720b5a8..a4475fb 100644
--- a/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
+++ b/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
@@ -110,8 +110,12 @@ import org.apache.calcite.rex.RexCall;
 import org.apache.calcite.rex.RexNode;
 import org.apache.calcite.runtime.Hook;
 import org.apache.calcite.sql.SemiJoinType;
+import org.apache.calcite.sql.SqlKind;
 import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.SqlSpecialOperator;
 import org.apache.calcite.sql.fun.SqlStdOperatorTable;
+import org.apache.calcite.sql.type.ReturnTypes;
 import org.apache.calcite.sql.type.SqlTypeName;
 import org.apache.calcite.sql.validate.SqlValidator;
 import org.apache.calcite.sql2rel.SqlToRelConverter;
@@ -2178,6 +2182,69 @@ public class RelOptRulesTest extends RelOptTestBase {
     checkPlanning(program, sql);
   }
 
+  /** Test case for
+   * <a href="https://issues.apache.org/jira/browse/CALCITE-2638">[CALCITE-2638]
+   * Constant reducer must not duplicate calls to non-deterministic
+   * functions</a>. */
+  @Test public void testReduceConstantsNonDeterministicFunction() {
+    final DiffRepository diffRepos = getDiffRepos();
+
+    final SqlOperator nonDeterministicOp =
+        new SqlSpecialOperator("NDC", SqlKind.OTHER_FUNCTION, 0, false,
+            ReturnTypes.INTEGER, null, null) {
+          @Override public boolean isDeterministic() {
+            return false;
+          }
+        };
+
+    // Build a tree equivalent to the SQL
+    //  SELECT sal, n
+    //  FROM (SELECT sal, NDC() AS n FROM emp)
+    //  WHERE n > 10
+    final RelBuilder builder =
+        RelBuilder.create(RelBuilderTest.config().build());
+    final RelNode root =
+        builder.scan("EMP")
+            .project(builder.field("SAL"),
+                builder.alias(builder.call(nonDeterministicOp), "N"))
+            .filter(
+                builder.call(SqlStdOperatorTable.GREATER_THAN,
+                    builder.field("N"), builder.literal(10)))
+            .build();
+
+    HepProgram preProgram = new HepProgramBuilder().build();
+    HepPlanner prePlanner = new HepPlanner(preProgram);
+    prePlanner.setRoot(root);
+    final RelNode relBefore = prePlanner.findBestExp();
+    final String planBefore = NL + RelOptUtil.toString(relBefore);
+    diffRepos.assertEquals("planBefore", "${planBefore}", planBefore);
+
+    final HepProgram program = new HepProgramBuilder()
+        .addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE)
+        .addRuleInstance(ReduceExpressionsRule.PROJECT_INSTANCE)
+        .build();
+
+    HepPlanner hepPlanner = new HepPlanner(program);
+    hepPlanner.setRoot(root);
+    final RelNode relAfter = hepPlanner.findBestExp();
+    final String planAfter = NL + RelOptUtil.toString(relAfter);
+    diffRepos.assertEquals("planAfter", "${planAfter}", planAfter);
+  }
+
+  /** Checks that constant reducer duplicates calls to dynamic functions, if
+   * appropriate. CURRENT_TIMESTAMP is a dynamic function. */
+  @Test public void testReduceConstantsDynamicFunction() {
+    HepProgram program = new HepProgramBuilder()
+        .addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE)
+        .addRuleInstance(ReduceExpressionsRule.PROJECT_INSTANCE)
+        .build();
+
+    final String sql = "select sal, t\n"
+        + "from (select sal, current_timestamp t from emp)\n"
+        + "where t > TIMESTAMP '2018-01-01 00:00:00'";
+    sql(sql).with(program).checkUnchanged();
+  }
+
   @Test public void testCasePushIsAlwaysWorking() throws Exception {
     HepProgram program = new HepProgramBuilder()
         .addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE)

http://git-wip-us.apache.org/repos/asf/calcite/blob/0d31de79/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml
----------------------------------------------------------------------
diff --git a/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml b/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml
index e344576..d99152e 100644
--- a/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml
+++ b/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml
@@ -6120,6 +6120,29 @@ LogicalProject(EXPR$0=[CASE(=($1, 0), null, $0)])
 ]]>
         </Resource>
     </TestCase>
+    <TestCase name="testReduceConstantsDynamicFunction">
+        <Resource name="sql">
+            <![CDATA[select sal, t
+from (select sal, current_timestamp t from emp)
+where t > TIMESTAMP '2018-01-01 00:00:00']]>
+        </Resource>
+        <Resource name="planBefore">
+            <![CDATA[
+LogicalProject(SAL=[$0], T=[$1])
+  LogicalFilter(condition=[>($1, 2018-01-01 00:00:00)])
+    LogicalProject(SAL=[$5], T=[CURRENT_TIMESTAMP])
+      LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+]]>
+        </Resource>
+        <Resource name="planAfter">
+            <![CDATA[
+LogicalProject(SAL=[$0], T=[$1])
+  LogicalFilter(condition=[>($1, 2018-01-01 00:00:00)])
+    LogicalProject(SAL=[$5], T=[CURRENT_TIMESTAMP])
+      LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+]]>
+        </Resource>
+    </TestCase>
     <TestCase name="testReduceConstantsIsNotNull">
         <Resource name="sql">
             <![CDATA[select empno from emp
@@ -6428,6 +6451,27 @@ LogicalProject(DEPTNO=[$0], DEPTNO0=[$9])
 ]]>
         </Resource>
     </TestCase>
+    <TestCase name="testReduceConstantsNonDeterministicFunction">
+        <Resource name="sql">
+            <![CDATA[select sal, r
+from (select sal, rand() as r from emp)
+where r > 0.5]]>
+        </Resource>
+        <Resource name="planBefore">
+            <![CDATA[
+LogicalFilter(condition=[>($1, 10)])
+  LogicalProject(SAL=[$5], N=[NDC()])
+    LogicalTableScan(table=[[scott, EMP]])
+]]>
+        </Resource>
+        <Resource name="planAfter">
+            <![CDATA[
+LogicalFilter(condition=[>($1, 10)])
+  LogicalProject(SAL=[$5], N=[NDC()])
+    LogicalTableScan(table=[[scott, EMP]])
+]]>
+        </Resource>
+    </TestCase>
     <TestCase name="testReduceConstantsNullEqualsOne">
         <Resource name="sql">
             <![CDATA[select count(1) from emp where cast(null as integer) = 1]]>


[3/3] calcite git commit: [CALCITE-2617] Add a variant of FilterProjectTransposeRule that can push down a Filter that contains correlated variables (Stamatis Zampetakis)

Posted by jh...@apache.org.
[CALCITE-2617] Add a variant of FilterProjectTransposeRule that can push down a Filter that contains correlated variables (Stamatis Zampetakis)

The default instance of FilterProjectTransposeRule does not push down
a Filter that contains correlated variables, as before.

1. Add a new constructor accepting predicates for the Filter and
   Project operands.
2. Remove the correlating condition check from the body of the rule
   and make it an optional predicate.
3. Pass the new correlating condition predicate to the existing
   constructors (retaining the same functionality for the generic
   INSTANCE rule)

Note: Classes using the protected constructor may break if they rely
on the fact that the Filter is not pushed when it contains correlating
conditions.

Add tests for each variant (Julian Hyde)

Close apache/calcite#887


Project: http://git-wip-us.apache.org/repos/asf/calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/calcite/commit/6284d3c8
Tree: http://git-wip-us.apache.org/repos/asf/calcite/tree/6284d3c8
Diff: http://git-wip-us.apache.org/repos/asf/calcite/diff/6284d3c8

Branch: refs/heads/master
Commit: 6284d3c88d9c659e0a8ef3dd5cf4819133de7522
Parents: 4b51b5a
Author: Stamatis Zampetakis <za...@gmail.com>
Authored: Thu Oct 11 19:25:49 2018 +0200
Committer: Julian Hyde <jh...@apache.org>
Committed: Sun Oct 28 02:29:04 2018 -0700

----------------------------------------------------------------------
 .../rel/rules/FilterProjectTransposeRule.java   | 66 +++++++++++++++-----
 .../apache/calcite/test/RelOptRulesTest.java    | 49 +++++++++++++++
 .../org/apache/calcite/test/RelOptTestBase.java |  2 +-
 .../org/apache/calcite/test/RelOptRulesTest.xml | 66 ++++++++++++++++++++
 4 files changed, 165 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite/blob/6284d3c8/core/src/main/java/org/apache/calcite/rel/rules/FilterProjectTransposeRule.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/rules/FilterProjectTransposeRule.java b/core/src/main/java/org/apache/calcite/rel/rules/FilterProjectTransposeRule.java
index 3bdb5f5..ac0ad83 100644
--- a/core/src/main/java/org/apache/calcite/rel/rules/FilterProjectTransposeRule.java
+++ b/core/src/main/java/org/apache/calcite/rel/rules/FilterProjectTransposeRule.java
@@ -30,17 +30,26 @@ import org.apache.calcite.rex.RexUtil;
 import org.apache.calcite.tools.RelBuilder;
 import org.apache.calcite.tools.RelBuilderFactory;
 
+import java.util.function.Predicate;
+
 /**
  * Planner rule that pushes
- * a {@link org.apache.calcite.rel.logical.LogicalFilter}
- * past a {@link org.apache.calcite.rel.logical.LogicalProject}.
+ * a {@link org.apache.calcite.rel.core.Filter}
+ * past a {@link org.apache.calcite.rel.core.Project}.
  */
 public class FilterProjectTransposeRule extends RelOptRule {
   /** The default instance of
    * {@link org.apache.calcite.rel.rules.FilterProjectTransposeRule}.
    *
-   * <p>It matches any kind of join or filter, and generates the same kind of
-   * join and filter. */
+   * <p>It matches any kind of {@link org.apache.calcite.rel.core.Join} or
+   * {@link org.apache.calcite.rel.core.Filter}, and generates the same kind of
+   * Join and Filter.
+   *
+   * <p>It does not allow a Filter to be pushed past the Project if
+   * {@link RexUtil#containsCorrelation there is a correlation condition})
+   * anywhere in the Filter, since in some cases it can prevent a
+   * {@link org.apache.calcite.rel.core.Correlate} from being de-correlated.
+   */
   public static final FilterProjectTransposeRule INSTANCE =
       new FilterProjectTransposeRule(Filter.class, Project.class, true, true,
           RelFactories.LOGICAL_BUILDER);
@@ -53,17 +62,46 @@ public class FilterProjectTransposeRule extends RelOptRule {
   /**
    * Creates a FilterProjectTransposeRule.
    *
-   * <p>If {@code filterFactory} is null, creates the same kind of filter as
-   * matched in the rule. Similarly {@code projectFactory}.</p>
+   * <p>Equivalent to the rule created by
+   * {@link #FilterProjectTransposeRule(Class, Predicate, Class, Predicate, boolean, boolean, RelBuilderFactory)}
+   * with some default predicates that do not allow a filter to be pushed
+   * past the project if there is a correlation condition anywhere in the
+   * filter (since in some cases it can prevent a
+   * {@link org.apache.calcite.rel.core.Correlate} from being de-correlated).
    */
   public FilterProjectTransposeRule(
       Class<? extends Filter> filterClass,
       Class<? extends Project> projectClass,
       boolean copyFilter, boolean copyProject,
       RelBuilderFactory relBuilderFactory) {
+    this(filterClass,
+        filter -> !RexUtil.containsCorrelation(filter.getCondition()),
+        projectClass, project -> true,
+        copyFilter, copyProject, relBuilderFactory);
+  }
+
+  /**
+   * Creates a FilterProjectTransposeRule.
+   *
+   * <p>If {@code copyFilter} is true, creates the same kind of Filter as
+   * matched in the rule, otherwise it creates a Filter using the RelBuilder
+   * obtained by the {@code relBuilderFactory}.
+   * Similarly for {@code copyProject}.
+   *
+   * <p>Defining predicates for the Filter (using {@code filterPredicate})
+   * and/or the Project (using {@code projectPredicate} allows making the rule
+   * more restrictive.
+   */
+  public <F extends Filter, P extends Project> FilterProjectTransposeRule(
+      Class<F> filterClass,
+      Predicate<? super F> filterPredicate,
+      Class<P> projectClass,
+      Predicate<? super P> projectPredicate,
+      boolean copyFilter, boolean copyProject,
+      RelBuilderFactory relBuilderFactory) {
     this(
-        operand(filterClass,
-            operand(projectClass, any())),
+        operandJ(filterClass, null, filterPredicate,
+            operandJ(projectClass, null, projectPredicate, any())),
         copyFilter, copyProject, relBuilderFactory);
   }
 
@@ -73,7 +111,9 @@ public class FilterProjectTransposeRule extends RelOptRule {
       RelFactories.FilterFactory filterFactory,
       Class<? extends Project> projectClass,
       RelFactories.ProjectFactory projectFactory) {
-    this(filterClass, projectClass, filterFactory == null,
+    this(filterClass, filter -> !RexUtil.containsCorrelation(filter.getCondition()),
+        projectClass, project -> true,
+        filterFactory == null,
         projectFactory == null,
         RelBuilder.proto(filterFactory, projectFactory));
   }
@@ -103,14 +143,6 @@ public class FilterProjectTransposeRule extends RelOptRule {
       // it can be pushed down. For now we don't support this.
       return;
     }
-
-    if (RexUtil.containsCorrelation(filter.getCondition())) {
-      // If there is a correlation condition anywhere in the filter, don't
-      // push this filter past project since in some cases it can prevent a
-      // Correlate from being de-correlated.
-      return;
-    }
-
     // convert the filter to one that references the child of the project
     RexNode newCondition =
         RelOptUtil.pushPastProject(filter.getCondition(), project);

http://git-wip-us.apache.org/repos/asf/calcite/blob/6284d3c8/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java b/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
index a4475fb..e3a943a 100644
--- a/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
+++ b/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
@@ -34,6 +34,7 @@ import org.apache.calcite.rel.RelNode;
 import org.apache.calcite.rel.RelRoot;
 import org.apache.calcite.rel.core.Aggregate;
 import org.apache.calcite.rel.core.CorrelationId;
+import org.apache.calcite.rel.core.Filter;
 import org.apache.calcite.rel.core.Intersect;
 import org.apache.calcite.rel.core.JoinRelType;
 import org.apache.calcite.rel.core.Minus;
@@ -1193,6 +1194,54 @@ public class RelOptRulesTest extends RelOptTestBase {
             + "unnest(t1.employees) as t2");
   }
 
+  /** Tests that the default instance of {@link FilterProjectTransposeRule}
+   * does not push a Filter that contains a correlating variable.
+   *
+   * @see #testFilterProjectTranspose() */
+  @Test public void testFilterProjectTransposePreventedByCorrelation() {
+    final String sql = "SELECT e.empno\n"
+        + "FROM emp as e\n"
+        + "WHERE exists (\n"
+        + "  SELECT *\n"
+        + "  FROM (\n"
+        + "    SELECT deptno * 2 AS twiceDeptno\n"
+        + "    FROM dept) AS d\n"
+        + "  WHERE e.deptno = d.twiceDeptno)";
+    HepProgram program = new HepProgramBuilder()
+        .addRuleInstance(FilterProjectTransposeRule.INSTANCE)
+        .build();
+    sql(sql)
+        .withDecorrelation(false)
+        .expand(true)
+        .with(program)
+        .checkUnchanged();
+  }
+
+  /** Tests a variant of {@link FilterProjectTransposeRule}
+   * that pushes a Filter that contains a correlating variable. */
+  @Test public void testFilterProjectTranspose() {
+    final String sql = "SELECT e.empno\n"
+        + "FROM emp as e\n"
+        + "WHERE exists (\n"
+        + "  SELECT *\n"
+        + "  FROM (\n"
+        + "    SELECT deptno * 2 AS twiceDeptno\n"
+        + "    FROM dept) AS d\n"
+        + "  WHERE e.deptno = d.twiceDeptno)";
+    final FilterProjectTransposeRule filterProjectTransposeRule =
+        new FilterProjectTransposeRule(Filter.class, filter -> true,
+            Project.class, project -> true, true, true,
+            RelFactories.LOGICAL_BUILDER);
+    HepProgram program = new HepProgramBuilder()
+        .addRuleInstance(filterProjectTransposeRule)
+        .build();
+    sql(sql)
+        .withDecorrelation(false)
+        .expand(true)
+        .with(program)
+        .check();
+  }
+
   private static final String NOT_STRONG_EXPR =
       "case when e.sal < 11 then 11 else -1 * e.sal end";
 

http://git-wip-us.apache.org/repos/asf/calcite/blob/6284d3c8/core/src/test/java/org/apache/calcite/test/RelOptTestBase.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/RelOptTestBase.java b/core/src/test/java/org/apache/calcite/test/RelOptTestBase.java
index 1fb2e57..507edd2 100644
--- a/core/src/test/java/org/apache/calcite/test/RelOptTestBase.java
+++ b/core/src/test/java/org/apache/calcite/test/RelOptTestBase.java
@@ -219,7 +219,7 @@ abstract class RelOptTestBase extends SqlToRelTestBase {
       diffRepos.assertEquals("planAfter", "${planAfter}", planAfter);
       if (planBefore.equals(planAfter)) {
         throw new AssertionError("Expected plan before and after is the same.\n"
-            + "You must use unchanged=true or call checkPlanUnchanged");
+            + "You must use unchanged=true or call checkUnchanged");
       }
     }
     SqlToRelTestBase.assertValid(r);

http://git-wip-us.apache.org/repos/asf/calcite/blob/6284d3c8/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml
----------------------------------------------------------------------
diff --git a/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml b/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml
index d99152e..a702384 100644
--- a/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml
+++ b/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml
@@ -2518,6 +2518,69 @@ LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$
 ]]>
         </Resource>
     </TestCase>
+    <TestCase name="testFilterProjectTranspose">
+        <Resource name="sql">
+            <![CDATA[SELECT e.empno
+FROM emp as e
+WHERE exists (
+  SELECT *
+  FROM (
+    SELECT deptno * 2 AS twiceDeptno
+    FROM dept) AS d
+  WHERE e.deptno = d.twiceDeptno)]]>
+        </Resource>
+        <Resource name="planBefore">
+            <![CDATA[
+LogicalProject(EMPNO=[$0])
+  LogicalFilter(condition=[IS NOT NULL($9)])
+    LogicalCorrelate(correlation=[$cor0], joinType=[left], requiredColumns=[{7}])
+      LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+      LogicalAggregate(group=[{}], agg#0=[MIN($0)])
+        LogicalProject($f0=[true])
+          LogicalFilter(condition=[=($cor0.DEPTNO, $0)])
+            LogicalProject(TWICEDEPTNO=[*($0, 2)])
+              LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
+]]>
+        </Resource>
+        <Resource name="planAfter">
+            <![CDATA[
+LogicalProject(EMPNO=[$0])
+  LogicalFilter(condition=[IS NOT NULL($9)])
+    LogicalCorrelate(correlation=[$cor0], joinType=[left], requiredColumns=[{7}])
+      LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+      LogicalAggregate(group=[{}], agg#0=[MIN($0)])
+        LogicalProject($f0=[true])
+          LogicalProject(TWICEDEPTNO=[*($0, 2)])
+            LogicalFilter(condition=[=($cor0.DEPTNO, *($0, 2))])
+              LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
+]]>
+        </Resource>
+    </TestCase>
+    <TestCase name="testFilterProjectTransposePreventedByCorrelation">
+        <Resource name="sql">
+            <![CDATA[SELECT e.empno
+FROM emp as e
+WHERE exists (
+  SELECT *
+  FROM (
+    SELECT deptno * 2 AS twiceDeptno
+    FROM dept) AS d
+  WHERE e.deptno = d.twiceDeptno)]]>
+        </Resource>
+        <Resource name="planBefore">
+            <![CDATA[
+LogicalProject(EMPNO=[$0])
+  LogicalFilter(condition=[IS NOT NULL($9)])
+    LogicalCorrelate(correlation=[$cor0], joinType=[left], requiredColumns=[{7}])
+      LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+      LogicalAggregate(group=[{}], agg#0=[MIN($0)])
+        LogicalProject($f0=[true])
+          LogicalFilter(condition=[=($cor0.DEPTNO, $0)])
+            LogicalProject(TWICEDEPTNO=[*($0, 2)])
+              LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
+]]>
+        </Resource>
+    </TestCase>
     <TestCase name="testFilterRemoveIsNotDistinctFromRule">
         <Resource name="planBefore">
             <![CDATA[
@@ -8607,5 +8670,8 @@ LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$
     LogicalTableScan(table=[[CATALOG, SALES, EMP]])
 ]]>
         </Resource>
+        <Resource name="sql">
+            <![CDATA[select * from emp where MGR > 0 and case when MGR > 0 then deptno / MGR else null end > 1]]>
+        </Resource>
     </TestCase>
 </Root>


[2/3] calcite git commit: Cosmetic

Posted by jh...@apache.org.
Cosmetic

In HTML5 <tt> is deprecated, so use <code> instead.


Project: http://git-wip-us.apache.org/repos/asf/calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/calcite/commit/4b51b5ab
Tree: http://git-wip-us.apache.org/repos/asf/calcite/tree/4b51b5ab
Diff: http://git-wip-us.apache.org/repos/asf/calcite/diff/4b51b5ab

Branch: refs/heads/master
Commit: 4b51b5ab2fe4dfaeffb22adf0e84477ba918aad5
Parents: 0d31de7
Author: Julian Hyde <jh...@apache.org>
Authored: Thu Sep 27 22:51:29 2018 -0400
Committer: Julian Hyde <jh...@apache.org>
Committed: Sun Oct 28 02:24:27 2018 -0700

----------------------------------------------------------------------
 .../org/apache/calcite/rex/RexSimplify.java     |  11 +-
 .../apache/calcite/runtime/SqlFunctions.java    |   7 +-
 .../calcite/sql/fun/SqlStdOperatorTable.java    |   8 +-
 .../apache/calcite/sql/test/SqlAdvisorTest.java |   4 +-
 .../apache/calcite/test/BookstoreSchema.java    |  41 +++----
 .../org/apache/calcite/test/RexProgramTest.java |   6 +-
 .../test/catalog/MockCatalogReaderDynamic.java  |   2 +-
 .../elasticsearch/ElasticsearchMethod.java      |   3 +-
 .../elasticsearch/ElasticsearchTable.java       |   4 +-
 .../adapter/geode/rel/AbstractGeodeTest.java    |   7 +-
 .../calcite/linq4j/tree/BlockBuilder.java       |   3 +-
 site/_data/contributors.yml                     |   2 +-
 site/_docs/adapter.md                           | 110 +++++++++----------
 site/_docs/model.md                             |  38 +++----
 site/_docs/reference.md                         |  12 +-
 site/downloads/index.md                         |   2 +-
 16 files changed, 128 insertions(+), 132 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite/blob/4b51b5ab/core/src/main/java/org/apache/calcite/rex/RexSimplify.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rex/RexSimplify.java b/core/src/main/java/org/apache/calcite/rex/RexSimplify.java
index 4ac6ed5..17946f2 100644
--- a/core/src/main/java/org/apache/calcite/rex/RexSimplify.java
+++ b/core/src/main/java/org/apache/calcite/rex/RexSimplify.java
@@ -927,12 +927,13 @@ public class RexSimplify {
 
   }
 
-  /** Analyzes a given {@link RexNode} and decides whenever its safe to unwind.
+  /** Analyzes a given {@link RexNode} and decides whenever it is safe to
+   * unwind.
   *
-  * CaseSafe means that it only contains a combination of known good operators.
+  * <p>"Safe" means that it only contains a combination of known good operators.
   *
-  * The division is an unsafe operator, consider:
-  * <pre>case when a &gt; 0 then 1/a else null end</pre>
+  * <p>Division is an unsafe operator; consider the following:
+  * <pre>case when a &gt; 0 then 1 / a else null end</pre>
   */
   static boolean isSafeExpression(RexNode r) {
     return r.accept(new SafeRexVisitor());
@@ -972,7 +973,7 @@ public class RexSimplify {
   /**
    * Generic boolean case simplification.
    *
-   * Rewrites:
+   * <p>Rewrites:
    * <pre>
    * CASE
    *   WHEN p1 THEN x

http://git-wip-us.apache.org/repos/asf/calcite/blob/4b51b5ab/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java b/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
index 02dbf30..837171b 100644
--- a/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
+++ b/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
@@ -2394,10 +2394,11 @@ public class SqlFunctions {
   }
 
   /**
-   * Implements the {@code .} (field access) operator on an object whose type is not known until
-   * runtime.
+   * Implements the {@code .} (field access) operator on an object
+   * whose type is not known until runtime.
    *
-   * A struct object can be represented in various ways by the runtime and depends on the
+   * <p>A struct object can be represented in various ways by the
+   * runtime and depends on the
    * {@link org.apache.calcite.adapter.enumerable.JavaRowFormat}.
    */
   @Experimental

http://git-wip-us.apache.org/repos/asf/calcite/blob/4b51b5ab/core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java b/core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java
index 9b00be3..827a516 100644
--- a/core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java
+++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java
@@ -1947,10 +1947,12 @@ public class SqlStdOperatorTable extends ReflectiveSqlOperatorTable {
       };
 
   /**
-   * The internal {@code $STRUCT_ACCESS} operator is used to access a field of a record.
+   * The internal {@code $STRUCT_ACCESS} operator is used to access a
+   * field of a record.
    *
-   * In contrast with {@link #DOT} operator it never appears in an {@link SqlNode} tree and allows
-   * to access fields by position and not by name.
+   * <p>In contrast with {@link #DOT} operator, it never appears in an
+   * {@link SqlNode} tree and allows to access fields by position and
+   * not by name.
    */
   public static final SqlInternalOperator STRUCT_ACCESS =
       new SqlInternalOperator("$STRUCT_ACCESS", SqlKind.OTHER);

http://git-wip-us.apache.org/repos/asf/calcite/blob/4b51b5ab/core/src/test/java/org/apache/calcite/sql/test/SqlAdvisorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/sql/test/SqlAdvisorTest.java b/core/src/test/java/org/apache/calcite/sql/test/SqlAdvisorTest.java
index 5b57d82..d7376c1 100644
--- a/core/src/test/java/org/apache/calcite/sql/test/SqlAdvisorTest.java
+++ b/core/src/test/java/org/apache/calcite/sql/test/SqlAdvisorTest.java
@@ -667,7 +667,7 @@ public class SqlAdvisorTest extends SqlValidatorTestCase {
     assertSimplify(sql, "SELECT ax _suggest_ FROM ( SELECT * FROM dummy a )");
   }
 
-  @Test public void testSimlifySubqueryStar() {
+  @Test public void testSimlifySubQueryStar() {
     String sql;
     sql = "select ax^ from (select (select * from dummy) axc from dummy a)";
     assertSimplify(sql,
@@ -691,7 +691,7 @@ public class SqlAdvisorTest extends SqlValidatorTestCase {
     assertSimplify(sql, "SELECT _suggest_ FROM ( SELECT a.x + b.y FROM dummy a , dummy b )");
   }
 
-  @Test public void testSimlifySubqueryMultipleFrom() {
+  @Test public void testSimlifySubQueryMultipleFrom() {
     String sql;
     // "dummy b" should be removed
     sql = "select axc from (select (select ^ from dummy) axc from dummy a), dummy b";

http://git-wip-us.apache.org/repos/asf/calcite/blob/4b51b5ab/core/src/test/java/org/apache/calcite/test/BookstoreSchema.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/BookstoreSchema.java b/core/src/test/java/org/apache/calcite/test/BookstoreSchema.java
index 16413cc..65ad112 100644
--- a/core/src/test/java/org/apache/calcite/test/BookstoreSchema.java
+++ b/core/src/test/java/org/apache/calcite/test/BookstoreSchema.java
@@ -24,56 +24,51 @@ import java.util.List;
 /**
  * A Schema representing a bookstore.
  *
- * It contains a single table with various levels/types of nesting, and is used mainly for testing
- * parts of code that rely on nested structures.
+ * <p>It contains a single table with various levels/types of nesting,
+ * and is used mainly for testing parts of code that rely on nested
+ * structures.
  *
- * New authors can be added but attention should be made to update appropriately tests that might
- * fail.
+ * <p>New authors can be added but attention should be made to update
+ * appropriately tests that might fail.
  *
- * The Schema is meant to be used with {@link org.apache.calcite.adapter.java.ReflectiveSchema} thus
- * all fields, and methods, should be public.
+ * <p>The Schema is meant to be used with
+ * {@link org.apache.calcite.adapter.java.ReflectiveSchema} thus all
+ * fields, and methods, should be public.
  */
 public final class BookstoreSchema {
 
   public final Author[] authors = {
-      new Author(
-          1,
+      new Author(1,
           "Victor Hugo",
           new Place(
               new Coordinate(BigDecimal.valueOf(47.24), BigDecimal.valueOf(6.02)),
               "Besançon",
               "France"),
           Collections.singletonList(
-              new Book(
-                  "Les Misérables",
+              new Book("Les Misérables",
                   1862,
                   Collections.singletonList(new Page(1, "Contents"))))),
-      new Author(
-          2,
+      new Author(2,
           "Nikos Kazantzakis",
-          new Place(new Coordinate(BigDecimal.valueOf(35.3387), BigDecimal.valueOf(25.1442)),
+          new Place(
+              new Coordinate(BigDecimal.valueOf(35.3387), BigDecimal.valueOf(25.1442)),
               "Heraklion",
               "Greece"),
           Arrays.asList(
-              new Book(
-                  "Zorba the Greek",
+              new Book("Zorba the Greek",
                   1946,
-                  Arrays.asList(
-                      new Page(1, "Contents"),
+                  Arrays.asList(new Page(1, "Contents"),
                       new Page(2, "Acknowledgements"))),
-              new Book(
-                  "The Last Temptation of Christ",
+              new Book("The Last Temptation of Christ",
                   1955,
                   Collections.singletonList(new Page(1, "Contents")))
           )),
-      new Author(
-          3,
+      new Author(3,
           "Homer",
           new Place(null,
               "Ionia",
               "Greece"),
-          Collections.emptyList()
-      )
+          Collections.emptyList())
   };
 
   /**

http://git-wip-us.apache.org/repos/asf/calcite/blob/4b51b5ab/core/src/test/java/org/apache/calcite/test/RexProgramTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/RexProgramTest.java b/core/src/test/java/org/apache/calcite/test/RexProgramTest.java
index 5d6b15a..7dddb71 100644
--- a/core/src/test/java/org/apache/calcite/test/RexProgramTest.java
+++ b/core/src/test/java/org/apache/calcite/test/RexProgramTest.java
@@ -1541,8 +1541,7 @@ public class RexProgramTest extends RexProgramBuilderBase {
             not(vBool(2)), not(vBool())),
         "AND(?0.bool3, null, IS NULL(?0.bool1),"
             + " IS NULL(?0.bool2), NOT(?0.bool0))",
-        "false"
-    );
+        "false");
   }
 
   @Test public void testSimplifyOrTerms() {
@@ -1617,8 +1616,7 @@ public class RexProgramTest extends RexProgramBuilderBase {
     checkSimplifyFilter(
         or(isNull(bRef),
             isNotFalse(bRef)),
-        "OR(IS NULL(?0.b), IS NOT FALSE(?0.b))"
-    );
+        "OR(IS NULL(?0.b), IS NOT FALSE(?0.b))");
 
     // multiple predicates are handled correctly
     checkSimplifyFilter(

http://git-wip-us.apache.org/repos/asf/calcite/blob/4b51b5ab/core/src/test/java/org/apache/calcite/test/catalog/MockCatalogReaderDynamic.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/catalog/MockCatalogReaderDynamic.java b/core/src/test/java/org/apache/calcite/test/catalog/MockCatalogReaderDynamic.java
index 2841df6..7a3660b 100644
--- a/core/src/test/java/org/apache/calcite/test/catalog/MockCatalogReaderDynamic.java
+++ b/core/src/test/java/org/apache/calcite/test/catalog/MockCatalogReaderDynamic.java
@@ -23,7 +23,7 @@ import org.apache.calcite.sql.type.SqlTypeName;
 /**
  * Registers dynamic tables.
  *
- * Non thread-safe.
+ * <p>Not thread-safe.
  */
 public class MockCatalogReaderDynamic extends MockCatalogReader {
   /**

http://git-wip-us.apache.org/repos/asf/calcite/blob/4b51b5ab/elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/ElasticsearchMethod.java
----------------------------------------------------------------------
diff --git a/elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/ElasticsearchMethod.java b/elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/ElasticsearchMethod.java
index 709156f..7c61345 100644
--- a/elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/ElasticsearchMethod.java
+++ b/elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/ElasticsearchMethod.java
@@ -36,8 +36,7 @@ enum ElasticsearchMethod {
       List.class, // groupBy
       List.class, // aggregations
       Long.class, // offset
-      Long.class // fetch
-      );
+      Long.class); // fetch
 
   public final Method method;
 

http://git-wip-us.apache.org/repos/asf/calcite/blob/4b51b5ab/elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/ElasticsearchTable.java
----------------------------------------------------------------------
diff --git a/elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/ElasticsearchTable.java b/elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/ElasticsearchTable.java
index f8cea1f..05f3136 100644
--- a/elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/ElasticsearchTable.java
+++ b/elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/ElasticsearchTable.java
@@ -176,8 +176,8 @@ public class ElasticsearchTable extends AbstractQueryableTable implements Transl
       ArrayNode sortNode = query.withArray("sort");
       sort.forEach(e ->
           sortNode.add(
-            mapper.createObjectNode().put(e.getKey(), e.getValue().isDescending() ? "desc" : "asc"))
-      );
+              mapper.createObjectNode().put(e.getKey(),
+                  e.getValue().isDescending() ? "desc" : "asc")));
     }
 
     if (offset != null) {

http://git-wip-us.apache.org/repos/asf/calcite/blob/4b51b5ab/geode/src/test/java/org/apache/calcite/adapter/geode/rel/AbstractGeodeTest.java
----------------------------------------------------------------------
diff --git a/geode/src/test/java/org/apache/calcite/adapter/geode/rel/AbstractGeodeTest.java b/geode/src/test/java/org/apache/calcite/adapter/geode/rel/AbstractGeodeTest.java
index 3f7b7f2..2f7ab9f 100644
--- a/geode/src/test/java/org/apache/calcite/adapter/geode/rel/AbstractGeodeTest.java
+++ b/geode/src/test/java/org/apache/calcite/adapter/geode/rel/AbstractGeodeTest.java
@@ -14,14 +14,15 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.calcite.adapter.geode.rel;
 
 import org.junit.ClassRule;
 
 /**
- * Base class which allows sharing same geode instance across all tests. Also due to legacy
- * reasons there can't be more than one Geode instance (running in parallel) for a single JVM.
+ * Base class that allows sharing same geode instance across all tests.
+ *
+ * <p>Also, due to legacy reasons, there can't be more than one Geode
+ * instance (running in parallel) for a single JVM.
  */
 public abstract class AbstractGeodeTest {
 

http://git-wip-us.apache.org/repos/asf/calcite/blob/4b51b5ab/linq4j/src/main/java/org/apache/calcite/linq4j/tree/BlockBuilder.java
----------------------------------------------------------------------
diff --git a/linq4j/src/main/java/org/apache/calcite/linq4j/tree/BlockBuilder.java b/linq4j/src/main/java/org/apache/calcite/linq4j/tree/BlockBuilder.java
index e59bc65..38668f0 100644
--- a/linq4j/src/main/java/org/apache/calcite/linq4j/tree/BlockBuilder.java
+++ b/linq4j/src/main/java/org/apache/calcite/linq4j/tree/BlockBuilder.java
@@ -133,8 +133,7 @@ public class BlockBuilder {
             ParameterExpression pe = Expressions.parameter(
                 declaration.parameter.type, newName);
             DeclarationStatement newDeclaration = Expressions.declare(
-                declaration.modifiers, pe, declaration.initializer
-            );
+                declaration.modifiers, pe, declaration.initializer);
             x = pe;
             add(newDeclaration);
           }

http://git-wip-us.apache.org/repos/asf/calcite/blob/4b51b5ab/site/_data/contributors.yml
----------------------------------------------------------------------
diff --git a/site/_data/contributors.yml b/site/_data/contributors.yml
index 82a860e..1e6fcfc 100644
--- a/site/_data/contributors.yml
+++ b/site/_data/contributors.yml
@@ -31,7 +31,7 @@
 - name: Andrei Sereda
   apacheId: sereda
   githubId: asereda-gs
-  org: 
+  org:
   role: Committer
 - name: Ashutosh Chauhan
   apacheId: hashutosh

http://git-wip-us.apache.org/repos/asf/calcite/blob/4b51b5ab/site/_docs/adapter.md
----------------------------------------------------------------------
diff --git a/site/_docs/adapter.md b/site/_docs/adapter.md
index 7e50a7a..20a7703 100644
--- a/site/_docs/adapter.md
+++ b/site/_docs/adapter.md
@@ -93,15 +93,15 @@ as implemented by Avatica's
 | <a href="{{ site.apiRoot }}/org/apache/calcite/config/CalciteConnectionProperty.html#LEX">lex</a> | Lexical policy. Values are ORACLE (default), MYSQL, MYSQL_ANSI, SQL_SERVER, JAVA.
 | <a href="{{ site.apiRoot }}/org/apache/calcite/config/CalciteConnectionProperty.html#MATERIALIZATIONS_ENABLED">materializationsEnabled</a> | Whether Calcite should use materializations. Default false.
 | <a href="{{ site.apiRoot }}/org/apache/calcite/config/CalciteConnectionProperty.html#MODEL">model</a> | URI of the JSON/YAML model file or inline like `inline:{...}` for JSON and `inline:...` for YAML.
-| <a href="{{ site.apiRoot }}/org/apache/calcite/config/CalciteConnectionProperty.html#PARSER_FACTORY">parserFactory</a> | Parser factory. The name of a class that implements [<tt>interface SqlParserImplFactory</tt>]({{ site.apiRoot }}/org/apache/calcite/sql/parser/SqlParserImplFactory.html) and has a public default constructor or an `INSTANCE` constant.
+| <a href="{{ site.apiRoot }}/org/apache/calcite/config/CalciteConnectionProperty.html#PARSER_FACTORY">parserFactory</a> | Parser factory. The name of a class that implements [<code>interface SqlParserImplFactory</code>]({{ site.apiRoot }}/org/apache/calcite/sql/parser/SqlParserImplFactory.html) and has a public default constructor or an `INSTANCE` constant.
 | <a href="{{ site.apiRoot }}/org/apache/calcite/config/CalciteConnectionProperty.html#QUOTING">quoting</a> | How identifiers are quoted. Values are DOUBLE_QUOTE, BACK_QUOTE, BRACKET. If not specified, value from `lex` is used.
 | <a href="{{ site.apiRoot }}/org/apache/calcite/config/CalciteConnectionProperty.html#QUOTED_CASING">quotedCasing</a> | How identifiers are stored if they are quoted. Values are UNCHANGED, TO_UPPER, TO_LOWER. If not specified, value from `lex` is used.
 | <a href="{{ site.apiRoot }}/org/apache/calcite/config/CalciteConnectionProperty.html#SCHEMA">schema</a> | Name of initial schema.
-| <a href="{{ site.apiRoot }}/org/apache/calcite/config/CalciteConnectionProperty.html#SCHEMA_FACTORY">schemaFactory</a> | Schema factory. The name of a class that implements [<tt>interface SchemaFactory</tt>]({{ site.apiRoot }}/org/apache/calcite/schema/SchemaFactory.html) and has a public default constructor or an `INSTANCE` constant. Ignored if `model` is specified.
+| <a href="{{ site.apiRoot }}/org/apache/calcite/config/CalciteConnectionProperty.html#SCHEMA_FACTORY">schemaFactory</a> | Schema factory. The name of a class that implements [<code>interface SchemaFactory</code>]({{ site.apiRoot }}/org/apache/calcite/schema/SchemaFactory.html) and has a public default constructor or an `INSTANCE` constant. Ignored if `model` is specified.
 | <a href="{{ site.apiRoot }}/org/apache/calcite/config/CalciteConnectionProperty.html#SCHEMA_TYPE">schemaType</a> | Schema type. Value must be "MAP" (the default), "JDBC", or "CUSTOM" (implicit if `schemaFactory` is specified). Ignored if `model` is specified.
 | <a href="{{ site.apiRoot }}/org/apache/calcite/config/CalciteConnectionProperty.html#SPARK">spark</a> | Specifies whether Spark should be used as the engine for processing that cannot be pushed to the source system. If false (the default), Calcite generates code that implements the Enumerable interface.
 | <a href="{{ site.apiRoot }}/org/apache/calcite/config/CalciteConnectionProperty.html#TIME_ZONE">timeZone</a> | Time zone, for example "gmt-3". Default is the JVM's time zone.
-| <a href="{{ site.apiRoot }}/org/apache/calcite/config/CalciteConnectionProperty.html#TYPE_SYSTEM">typeSystem</a> | Type system. The name of a class that implements [<tt>interface RelDataTypeSystem</tt>]({{ site.apiRoot }}/org/apache/calcite/rel/type/RelDataTypeSystem.html) and has a public default constructor or an `INSTANCE` constant.
+| <a href="{{ site.apiRoot }}/org/apache/calcite/config/CalciteConnectionProperty.html#TYPE_SYSTEM">typeSystem</a> | Type system. The name of a class that implements [<code>interface RelDataTypeSystem</code>]({{ site.apiRoot }}/org/apache/calcite/rel/type/RelDataTypeSystem.html) and has a public default constructor or an `INSTANCE` constant.
 | <a href="{{ site.apiRoot }}/org/apache/calcite/config/CalciteConnectionProperty.html#UNQUOTED_CASING">unquotedCasing</a> | How identifiers are stored if they are not quoted. Values are UNCHANGED, TO_UPPER, TO_LOWER. If not specified, value from `lex` is used.
 
 To make a connection to a single schema based on a built-in schema type, you don't need to specify
@@ -201,7 +201,7 @@ into your project.
 At present, the repository is not persisted. As you execute DDL commands, you
 are modifying an in-memory repository by adding and removing objects
 reachable from a root
-[<tt>Schema</tt>]({{ site.apiRoot }}/org/apache/calcite/schema/Schema.html).
+[<code>Schema</code>]({{ site.apiRoot }}/org/apache/calcite/schema/Schema.html).
 All commands within the same SQL session will see those objects.
 You can create the same objects in a future session by executing the same
 script of SQL commands.
@@ -235,14 +235,14 @@ arguments, resolving overloaded functions, or deriving the return type.
 
 It you want that flexibility, you probably need to write you a
 *user-defined operator*
-(see [<tt>interface SqlOperator</tt>]({{ site.apiRoot }}/org/apache/calcite/sql/SqlOperator.html)).
+(see [<code>interface SqlOperator</code>]({{ site.apiRoot }}/org/apache/calcite/sql/SqlOperator.html)).
 
 If your operator does not adhere to standard SQL function syntax,
 "`f(arg1, arg2, ...)`", then you need to
 [extend the parser](#extending-the-parser).
 
 There are many good examples in the tests:
-[<tt>class UdfTest</tt>]({{ site.sourceRoot }}/core/src/test/java/org/apache/calcite/test/UdfTest.java)
+[<code>class UdfTest</code>]({{ site.sourceRoot }}/core/src/test/java/org/apache/calcite/test/UdfTest.java)
 tests user-defined functions and user-defined aggregate functions.
 
 ### Aggregate functions
@@ -335,7 +335,7 @@ Grouped window functions are functions that operate the `GROUP BY` clause
 to gather together records into sets. The built-in grouped window functions
 are `HOP`, `TUMBLE` and `SESSION`.
 You can define additional functions by implementing
-[<tt>interface SqlGroupedWindowFunction</tt>]({{ site.apiRoot }}/org/apache/calcite/sql/fun/SqlGroupedWindowFunction.html).
+[<code>interface SqlGroupedWindowFunction</code>]({{ site.apiRoot }}/org/apache/calcite/sql/fun/SqlGroupedWindowFunction.html).
 
 ### Table functions and table macros
 
@@ -355,7 +355,7 @@ Table macros are invoked during query preparation and the relational expression
 they produce can then be optimized.
 (Calcite's implementation of views uses table macros.)
 
-[<tt>class TableFunctionTest</tt>]({{ site.sourceRoot }}/core/src/test/java/org/apache/calcite/test/TableFunctionTest.java)
+[<code>class TableFunctionTest</code>]({{ site.sourceRoot }}/core/src/test/java/org/apache/calcite/test/TableFunctionTest.java)
 tests table functions and contains several useful examples.
 
 ### Extending the parser
@@ -378,39 +378,39 @@ The `calcite-server` module, which was created in
 [[CALCITE-707](https://issues.apache.org/jira/browse/CALCITE-707)] and
 adds DDL statements such as `CREATE TABLE`, is an example that you could follow.
 Also see
-[<tt>class ExtensionSqlParserTest</tt>]({{ site.sourceRoot }}/core/src/test/java/org/apache/calcite/sql/parser/parserextensiontesting/ExtensionSqlParserTest.java).
+[<code>class ExtensionSqlParserTest</code>]({{ site.sourceRoot }}/core/src/test/java/org/apache/calcite/sql/parser/parserextensiontesting/ExtensionSqlParserTest.java).
 
 ### Customizing SQL dialect accepted and generated
 
 To customize what SQL extensions the parser should accept, implement
-[<tt>interface SqlConformance</tt>]({{ site.apiRoot }}/org/apache/calcite/sql/validate/SqlConformance.html)
+[<code>interface SqlConformance</code>]({{ site.apiRoot }}/org/apache/calcite/sql/validate/SqlConformance.html)
 or use one of the built-in values in
-[<tt>enum SqlConformanceEnum</tt>]({{ site.apiRoot }}/org/apache/calcite/sql/validate/SqlConformanceEnum.html).
+[<code>enum SqlConformanceEnum</code>]({{ site.apiRoot }}/org/apache/calcite/sql/validate/SqlConformanceEnum.html).
 
 To control how SQL is generated for an external database (usually via the JDBC
 adapter), use
-[<tt>class SqlDialect</tt>]({{ site.apiRoot }}/org/apache/calcite/sql/SqlDialect.html).
+[<code>class SqlDialect</code>]({{ site.apiRoot }}/org/apache/calcite/sql/SqlDialect.html).
 The dialect also describes the engine's capabilities, such as whether it
 supports `OFFSET` and `FETCH` clauses.
 
 ### Defining a custom schema
 
 To define a custom schema, you need to implement
-[<tt>interface SchemaFactory</tt>]({{ site.apiRoot }}/org/apache/calcite/schema/SchemaFactory.html).
+[<code>interface SchemaFactory</code>]({{ site.apiRoot }}/org/apache/calcite/schema/SchemaFactory.html).
 
 During query preparation, Calcite will call this interface to find out
 what tables and sub-schemas your schema contains. When a table in your schema
 is referenced in a query, Calcite will ask your schema to create an instance of
-[<tt>interface Table</tt>]({{ site.apiRoot }}/org/apache/calcite/schema/Table.html).
+[<code>interface Table</code>]({{ site.apiRoot }}/org/apache/calcite/schema/Table.html).
 
 That table will be wrapped in a
-[<tt>TableScan</tt>]({{ site.apiRoot }}/org/apache/calcite/rel/core/TableScan.html)
+[<code>TableScan</code>]({{ site.apiRoot }}/org/apache/calcite/rel/core/TableScan.html)
 and will undergo the query optimization process.
 
 ### Reflective schema
 
 A reflective schema
-([<tt>class ReflectiveSchema</tt>]({{ site.apiRoot }}/org/apache/calcite/adapter/java/ReflectiveSchema.html))
+([<code>class ReflectiveSchema</code>]({{ site.apiRoot }}/org/apache/calcite/adapter/java/ReflectiveSchema.html))
 is a way of wrapping a Java object so that it appears
 as a schema. Its collection-valued fields will appear as tables.
 
@@ -418,12 +418,12 @@ It is not a schema factory but an actual schema; you have to create the object
 and wrap it in the schema by calling APIs.
 
 See
-[<tt>class ReflectiveSchemaTest</tt>]({{ site.sourceRoot }}/core/src/test/java/org/apache/calcite/test/ReflectiveSchemaTest.java).
+[<code>class ReflectiveSchemaTest</code>]({{ site.sourceRoot }}/core/src/test/java/org/apache/calcite/test/ReflectiveSchemaTest.java).
 
 ### Defining a custom table
 
 To define a custom table, you need to implement
-[<tt>interface TableFactory</tt>]({{ site.apiRoot }}/org/apache/calcite/schema/TableFactory.html).
+[<code>interface TableFactory</code>]({{ site.apiRoot }}/org/apache/calcite/schema/TableFactory.html).
 Whereas a schema factory a set of named tables, a table factory produces a
 single table when bound to a schema with a particular name (and optionally a
 set of extra operands).
@@ -432,25 +432,25 @@ set of extra operands).
 
 If your table is to support DML operations (INSERT, UPDATE, DELETE, MERGE),
 your implementation of `interface Table` must implement
-[<tt>interface ModifiableTable</tt>]({{ site.apiRoot }}/org/apache/calcite/schema/ModifiableTable.html).
+[<code>interface ModifiableTable</code>]({{ site.apiRoot }}/org/apache/calcite/schema/ModifiableTable.html).
 
 ### Streaming
 
 If your table is to support streaming queries,
 your implementation of `interface Table` must implement
-[<tt>interface StreamableTable</tt>]({{ site.apiRoot }}/org/apache/calcite/schema/StreamableTable.html).
+[<code>interface StreamableTable</code>]({{ site.apiRoot }}/org/apache/calcite/schema/StreamableTable.html).
 
 See
-[<tt>class StreamTest</tt>]({{ site.sourceRoot }}/core/src/test/java/org/apache/calcite/test/StreamTest.java)
+[<code>class StreamTest</code>]({{ site.sourceRoot }}/core/src/test/java/org/apache/calcite/test/StreamTest.java)
 for examples.
 
 ### Pushing operations down to your table
 
 If you wish to push processing down to your custom table's source system,
 consider implementing either
-[<tt>interface FilterableTable</tt>]({{ site.apiRoot }}/org/apache/calcite/schema/FilterableTable.html)
+[<code>interface FilterableTable</code>]({{ site.apiRoot }}/org/apache/calcite/schema/FilterableTable.html)
 or
-[<tt>interface ProjectableFilterableTable</tt>]({{ site.apiRoot }}/org/apache/calcite/schema/ProjectableFilterableTable.html).
+[<code>interface ProjectableFilterableTable</code>]({{ site.apiRoot }}/org/apache/calcite/schema/ProjectableFilterableTable.html).
 
 If you want more control, you should write a [planner rule](#planner-rule).
 This will allow you to push down expressions, to make a cost-based decision
@@ -460,36 +460,36 @@ such as join, aggregation, and sort.
 ### Type system
 
 You can customize some aspects of the type system by implementing
-[<tt>interface RelDataTypeSystem</tt>]({{ site.apiRoot }}/org/apache/calcite/rel/type/RelDataTypeSystem.html).
+[<code>interface RelDataTypeSystem</code>]({{ site.apiRoot }}/org/apache/calcite/rel/type/RelDataTypeSystem.html).
 
 ### Relational operators
 
 All relational operators implement
-[<tt>interface RelNode</tt>]({{ site.apiRoot }}/org/apache/calcite/rel/RelNode.html)
+[<code>interface RelNode</code>]({{ site.apiRoot }}/org/apache/calcite/rel/RelNode.html)
 and most extend
-[<tt>class AbstractRelNode</tt>]({{ site.apiRoot }}/org/apache/calcite/rel/AbstractRelNode.html).
+[<code>class AbstractRelNode</code>]({{ site.apiRoot }}/org/apache/calcite/rel/AbstractRelNode.html).
 The core operators (used by
-[<tt>SqlToRelConverter</tt>]({{ site.apiRoot }}/org/apache/calcite/sql2rel/SqlToRelConverter.html)
+[<code>SqlToRelConverter</code>]({{ site.apiRoot }}/org/apache/calcite/sql2rel/SqlToRelConverter.html)
 and covering conventional relational algebra) are
-[<tt>TableScan</tt>]({{ site.apiRoot }}/org/apache/calcite/rel/core/TableScan.html),
-[<tt>TableModify</tt>]({{ site.apiRoot }}/org/apache/calcite/rel/core/TableModify.html),
-[<tt>Values</tt>]({{ site.apiRoot }}/org/apache/calcite/rel/core/Values.html),
-[<tt>Project</tt>]({{ site.apiRoot }}/org/apache/calcite/rel/core/Project.html),
-[<tt>Filter</tt>]({{ site.apiRoot }}/org/apache/calcite/rel/core/Filter.html),
-[<tt>Aggregate</tt>]({{ site.apiRoot }}/org/apache/calcite/rel/core/Aggregate.html),
-[<tt>Join</tt>]({{ site.apiRoot }}/org/apache/calcite/rel/core/Join.html),
-[<tt>Sort</tt>]({{ site.apiRoot }}/org/apache/calcite/rel/core/Sort.html),
-[<tt>Union</tt>]({{ site.apiRoot }}/org/apache/calcite/rel/core/Union.html),
-[<tt>Intersect</tt>]({{ site.apiRoot }}/org/apache/calcite/rel/core/Intersect.html),
-[<tt>Minus</tt>]({{ site.apiRoot }}/org/apache/calcite/rel/core/Minus.html),
-[<tt>Window</tt>]({{ site.apiRoot }}/org/apache/calcite/rel/core/Window.html) and
-[<tt>Match</tt>]({{ site.apiRoot }}/org/apache/calcite/rel/core/Match.html).
+[<code>TableScan</code>]({{ site.apiRoot }}/org/apache/calcite/rel/core/TableScan.html),
+[<code>TableModify</code>]({{ site.apiRoot }}/org/apache/calcite/rel/core/TableModify.html),
+[<code>Values</code>]({{ site.apiRoot }}/org/apache/calcite/rel/core/Values.html),
+[<code>Project</code>]({{ site.apiRoot }}/org/apache/calcite/rel/core/Project.html),
+[<code>Filter</code>]({{ site.apiRoot }}/org/apache/calcite/rel/core/Filter.html),
+[<code>Aggregate</code>]({{ site.apiRoot }}/org/apache/calcite/rel/core/Aggregate.html),
+[<code>Join</code>]({{ site.apiRoot }}/org/apache/calcite/rel/core/Join.html),
+[<code>Sort</code>]({{ site.apiRoot }}/org/apache/calcite/rel/core/Sort.html),
+[<code>Union</code>]({{ site.apiRoot }}/org/apache/calcite/rel/core/Union.html),
+[<code>Intersect</code>]({{ site.apiRoot }}/org/apache/calcite/rel/core/Intersect.html),
+[<code>Minus</code>]({{ site.apiRoot }}/org/apache/calcite/rel/core/Minus.html),
+[<code>Window</code>]({{ site.apiRoot }}/org/apache/calcite/rel/core/Window.html) and
+[<code>Match</code>]({{ site.apiRoot }}/org/apache/calcite/rel/core/Match.html).
 
 Each of these has a "pure" logical sub-class,
-[<tt>LogicalProject</tt>]({{ site.apiRoot }}/org/apache/calcite/rel/logical/LogicalProject.html)
+[<code>LogicalProject</code>]({{ site.apiRoot }}/org/apache/calcite/rel/logical/LogicalProject.html)
 and so forth. Any given adapter will have counterparts for the operations that
 its engine can implement efficiently; for example, the Cassandra adapter has
-[<tt>CassandraProject</tt>]({{ site.apiRoot }}/org/apache/calcite/rel/cassandra/CassandraProject.html)
+[<code>CassandraProject</code>]({{ site.apiRoot }}/org/apache/calcite/rel/cassandra/CassandraProject.html)
 but there is no `CassandraJoin`.
 
 You can define your own sub-class of `RelNode` to add a new operator, or
@@ -511,7 +511,7 @@ operators with no extra work.
 ### Planner rule
 
 A planner rule
-([<tt>class RelOptRule</tt>]({{ site.apiRoot }}/org/apache/calcite/plan/RelOptRule.html))
+([<code>class RelOptRule</code>]({{ site.apiRoot }}/org/apache/calcite/plan/RelOptRule.html))
 transforms a relational expression into an equivalent relational expression.
 
 A planner engine has many planner rules registered and fires them
@@ -522,9 +522,9 @@ firing rules in a sequence that produces an optimal plan, but each individual
 rules only concerns itself with correctness.
 
 Calcite has two built-in planner engines:
-[<tt>class VolcanoPlanner</tt>]({{ site.apiRoot }}/org/apache/calcite/plan/volcano/VolcanoPlanner.html)
+[<code>class VolcanoPlanner</code>]({{ site.apiRoot }}/org/apache/calcite/plan/volcano/VolcanoPlanner.html)
 uses dynamic programming and is good for exhaustive search, whereas
-[<tt>class HepPlanner</tt>]({{ site.apiRoot }}/org/apache/calcite/plan/hep/HepPlanner.html)
+[<code>class HepPlanner</code>]({{ site.apiRoot }}/org/apache/calcite/plan/hep/HepPlanner.html)
 fires a sequence of rules in a more fixed order.
 
 ### Calling conventions
@@ -537,7 +537,7 @@ to another.
 
 If data needs to be converted from one calling convention to another, Calcite
 uses a special sub-class of relational expression called a converter
-(see [<tt>class Converter</tt>]({{ site.apiRoot }}/org/apache/calcite/rel/convert/Converter.html)).
+(see [<code>class Converter</code>]({{ site.apiRoot }}/org/apache/calcite/rel/convert/Converter.html)).
 But of course converting data has a runtime cost.
 
 When planning a query that uses multiple engines, Calcite "colors" regions of
@@ -548,15 +548,15 @@ operation can occur in more than one place, and ultimately the best plan is
 chosen according to cost.
 
 A calling convention is a class that implements
-[<tt>interface Convention</tt>]({{ site.apiRoot }}/org/apache/calcite/plan/Convention.html),
+[<code>interface Convention</code>]({{ site.apiRoot }}/org/apache/calcite/plan/Convention.html),
 an auxiliary interface (for instance
-[<tt>interface CassandraRel</tt>]({{ site.apiRoot }}/org/apache/calcite/adapter/cassandra/CassandraRel.html)),
+[<code>interface CassandraRel</code>]({{ site.apiRoot }}/org/apache/calcite/adapter/cassandra/CassandraRel.html)),
 and a set of sub-classes of
-[<tt>class RelNode</tt>]({{ site.apiRoot }}/org/apache/calcite/rel/RelNode.html)
+[<code>class RelNode</code>]({{ site.apiRoot }}/org/apache/calcite/rel/RelNode.html)
 that implement that interface for the core relational operators
-([<tt>Project</tt>]({{ site.apiRoot }}/org/apache/calcite/rel/core/Project.html),
-[<tt>Filter</tt>]({{ site.apiRoot }}/org/apache/calcite/rel/core/Filter.html),
-[<tt>Aggregate</tt>]({{ site.apiRoot }}/org/apache/calcite/rel/core/Aggregate.html),
+([<code>Project</code>]({{ site.apiRoot }}/org/apache/calcite/rel/core/Project.html),
+[<code>Filter</code>]({{ site.apiRoot }}/org/apache/calcite/rel/core/Filter.html),
+[<code>Aggregate</code>]({{ site.apiRoot }}/org/apache/calcite/rel/core/Aggregate.html),
 and so forth).
 
 ### Built-in SQL implementation
@@ -565,7 +565,7 @@ How does Calcite implement SQL, if an adapter does not implement all of the core
 relational operators?
 
 The answer is a particular built-in calling convention,
-[<tt>EnumerableConvention</tt>]({{ site.apiRoot }}/org/apache/calcite/adapter/EnumerableConvention.html).
+[<code>EnumerableConvention</code>]({{ site.apiRoot }}/org/apache/calcite/adapter/EnumerableConvention.html).
 Relational expressions of enumerable convention are implemented as "built-ins":
 Calcite generates Java code, compiles it, and executes inside its own JVM.
 Enumerable convention is less efficient than, say, a distributed engine
@@ -580,9 +580,9 @@ Calcite has a metadata system that allow you to define cost functions and
 statistics about relational operators, collectively referred to as *metadata*.
 Each kind of metadata has an interface with (usually) one method.
 For example, selectivity is defined by
-[<tt>interface RelMdSelectivity</tt>]({{ site.apiRoot }}/org/apache/calcite/rel/metadata/RelMdSelectivity.html)
+[<code>interface RelMdSelectivity</code>]({{ site.apiRoot }}/org/apache/calcite/rel/metadata/RelMdSelectivity.html)
 and the method
-[<tt>getSelectivity(RelNode rel, RexNode predicate)</tt>]({{ site.apiRoot }}/org/apache/calcite/rel/metadata/RelMetadataQuery.html#getSelectivity-org.apache.calcite.rel.RelNode-org.apache.calcite.rex.RexNode-).
+[<code>getSelectivity(RelNode rel, RexNode predicate)</code>]({{ site.apiRoot }}/org/apache/calcite/rel/metadata/RelMetadataQuery.html#getSelectivity-org.apache.calcite.rel.RelNode-org.apache.calcite.rex.RexNode-).
 
 There are many built-in kinds of metadata, including
 [collation]({{ site.apiRoot }}/org/apache/calcite/rel/metadata/RelMdCollation.html),

http://git-wip-us.apache.org/repos/asf/calcite/blob/4b51b5ab/site/_docs/model.md
----------------------------------------------------------------------
diff --git a/site/_docs/model.md b/site/_docs/model.md
index 01fa9b2..2628174 100644
--- a/site/_docs/model.md
+++ b/site/_docs/model.md
@@ -44,7 +44,7 @@ Models can also be built programmatically using the `Schema` SPI.
 {% highlight yaml %}
 version: 1.0
 defaultSchema: mongo
-schemas: 
+schemas:
 - [Schema...]
 {% endhighlight %}
 
@@ -73,10 +73,10 @@ Occurs within `root.schemas`.
 #### YAML
 {% highlight yaml %}
 name: foodmart
-path: 
+path:
   lib
 cache: true
-materializations: 
+materializations:
 - [ Materialization... ]
 {% endhighlight %}
 
@@ -100,7 +100,7 @@ strings. For example,
 
 #### YAML
 {% highlight yaml %}
-path: 
+path:
 - [usr, lib]
 - lib
 {% endhighlight %}
@@ -138,7 +138,7 @@ immediately, and are never flushed.
 
 Like base class <a href="#schema">Schema</a>, occurs within `root.schemas`.
 
-#### JSON 
+#### JSON
 {% highlight json %}
 {
   name: 'foodmart',
@@ -153,11 +153,11 @@ Like base class <a href="#schema">Schema</a>, occurs within `root.schemas`.
 {% highlight yaml %}
 name: foodmart
 type: map
-tables: 
+tables:
 - [ Table... ]
-functions: 
+functions:
 - [ Function... ]
-types: 
+types:
 - [ Type... ]
 {% endhighlight %}
 
@@ -194,7 +194,7 @@ Like base class <a href="#schema">Schema</a>, occurs within `root.schemas`.
 name: mongo
 type: custom
 factory: org.apache.calcite.adapter.mongodb.MongoSchemaFactory
-operand: 
+operand:
   host: localhost
   database: test
 {% endhighlight %}
@@ -303,7 +303,7 @@ Occurs within `root.schemas.tables`.
 #### YAML
 {% highlight yaml %}
 name: sales_fact
-columns: 
+columns:
   [ Column... ]
 {% endhighlight %}
 
@@ -393,7 +393,7 @@ Like base class <a href="#table">Table</a>, occurs within `root.schemas.tables`.
 name: female_emps
 type: custom
 factory: TODO
-operand: 
+operand:
   todo: TODO
 {% endhighlight %}
 
@@ -469,7 +469,7 @@ Occurs within `root.schemas.functions`.
 name: MY_PLUS
 className: com.example.functions.MyPlusFunction
 methodName: apply
-path: {}  
+path: {}
 {% endhighlight %}
 
 `name` (required string) is the name of this function.
@@ -516,7 +516,7 @@ Occurs within `root.schemas.types`.
 {% highlight yaml %}
 name: mytype1
 type: BIGINT
-attributes:  
+attributes:
 - name: f1
   type: BIGINT
 {% endhighlight %}
@@ -577,11 +577,11 @@ auto: false
 algorithm: true
 algorithmMaxMillis: 10000
 rowCountEstimate: 86837
-defaultMeasures: 
+defaultMeasures:
 - agg: count
-tiles: 
-- dimensions: [ 'the_year', ['t', 'quarter'] ] 
-  measures: 
+tiles:
+- dimensions: [ 'the_year', ['t', 'quarter'] ]
+  measures:
   - agg: sum
     args: unit_sales
   - agg: sum
@@ -663,8 +663,8 @@ Occurs within `root.schemas.lattices.tiles`.
 
 #### YAML
 {% highlight yaml %}
-dimensions: [ 'the_year', ['t', 'quarter'] ] 
-measures: 
+dimensions: [ 'the_year', ['t', 'quarter'] ]
+measures:
 - agg: sum
   args: unit_sales
 - agg: sum

http://git-wip-us.apache.org/repos/asf/calcite/blob/4b51b5ab/site/_docs/reference.md
----------------------------------------------------------------------
diff --git a/site/_docs/reference.md b/site/_docs/reference.md
index e76e7d6..81d21c3 100644
--- a/site/_docs/reference.md
+++ b/site/_docs/reference.md
@@ -1031,18 +1031,18 @@ for example `ST_GeomFromText('POINT (30 10)')`.
 | Data type   | Type code | Examples in WKT
 |:----------- |:--------- |:---------------------
 | GEOMETRY           |  0 | generalization of Point, Curve, Surface, GEOMETRYCOLLECTION
-| POINT              |  1 | <tt>ST_GeomFromText(&#8203;'POINT (30 10)')</tt> is a point in 2D space; <tt>ST_GeomFromText(&#8203;'POINT Z(30 10 2)')</tt> is point in 3D space
+| POINT              |  1 | <code>ST_GeomFromText(&#8203;'POINT (30 10)')</code> is a point in 2D space; <code>ST_GeomFromText(&#8203;'POINT Z(30 10 2)')</code> is point in 3D space
 | CURVE            | 13 | generalization of LINESTRING
-| LINESTRING         |  2 | <tt>ST_GeomFromText(&#8203;'LINESTRING (30 10, 10 30, 40 40)')</tt>
+| LINESTRING         |  2 | <code>ST_GeomFromText(&#8203;'LINESTRING (30 10, 10 30, 40 40)')</code>
 | SURFACE            | 14 | generalization of Polygon, PolyhedralSurface
-| POLYGON            |  3 | <tt>ST_GeomFromText(&#8203;'POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))')</tt> is a pentagon; <tt>ST_GeomFromText(&#8203;'POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10), (20 30, 35 35, 30 20, 20 30))')</tt> is a pentagon with a quadrilateral hole
+| POLYGON            |  3 | <code>ST_GeomFromText(&#8203;'POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))')</code> is a pentagon; <code>ST_GeomFromText(&#8203;'POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10), (20 30, 35 35, 30 20, 20 30))')</code> is a pentagon with a quadrilateral hole
 | POLYHEDRALSURFACE  | 15 |
 | GEOMETRYCOLLECTION |  7 | a collection of zero or more GEOMETRY instances; a generalization of MULTIPOINT, MULTILINESTRING, MULTIPOLYGON
-| MULTIPOINT         |  4 | <tt>ST_GeomFromText(&#8203;'MULTIPOINT ((10 40), (40 30), (20 20), (30 10))')</tt> is equivalent to <tt>ST_GeomFromText(&#8203;'MULTIPOINT (10 40, 40 30, 20 20, 30 10)')</tt>
+| MULTIPOINT         |  4 | <code>ST_GeomFromText(&#8203;'MULTIPOINT ((10 40), (40 30), (20 20), (30 10))')</code> is equivalent to <code>ST_GeomFromText(&#8203;'MULTIPOINT (10 40, 40 30, 20 20, 30 10)')</code>
 | MULTICURVE         |  - | generalization of MULTILINESTRING
-| MULTILINESTRING    |  5 | <tt>ST_GeomFromText(&#8203;'MULTILINESTRING ((10 10, 20 20, 10 40), (40 40, 30 30, 40 20, 30 10))')</tt>
+| MULTILINESTRING    |  5 | <code>ST_GeomFromText(&#8203;'MULTILINESTRING ((10 10, 20 20, 10 40), (40 40, 30 30, 40 20, 30 10))')</code>
 | MULTISURFACE       |  - | generalization of MULTIPOLYGON
-| MULTIPOLYGON       |  6 | <tt>ST_GeomFromText(&#8203;'MULTIPOLYGON (((30 20, 45 40, 10 40, 30 20)), ((15 5, 40 10, 10 20, 5 10, 15 5)))')</tt>
+| MULTIPOLYGON       |  6 | <code>ST_GeomFromText(&#8203;'MULTIPOLYGON (((30 20, 45 40, 10 40, 30 20)), ((15 5, 40 10, 10 20, 5 10, 15 5)))')</code>
 
 ## Operators and functions
 

http://git-wip-us.apache.org/repos/asf/calcite/blob/4b51b5ab/site/downloads/index.md
----------------------------------------------------------------------
diff --git a/site/downloads/index.md b/site/downloads/index.md
index abe874a..bceb2db 100644
--- a/site/downloads/index.md
+++ b/site/downloads/index.md
@@ -74,7 +74,7 @@ Choose a source distribution in either *tar* or *zip* format.
 
 For fast downloads, current source distributions are hosted on mirror servers;
 older source distributions are in the
-[archive](https://archive.apache.org/dist/calcite/) 
+[archive](https://archive.apache.org/dist/calcite/)
 or [incubator archive](https://archive.apache.org/dist/incubator/calcite/).
 If a download from a mirror fails, retry, and the second download will likely
 succeed.