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 2016/12/14 16:42:46 UTC

[3/3] calcite git commit: [CALCITE-1519] Standardize on "sub-query" rather than "subquery" in class names and comments

[CALCITE-1519] Standardize on "sub-query" rather than "subquery" in class names and comments

There are lots of backward-compatible changes (e.g. leaving the old
name but deprecated) but the following changes are breaking (albeit
to APIs not widely used):
* public interface SubqueryConverter becomes SubQueryConverter
* public enum RelOptUtil.SubqueryType becomes SubQueryType
* public void SqlPrettyWriter.setSubqueryStyle() becomes setSubQueryStyle
* public void SqlToRelConverter.setSubqueryConverter() becomes setSubQueryConverter
* public boolean SqlToRelConverter.canConvertSubquery() becomes canConvertSubQuery
* public boolean SqlToRelConverter.convertSubquery() becomes convertSubQuery
* public SqlToRelConverter.Config.getInSubqueryThreshold() becomes getInSubQueryThreshold


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

Branch: refs/heads/master
Commit: e38d51e8f4e61e32213aaeb39790e58069f718a4
Parents: 1ccebc8
Author: Julian Hyde <jh...@apache.org>
Authored: Wed Nov 30 15:21:51 2016 -0800
Committer: Julian Hyde <jh...@apache.org>
Committed: Tue Dec 13 20:07:08 2016 -0800

----------------------------------------------------------------------
 core/src/main/codegen/templates/Parser.jj       | 144 +++---
 .../org/apache/calcite/plan/RelOptUtil.java     |  12 +-
 .../org/apache/calcite/prepare/Prepare.java     |   2 +-
 .../org/apache/calcite/rel/core/Sample.java     |   2 +-
 .../apache/calcite/runtime/CalciteResource.java |   4 +-
 .../java/org/apache/calcite/sql/SqlKind.java    |   2 +-
 .../org/apache/calcite/sql/SqlOperator.java     |   2 +-
 .../java/org/apache/calcite/sql/SqlSelect.java  |   6 +-
 .../java/org/apache/calcite/sql/SqlWriter.java  |   8 +-
 .../calcite/sql/advise/SqlSimpleParser.java     |  26 +-
 .../apache/calcite/sql/fun/SqlInOperator.java   |   4 +-
 .../calcite/sql/fun/SqlStdOperatorTable.java    |   4 +-
 .../sql/parser/SqlAbstractParserImpl.java       |  12 +-
 .../calcite/sql/pretty/SqlPrettyWriter.java     |  24 +-
 .../calcite/sql/validate/SelectNamespace.java   |   2 +-
 .../calcite/sql/validate/SqlValidatorImpl.java  |  48 +-
 .../sql/validate/SqlValidatorNamespace.java     |   4 +-
 .../apache/calcite/sql2rel/RelDecorrelator.java |   8 +-
 .../calcite/sql2rel/SqlToRelConverter.java      | 203 ++++----
 .../calcite/sql2rel/SubQueryConverter.java      |  53 ++
 .../calcite/sql2rel/SubqueryConverter.java      |  52 --
 .../java/org/apache/calcite/tools/Programs.java |   9 +-
 .../calcite/runtime/CalciteResource.properties  |   2 +-
 .../calcite/sql/parser/SqlParserTest.java       |  12 +-
 .../apache/calcite/sql/test/SqlAdvisorTest.java |  14 +-
 .../calcite/sql/test/SqlOperatorBaseTest.java   |   4 +-
 .../calcite/sql/test/SqlPrettyWriterTest.java   |   4 +-
 .../apache/calcite/test/JdbcAdapterTest.java    |   5 +-
 .../java/org/apache/calcite/test/JdbcTest.java  |   6 +-
 .../apache/calcite/test/RelOptRulesTest.java    |   3 +-
 .../calcite/test/SqlToRelConverterTest.java     |   5 +-
 .../apache/calcite/test/SqlValidatorTest.java   |  25 +-
 .../calcite/sql/test/SqlPrettyWriterTest.xml    |   2 +-
 core/src/test/resources/sql/misc.iq             |   6 +-
 core/src/test/resources/sql/sub-query.iq        | 513 +++++++++++++++++++
 core/src/test/resources/sql/subquery.iq         | 513 -------------------
 .../java/org/apache/calcite/test/CsvTest.java   |  13 +-
 .../calcite/adapter/mongodb/MongoRules.java     |   2 +-
 site/_docs/history.md                           |   4 +-
 39 files changed, 894 insertions(+), 870 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite/blob/e38d51e8/core/src/main/codegen/templates/Parser.jj
----------------------------------------------------------------------
diff --git a/core/src/main/codegen/templates/Parser.jj b/core/src/main/codegen/templates/Parser.jj
index bf03c10..4a0bc46 100644
--- a/core/src/main/codegen/templates/Parser.jj
+++ b/core/src/main/codegen/templates/Parser.jj
@@ -345,11 +345,11 @@ JAVACODE List startList(Object o)
  * to keep query expressions (SELECT, UNION, etc) separate from row expressions
  * (+, LIKE, etc).  However, this is not possible with an LL(k) parser, because
  * both kinds of expressions allow parenthesization, so no fixed amount of left
- * context is ever good enough.  A subquery can be a leaf in a row expression,
+ * context is ever good enough.  A sub-query can be a leaf in a row expression,
  * and can include operators like UNION, so it's not even possible to use a
  * syntactic lookahead rule like "look past an indefinite number of parentheses
  * until you see SELECT, VALUES, or TABLE" (since at that point we still
- * don't know whether we're parsing a subquery like ((select ...) + x)
+ * don't know whether we're parsing a sub-query like ((select ...) + x)
  * vs. (select ... union select ...).
  *
  * The somewhat messy solution is to unify the two kinds of expression,
@@ -389,8 +389,8 @@ JAVACODE SqlParserPos getPos()
 JAVACODE void checkQueryExpression(ExprContext exprContext)
 {
     switch (exprContext) {
-    case ACCEPT_NONQUERY:
-    case ACCEPT_SUBQUERY:
+    case ACCEPT_NON_QUERY:
+    case ACCEPT_SUB_QUERY:
     case ACCEPT_CURSOR:
         throw SqlUtil.newContextException(getPos(),
             RESOURCE.illegalQueryExpression());
@@ -710,9 +710,9 @@ SqlNode ParenthesizedExpression(ExprContext exprContext) :
     <LPAREN>
     {
         // we've now seen left paren, so queries inside should
-        // be allowed as subqueries
+        // be allowed as sub-queries
         switch (exprContext) {
-        case ACCEPT_SUBQUERY:
+        case ACCEPT_SUB_QUERY:
             exprContext = ExprContext.ACCEPT_NONCURSOR;
             break;
         case ACCEPT_CURSOR:
@@ -739,7 +739,7 @@ SqlNode ParenthesizedExpression(ExprContext exprContext) :
  *
  * <code>WHERE x IN ((select count(*) from t where c=d),5)</code>,
  *
- * which is a legal use of a subquery.  The only way to fix the hole is to be
+ * which is a legal use of a sub-query.  The only way to fix the hole is to be
  * able to remember whether a subexpression was parenthesized or not, which
  * means preserving parentheses in the SqlNode tree.  This is probably
  * desirable anyway for use in purely syntactic parsing applications (e.g. SQL
@@ -759,10 +759,10 @@ SqlNodeList ParenthesizedQueryOrCommaList(
     <LPAREN>
     {
         // we've now seen left paren, so a query by itself should
-        // be interpreted as a subquery
+        // be interpreted as a sub-query
         pos = getPos();
         switch (exprContext) {
-        case ACCEPT_SUBQUERY:
+        case ACCEPT_SUB_QUERY:
             firstExprContext = ExprContext.ACCEPT_NONCURSOR;
             break;
         case ACCEPT_CURSOR:
@@ -836,9 +836,9 @@ void Arg0(List list, ExprContext exprContext) :
     final ExprContext firstExprContext;
     {
         // we've now seen left paren, so queries inside should
-        // be allowed as subqueries
+        // be allowed as sub-queries
         switch (exprContext) {
-        case ACCEPT_SUBQUERY:
+        case ACCEPT_SUB_QUERY:
             firstExprContext = ExprContext.ACCEPT_NONCURSOR;
             break;
         case ACCEPT_CURSOR:
@@ -1221,7 +1221,7 @@ SqlNode SqlProcedureCall() :
     }
     routineCall = NamedRoutineCall(
         SqlFunctionCategory.USER_DEFINED_PROCEDURE,
-        ExprContext.ACCEPT_SUBQUERY)
+        ExprContext.ACCEPT_SUB_QUERY)
     {
         return SqlStdOperatorTable.PROCEDURE_CALL.createCall(
             callPos, routineCall);
@@ -1366,7 +1366,7 @@ SqlNode SqlUpdate() :
     {
         targetColumnList.add(id);
     }
-    <EQ> exp = Expression(ExprContext.ACCEPT_SUBQUERY)
+    <EQ> exp = Expression(ExprContext.ACCEPT_SUB_QUERY)
     {
         // TODO:  support DEFAULT also
         sourceExpressionList.add(exp);
@@ -1377,7 +1377,7 @@ SqlNode SqlUpdate() :
         {
             targetColumnList.add(id);
         }
-        <EQ> exp = Expression(ExprContext.ACCEPT_SUBQUERY)
+        <EQ> exp = Expression(ExprContext.ACCEPT_SUB_QUERY)
         {
             sourceExpressionList.add(exp);
         }
@@ -1418,7 +1418,7 @@ SqlNode SqlMerge() :
 
     <USING> sourceTableRef = TableRef()
 
-    <ON> condition = Expression(ExprContext.ACCEPT_SUBQUERY)
+    <ON> condition = Expression(ExprContext.ACCEPT_SUB_QUERY)
 
     (
     LOOKAHEAD(2)
@@ -1450,7 +1450,7 @@ SqlUpdate WhenMatchedClause(SqlNode table, SqlIdentifier alias) :
         updateExprList = new SqlNodeList(pos);
         updateColumnList.add(id);
     }
-    <EQ> exp = Expression(ExprContext.ACCEPT_SUBQUERY)
+    <EQ> exp = Expression(ExprContext.ACCEPT_SUB_QUERY)
     {
         updateExprList.add(exp);
     }
@@ -1460,7 +1460,7 @@ SqlUpdate WhenMatchedClause(SqlNode table, SqlIdentifier alias) :
         {
             updateColumnList.add(id);
         }
-        <EQ> exp = Expression(ExprContext.ACCEPT_SUBQUERY)
+        <EQ> exp = Expression(ExprContext.ACCEPT_SUB_QUERY)
         {
             updateExprList.add(exp);
         }
@@ -1559,7 +1559,7 @@ SqlNode SelectExpression() :
         return SqlIdentifier.star(getPos());
     }
     |
-    e = Expression(ExprContext.ACCEPT_SUBQUERY)
+    e = Expression(ExprContext.ACCEPT_SUB_QUERY)
     {
         return e;
     }
@@ -1613,7 +1613,7 @@ SqlNode JoinTable(SqlNode e) :
     e2 = TableRef()
     (
         <ON> { pos = getPos(); }
-        condition = Expression(ExprContext.ACCEPT_SUBQUERY) {
+        condition = Expression(ExprContext.ACCEPT_SUB_QUERY) {
             SqlParserPos onPos = pos.plus(getPos());
             return new SqlJoin(joinType.getParserPosition(),
                 e,
@@ -1682,7 +1682,7 @@ SqlNode FromClause() :
         e2 = TableRef()
         (
             <ON> { pos = getPos(); }
-            condition = Expression(ExprContext.ACCEPT_SUBQUERY) {
+            condition = Expression(ExprContext.ACCEPT_SUB_QUERY) {
                 SqlParserPos onPos = pos.plus(getPos());
                 e = new SqlJoin(joinType.getParserPosition(),
                     e,
@@ -1837,7 +1837,7 @@ SqlNode TableRef2(boolean lateral) :
         }
     |
         <UNNEST> { pos = getPos(); }
-        args = ParenthesizedQueryOrCommaList(ExprContext.ACCEPT_SUBQUERY)
+        args = ParenthesizedQueryOrCommaList(ExprContext.ACCEPT_SUB_QUERY)
         [
             <WITH> <ORDINALITY> {
                 unnestOp = SqlStdOperatorTable.UNNEST_WITH_ORDINALITY;
@@ -2107,7 +2107,7 @@ SqlNode RowConstructor() :
     )
     {
         // REVIEW jvs 8-Feb-2004: Should we discriminate between scalar
-        // subqueries inside of ROW and row subqueries?  The standard does,
+        // sub-queries inside of ROW and row sub-queries?  The standard does,
         // but the distinction seems to be purely syntactic.
         return SqlStdOperatorTable.ROW.createCall(pos, valueList.toArray());
     }
@@ -2121,7 +2121,7 @@ SqlNode WhereOpt() :
     SqlNode condition;
 }
 {
-    <WHERE> condition = Expression(ExprContext.ACCEPT_SUBQUERY)
+    <WHERE> condition = Expression(ExprContext.ACCEPT_SUB_QUERY)
     {
         return condition;
     }
@@ -2178,12 +2178,12 @@ SqlNode GroupingElement() :
         return SqlStdOperatorTable.GROUPING_SETS.createCall(pos, list);
     }
 |   <ROLLUP> { pos = getPos(); }
-    <LPAREN> nlist = ExpressionCommaList(pos, ExprContext.ACCEPT_SUBQUERY)
+    <LPAREN> nlist = ExpressionCommaList(pos, ExprContext.ACCEPT_SUB_QUERY)
     <RPAREN> {
         return SqlStdOperatorTable.ROLLUP.createCall(nlist);
     }
 |   <CUBE> { pos = getPos(); }
-    <LPAREN> nlist = ExpressionCommaList(pos, ExprContext.ACCEPT_SUBQUERY)
+    <LPAREN> nlist = ExpressionCommaList(pos, ExprContext.ACCEPT_SUB_QUERY)
     <RPAREN> {
         return SqlStdOperatorTable.CUBE.createCall(nlist);
     }
@@ -2191,7 +2191,7 @@ SqlNode GroupingElement() :
     <LPAREN> <RPAREN> {
         return new SqlNodeList(getPos());
     }
-|   e = Expression(ExprContext.ACCEPT_SUBQUERY) {
+|   e = Expression(ExprContext.ACCEPT_SUB_QUERY) {
         return e;
     }
 }
@@ -2219,7 +2219,7 @@ SqlNodeList ExpressionCommaList(
         // NOTE jvs 6-Feb-2004:  See comments at top of file for why
         // hint is necessary here.
         LOOKAHEAD(2)
-        <COMMA> e = Expression(ExprContext.ACCEPT_SUBQUERY)
+        <COMMA> e = Expression(ExprContext.ACCEPT_SUB_QUERY)
         {
             list.add(e);
             pos = pos.plus(getPos());
@@ -2238,7 +2238,7 @@ SqlNode HavingOpt() :
     SqlNode e;
 }
 {
-    <HAVING> e = Expression(ExprContext.ACCEPT_SUBQUERY)
+    <HAVING> e = Expression(ExprContext.ACCEPT_SUB_QUERY)
     {
         return e;
     }
@@ -2311,7 +2311,7 @@ SqlWindow WindowSpecification() :
         <PARTITION>
         { pos = getPos(); }
         <BY>
-        partitionList = ExpressionCommaList(pos, ExprContext.ACCEPT_NONQUERY)
+        partitionList = ExpressionCommaList(pos, ExprContext.ACCEPT_NON_QUERY)
         |
         { partitionList = SqlNodeList.EMPTY; }
     )
@@ -2381,7 +2381,7 @@ SqlNode WindowRange() :
         }
     )
     |
-    e = Expression(ExprContext.ACCEPT_NONQUERY)
+    e = Expression(ExprContext.ACCEPT_NON_QUERY)
     (
         <PRECEDING>
         {
@@ -2437,7 +2437,7 @@ SqlNode OrderItem() :
     SqlNode e;
 }
 {
-    e = Expression(ExprContext.ACCEPT_SUBQUERY)
+    e = Expression(ExprContext.ACCEPT_SUB_QUERY)
     (
         <ASC>
     |   <DESC> {
@@ -2470,7 +2470,7 @@ SqlNode SqlExpressionEof() :
     SqlNode e;
 }
 {
-    e = Expression(ExprContext.ACCEPT_SUBQUERY) (<EOF>)
+    e = Expression(ExprContext.ACCEPT_SUB_QUERY) (<EOF>)
     {
         return e;
     }
@@ -2710,7 +2710,7 @@ List<Object> Expression2(ExprContext exprContext) :
                         <ASYMMETRIC>
                     ]
                 )
-                e = Expression3(ExprContext.ACCEPT_SUBQUERY)
+                e = Expression3(ExprContext.ACCEPT_SUB_QUERY)
                 {
                     list.add(new SqlParserUtil.ToTreeListItem(op, pos));
                     list.add(e);
@@ -2732,14 +2732,14 @@ List<Object> Expression2(ExprContext exprContext) :
                 |
                     <SIMILAR> <TO> { op = SqlStdOperatorTable.SIMILAR_TO; }
                 )
-                list2 = Expression2(ExprContext.ACCEPT_SUBQUERY)
+                list2 = Expression2(ExprContext.ACCEPT_SUB_QUERY)
                 {
                     list.add(new SqlParserUtil.ToTreeListItem(op, pos));
                     list.addAll(list2);
                 }
                 [
                     LOOKAHEAD(2)
-                    <ESCAPE> e = Expression3(ExprContext.ACCEPT_SUBQUERY)
+                    <ESCAPE> e = Expression3(ExprContext.ACCEPT_SUB_QUERY)
                     {
                         pos = getPos();
                         list.add(
@@ -2754,10 +2754,10 @@ List<Object> Expression2(ExprContext exprContext) :
                     checkNonQueryExpression(exprContext);
                     list.add(new SqlParserUtil.ToTreeListItem(op, getPos()));
                 }
-                Expression2b(ExprContext.ACCEPT_SUBQUERY, list)
+                Expression2b(ExprContext.ACCEPT_SUB_QUERY, list)
             |
                 <LBRACKET>
-                e = Expression(ExprContext.ACCEPT_SUBQUERY)
+                e = Expression(ExprContext.ACCEPT_SUB_QUERY)
                 <RBRACKET>
                 {
                     list.add(
@@ -2965,23 +2965,23 @@ SqlNode CaseExpression() :
         pos = getPos();
     }
     [
-        caseIdentifier = Expression(ExprContext.ACCEPT_SUBQUERY)
+        caseIdentifier = Expression(ExprContext.ACCEPT_SUB_QUERY)
     ]
     (
         <WHEN>
         { whenPos = getPos(); }
-        e = ExpressionCommaList(pos, ExprContext.ACCEPT_SUBQUERY)
+        e = ExpressionCommaList(pos, ExprContext.ACCEPT_SUB_QUERY)
         {
             if (((SqlNodeList) e).size() == 1) {
                 e = ((SqlNodeList) e).get(0);
             }
             whenList.add(e);
         }
-        <THEN> e = Expression(ExprContext.ACCEPT_SUBQUERY)
+        <THEN> e = Expression(ExprContext.ACCEPT_SUB_QUERY)
         {  thenPos = getPos(); thenList.add(e); }
     ) +
     [
-        <ELSE> elseClause = Expression(ExprContext.ACCEPT_SUBQUERY)
+        <ELSE> elseClause = Expression(ExprContext.ACCEPT_SUB_QUERY)
     ]
     <END>
     {
@@ -3447,9 +3447,9 @@ SqlNode MultisetConstructor() :
     |
         // by enumeration "MULTISET[e0, e1, ..., eN]"
         <LBRACKET> // TODO: do trigraph as well ??( ??)
-        e = Expression(ExprContext.ACCEPT_NONQUERY) { args = startList(e); }
+        e = Expression(ExprContext.ACCEPT_NON_QUERY) { args = startList(e); }
         (
-            <COMMA> e = Expression(ExprContext.ACCEPT_NONQUERY) { args.add(e); }
+            <COMMA> e = Expression(ExprContext.ACCEPT_NON_QUERY) { args.add(e); }
         ) *
         <RBRACKET>
         {
@@ -3482,7 +3482,7 @@ SqlNode ArrayConstructor() :
         // by enumeration "ARRAY[e0, e1, ..., eN]"
         <LBRACKET> // TODO: do trigraph as well ??( ??)
         (
-            args = ExpressionCommaList(pos, ExprContext.ACCEPT_NONQUERY)
+            args = ExpressionCommaList(pos, ExprContext.ACCEPT_NON_QUERY)
         |
             { args = new SqlNodeList(getPos()); }
         )
@@ -3517,7 +3517,7 @@ SqlNode MapConstructor() :
         // by enumeration "MAP[k0, v0, ..., kN, vN]"
         <LBRACKET> // TODO: do trigraph as well ??( ??)
         (
-            args = ExpressionCommaList(pos, ExprContext.ACCEPT_NONQUERY)
+            args = ExpressionCommaList(pos, ExprContext.ACCEPT_NON_QUERY)
         |
             { args = new SqlNodeList(getPos()); }
         )
@@ -3879,7 +3879,7 @@ SqlNode NewSpecification() :
     routineCall =
     NamedRoutineCall(
         SqlFunctionCategory.USER_DEFINED_CONSTRUCTOR,
-        ExprContext.ACCEPT_SUBQUERY)
+        ExprContext.ACCEPT_SUB_QUERY)
     {
         return SqlStdOperatorTable.NEW.createCall(callPos, routineCall);
     }
@@ -4216,7 +4216,7 @@ SqlNode BuiltinFunctionCall() :
         {
             pos = getPos();
         }
-        <LPAREN> e = Expression(ExprContext.ACCEPT_SUBQUERY) { args = startList(e); }
+        <LPAREN> e = Expression(ExprContext.ACCEPT_SUB_QUERY) { args = startList(e); }
         <AS>
         (
             dt = DataType() { args.add(dt); }
@@ -4239,7 +4239,7 @@ SqlNode BuiltinFunctionCall() :
         unit = TimeUnit()
         { args = startList(new SqlIntervalQualifier(unit, null, getPos())); }
         <FROM>
-        e = Expression(ExprContext.ACCEPT_SUBQUERY) { args.add(e); }
+        e = Expression(ExprContext.ACCEPT_SUB_QUERY) { args.add(e); }
         <RPAREN>
         {
             return SqlStdOperatorTable.EXTRACT.createCall(
@@ -4254,14 +4254,14 @@ SqlNode BuiltinFunctionCall() :
         }
         <LPAREN>
         // FIXME jvs 31-Aug-2006:  FRG-192:  This should be
-        // Expression(ExprContext.ACCEPT_SUBQUERY), but that doesn't work
+        // Expression(ExprContext.ACCEPT_SUB_QUERY), but that doesn't work
         // because it matches the other kind of IN.
         e = AtomicRowExpression() { args = startList(e); }
         <IN>
-        e = Expression(ExprContext.ACCEPT_SUBQUERY) { args.add(e);}
+        e = Expression(ExprContext.ACCEPT_SUB_QUERY) { args.add(e);}
         [
             <FROM>
-            e = Expression(ExprContext.ACCEPT_SUBQUERY) { args.add(e); }
+            e = Expression(ExprContext.ACCEPT_SUB_QUERY) { args.add(e); }
         ]
         <RPAREN>
         {
@@ -4276,7 +4276,7 @@ SqlNode BuiltinFunctionCall() :
             pos = getPos();
         }
         <LPAREN>
-        e = Expression(ExprContext.ACCEPT_SUBQUERY)
+        e = Expression(ExprContext.ACCEPT_SUB_QUERY)
         {
             args = startList(e);
         }
@@ -4298,7 +4298,7 @@ SqlNode BuiltinFunctionCall() :
             pos = getPos();
         }
         <LPAREN>
-        e = Expression(ExprContext.ACCEPT_SUBQUERY)
+        e = Expression(ExprContext.ACCEPT_SUB_QUERY)
         {
             args = startList(e);
         }
@@ -4313,7 +4313,7 @@ SqlNode BuiltinFunctionCall() :
             }
         |
             (
-                <COMMA> e = Expression(ExprContext.ACCEPT_SUBQUERY) {
+                <COMMA> e = Expression(ExprContext.ACCEPT_SUB_QUERY) {
                     args.add(e);
                 }
             )*
@@ -4330,23 +4330,23 @@ SqlNode BuiltinFunctionCall() :
             pos = getPos();
         }
         <LPAREN>
-        e = Expression(ExprContext.ACCEPT_SUBQUERY)
+        e = Expression(ExprContext.ACCEPT_SUB_QUERY)
         {
             args = startList(e);
         }
         <PLACING>
-        e = Expression(ExprContext.ACCEPT_SUBQUERY)
+        e = Expression(ExprContext.ACCEPT_SUB_QUERY)
         {
             args.add(e);
         }
         <FROM>
-        e = Expression(ExprContext.ACCEPT_SUBQUERY)
+        e = Expression(ExprContext.ACCEPT_SUB_QUERY)
         {
             args.add(e);
         }
         [
             <FOR>
-            e = Expression(ExprContext.ACCEPT_SUBQUERY)
+            e = Expression(ExprContext.ACCEPT_SUB_QUERY)
             {
                 args.add(e);
             }
@@ -4376,14 +4376,14 @@ SqlNode BuiltinFunctionCall() :
             pos = getPos();
         }
         <LPAREN>
-        e = Expression(ExprContext.ACCEPT_SUBQUERY)
+        e = Expression(ExprContext.ACCEPT_SUB_QUERY)
         { args = startList(e); }
         ( <FROM> | <COMMA>)
-        e = Expression(ExprContext.ACCEPT_SUBQUERY)
+        e = Expression(ExprContext.ACCEPT_SUB_QUERY)
         { args.add(e); }
         [
             (<FOR> | <COMMA>)
-            e = Expression(ExprContext.ACCEPT_SUBQUERY)
+            e = Expression(ExprContext.ACCEPT_SUB_QUERY)
             { args.add(e); }
         ]
         <RPAREN>
@@ -4422,7 +4422,7 @@ SqlNode BuiltinFunctionCall() :
                     flag = SqlTrimFunction.Flag.LEADING.symbol(pos);
                 }
             ]
-            [ trimChars = Expression(ExprContext.ACCEPT_SUBQUERY) ]
+            [ trimChars = Expression(ExprContext.ACCEPT_SUB_QUERY) ]
             (
                 <FROM>
                 {
@@ -4446,7 +4446,7 @@ SqlNode BuiltinFunctionCall() :
                 }
             )
         ]
-        e = Expression(ExprContext.ACCEPT_SUBQUERY)
+        e = Expression(ExprContext.ACCEPT_SUB_QUERY)
         {
             if (flag == null) {
                 flag = SqlTrimFunction.Flag.BOTH.symbol(SqlParserPos.ZERO);
@@ -4489,9 +4489,9 @@ SqlCall TimestampAddFunctionCall() :
         args = startList(SqlLiteral.createSymbol(interval, getPos()));
     }
     <COMMA>
-    e = Expression(ExprContext.ACCEPT_SUBQUERY) { args.add(e); }
+    e = Expression(ExprContext.ACCEPT_SUB_QUERY) { args.add(e); }
     <COMMA>
-    e = Expression(ExprContext.ACCEPT_SUBQUERY) { args.add(e); }
+    e = Expression(ExprContext.ACCEPT_SUB_QUERY) { args.add(e); }
     <RPAREN> {
         return SqlStdOperatorTable.TIMESTAMP_ADD.createCall(
             pos.plus(getPos()), SqlParserUtil.toNodeArray(args));
@@ -4518,9 +4518,9 @@ SqlCall TimestampDiffFunctionCall() :
         args = startList(SqlLiteral.createSymbol(interval, getPos()));
     }
     <COMMA>
-    e = Expression(ExprContext.ACCEPT_SUBQUERY) { args.add(e); }
+    e = Expression(ExprContext.ACCEPT_SUB_QUERY) { args.add(e); }
     <COMMA>
-    e = Expression(ExprContext.ACCEPT_SUBQUERY) { args.add(e); }
+    e = Expression(ExprContext.ACCEPT_SUB_QUERY) { args.add(e); }
     <RPAREN> {
         return SqlStdOperatorTable.TIMESTAMP_DIFF.createCall(
             pos.plus(getPos()), SqlParserUtil.toNodeArray(args));
@@ -4578,7 +4578,7 @@ SqlNode NamedFunctionCall() :
                 args = Collections.emptyList();
                 pos = pos.plus(getPos());
             }
-            | args = FunctionParameterList(ExprContext.ACCEPT_SUBQUERY)
+            | args = FunctionParameterList(ExprContext.ACCEPT_SUB_QUERY)
             {
                 pos = pos.plus(getPos());
                 quantifier = (SqlLiteral) args.get(0);
@@ -4589,7 +4589,7 @@ SqlNode NamedFunctionCall() :
             <FILTER> { filterPos = getPos(); }
             <LPAREN>
             <WHERE>
-            filter = Expression(ExprContext.ACCEPT_SUBQUERY)
+            filter = Expression(ExprContext.ACCEPT_SUB_QUERY)
             <RPAREN>  { filterPos = filterPos.plus(getPos()); }
         ]
         [
@@ -4637,7 +4637,7 @@ SqlNode StandardFloorCeilOptions(SqlParserPos pos, boolean floorFlag) :
     boolean over = false;
 }
 {
-    <LPAREN> e = Expression(ExprContext.ACCEPT_SUBQUERY) {
+    <LPAREN> e = Expression(ExprContext.ACCEPT_SUB_QUERY) {
         args = startList(e);
     }
     (
@@ -4820,7 +4820,7 @@ SqlNode JdbcFunctionCall() :
     |
         <CONVERT> { name = unquotedIdentifier(); }
         <LPAREN>
-        e = Expression(ExprContext.ACCEPT_SUBQUERY) {
+        e = Expression(ExprContext.ACCEPT_SUB_QUERY) {
             args = new SqlNodeList(getPos());
             args.add(e);
         }
@@ -4851,7 +4851,7 @@ SqlNode JdbcFunctionCall() :
         |
             LOOKAHEAD(2) <LPAREN> <RPAREN> { args = new SqlNodeList(pos); }
         |
-            args = ParenthesizedQueryOrCommaList(ExprContext.ACCEPT_SUBQUERY)
+            args = ParenthesizedQueryOrCommaList(ExprContext.ACCEPT_SUB_QUERY)
         )
     )
     <RBRACE> {

http://git-wip-us.apache.org/repos/asf/calcite/blob/e38d51e8/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java b/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java
index b03c544..bf24a41 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java
@@ -442,7 +442,7 @@ public abstract class RelOptUtil {
       assert extraExpr == rexBuilder.makeLiteral(true);
 
       // this should only be called for the exists case
-      // first stick an Agg on top of the subquery
+      // first stick an Agg on top of the sub-query
       // agg does not like no agg functions so just pretend it is
       // doing a min(TRUE)
 
@@ -474,7 +474,7 @@ public abstract class RelOptUtil {
    *
    * @param seekRel    A query rel, for example the resulting rel from 'select *
    *                   from emp' or 'values (1,2,3)' or '('Foo', 34)'.
-   * @param subqueryType Sub-query type
+   * @param subQueryType Sub-query type
    * @param logic  Whether to use 2- or 3-valued boolean logic
    * @param notIn Whether the operator is NOT IN
    *
@@ -485,10 +485,10 @@ public abstract class RelOptUtil {
    */
   public static Exists createExistsPlan(
       RelNode seekRel,
-      SubqueryType subqueryType,
+      SubQueryType subQueryType,
       Logic logic,
       boolean notIn) {
-    switch (subqueryType) {
+    switch (subQueryType) {
     case SCALAR:
       return new Exists(seekRel, false, true);
     }
@@ -516,7 +516,7 @@ public abstract class RelOptUtil {
 
     // for IN/NOT IN, it needs to output the fields
     final List<RexNode> exprs = new ArrayList<>();
-    if (subqueryType == SubqueryType.IN) {
+    if (subQueryType == SubQueryType.IN) {
       for (int i = 0; i < keyCount; i++) {
         exprs.add(rexBuilder.makeInputRef(ret, i));
       }
@@ -3628,7 +3628,7 @@ public abstract class RelOptUtil {
   }
 
   /** What kind of sub-query. */
-  public enum SubqueryType {
+  public enum SubQueryType {
     EXISTS,
     IN,
     SCALAR

http://git-wip-us.apache.org/repos/asf/calcite/blob/e38d51e8/core/src/main/java/org/apache/calcite/prepare/Prepare.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/prepare/Prepare.java b/core/src/main/java/org/apache/calcite/prepare/Prepare.java
index aa4ba8b..b5ceec8 100644
--- a/core/src/main/java/org/apache/calcite/prepare/Prepare.java
+++ b/core/src/main/java/org/apache/calcite/prepare/Prepare.java
@@ -268,7 +268,7 @@ public abstract class Prepare {
     root = root.withRel(flattenTypes(root.rel, true));
 
     if (this.context.config().forceDecorrelate()) {
-      // Subquery decorrelation.
+      // Sub-query decorrelation.
       root = root.withRel(decorrelate(sqlToRelConverter, sqlQuery, root.rel));
     }
 

http://git-wip-us.apache.org/repos/asf/calcite/blob/e38d51e8/core/src/main/java/org/apache/calcite/rel/core/Sample.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/core/Sample.java b/core/src/main/java/org/apache/calcite/rel/core/Sample.java
index e22e0de..9005001 100644
--- a/core/src/main/java/org/apache/calcite/rel/core/Sample.java
+++ b/core/src/main/java/org/apache/calcite/rel/core/Sample.java
@@ -31,7 +31,7 @@ import java.util.List;
  * Relational expression that returns a sample of the rows from its input.
  *
  * <p>In SQL, a sample is expressed using the {@code TABLESAMPLE BERNOULLI} or
- * {@code SYSTEM} keyword applied to a table, view or subquery.
+ * {@code SYSTEM} keyword applied to a table, view or sub-query.
  */
 public class Sample extends SingleRel {
   //~ Instance fields --------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/calcite/blob/e38d51e8/core/src/main/java/org/apache/calcite/runtime/CalciteResource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/runtime/CalciteResource.java b/core/src/main/java/org/apache/calcite/runtime/CalciteResource.java
index da3e519..77a6bf9 100644
--- a/core/src/main/java/org/apache/calcite/runtime/CalciteResource.java
+++ b/core/src/main/java/org/apache/calcite/runtime/CalciteResource.java
@@ -413,8 +413,8 @@ public interface CalciteResource {
   @BaseMessage("The {0} function does not support the {1} data type.")
   ExInst<SqlValidatorException> minMaxBadType(String a0, String a1);
 
-  @BaseMessage("Only scalar subqueries allowed in select list.")
-  ExInst<SqlValidatorException> onlyScalarSubqueryAllowed();
+  @BaseMessage("Only scalar sub-queries allowed in select list.")
+  ExInst<SqlValidatorException> onlyScalarSubQueryAllowed();
 
   @BaseMessage("Ordinal out of range")
   ExInst<SqlValidatorException> orderByOrdinalOutOfRange();

http://git-wip-us.apache.org/repos/asf/calcite/blob/e38d51e8/core/src/main/java/org/apache/calcite/sql/SqlKind.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlKind.java b/core/src/main/java/org/apache/calcite/sql/SqlKind.java
index 3300f00..2f6b5fd 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlKind.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlKind.java
@@ -419,7 +419,7 @@ public enum SqlKind {
   EXPLICIT_TABLE,
 
   /**
-   * Scalar query; that is, a subquery used in an expression context, and
+   * Scalar query; that is, a sub-query used in an expression context, and
    * returning one row and one column.
    */
   SCALAR_QUERY,

http://git-wip-us.apache.org/repos/asf/calcite/blob/e38d51e8/core/src/main/java/org/apache/calcite/sql/SqlOperator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlOperator.java b/core/src/main/java/org/apache/calcite/sql/SqlOperator.java
index 3d84004..d558fce 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlOperator.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlOperator.java
@@ -900,7 +900,7 @@ public abstract class SqlOperator {
    * be scalar (as opposed to a query).
    *
    * <p>If true (the default), the validator will attempt to convert the
-   * argument into a scalar subquery, which must have one column and return at
+   * argument into a scalar sub-query, which must have one column and return at
    * most one row.
    *
    * <p>Operators such as <code>SELECT</code> and <code>EXISTS</code> override

http://git-wip-us.apache.org/repos/asf/calcite/blob/e38d51e8/core/src/main/java/org/apache/calcite/sql/SqlSelect.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlSelect.java b/core/src/main/java/org/apache/calcite/sql/SqlSelect.java
index c054763..bb847bc 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlSelect.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlSelect.java
@@ -208,11 +208,11 @@ public class SqlSelect extends SqlCall {
     validator.validateQuery(this, scope, validator.getUnknownType());
   }
 
-  // Override SqlCall, to introduce a subquery frame.
+  // Override SqlCall, to introduce a sub-query frame.
   @Override public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
     if (!writer.inQuery()) {
-      // If this SELECT is the topmost item in a subquery, introduce a new
-      // frame. (The topmost item in the subquery might be a UNION or
+      // If this SELECT is the topmost item in a sub-query, introduce a new
+      // frame. (The topmost item in the sub-query might be a UNION or
       // ORDER. In this case, we don't need a wrapper frame.)
       final SqlWriter.Frame frame =
           writer.startList(SqlWriter.FrameTypeEnum.SUB_QUERY, "(", ")");

http://git-wip-us.apache.org/repos/asf/calcite/blob/e38d51e8/core/src/main/java/org/apache/calcite/sql/SqlWriter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlWriter.java b/core/src/main/java/org/apache/calcite/sql/SqlWriter.java
index bd961ae..3d09138 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlWriter.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlWriter.java
@@ -28,11 +28,11 @@ public interface SqlWriter {
   //~ Enums ------------------------------------------------------------------
 
   /**
-   * Style of formatting subqueries.
+   * Style of formatting sub-queries.
    */
-  enum SubqueryStyle {
+  enum SubQueryStyle {
     /**
-     * Julian's style of subquery nesting. Like this:
+     * Julian's style of sub-query nesting. Like this:
      *
      * <pre>SELECT *
      * FROM (
@@ -44,7 +44,7 @@ public interface SqlWriter {
     HYDE,
 
     /**
-     * Damian's style of subquery nesting. Like this:
+     * Damian's style of sub-query nesting. Like this:
      *
      * <pre>SELECT *
      * FROM

http://git-wip-us.apache.org/repos/asf/calcite/blob/e38d51e8/core/src/main/java/org/apache/calcite/sql/advise/SqlSimpleParser.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/advise/SqlSimpleParser.java b/core/src/main/java/org/apache/calcite/sql/advise/SqlSimpleParser.java
index 0ad0d32..85dfa10 100644
--- a/core/src/main/java/org/apache/calcite/sql/advise/SqlSimpleParser.java
+++ b/core/src/main/java/org/apache/calcite/sql/advise/SqlSimpleParser.java
@@ -75,7 +75,7 @@ public class SqlSimpleParser {
     },
 
     /**
-     * A token created by reducing an entire subquery.
+     * A token created by reducing an entire sub-query.
      */
     QUERY;
 
@@ -140,7 +140,7 @@ public class SqlSimpleParser {
       list.add(token);
     }
 
-    // Gather consecutive sub-sequences of tokens into subqueries.
+    // Gather consecutive sub-sequences of tokens into sub-queries.
     List<Token> outList = new ArrayList<Token>();
     consumeQuery(list.listIterator(), outList);
 
@@ -193,18 +193,18 @@ public class SqlSimpleParser {
   private void consumeSelect(ListIterator<Token> iter, List<Token> outList) {
     boolean isQuery = false;
     int start = outList.size();
-    List<Token> subqueryList = new ArrayList<Token>();
+    List<Token> subQueryList = new ArrayList<Token>();
   loop:
     while (iter.hasNext()) {
       Token token = iter.next();
-      subqueryList.add(token);
+      subQueryList.add(token);
       switch (token.type) {
       case LPAREN:
-        consumeQuery(iter, subqueryList);
+        consumeQuery(iter, subQueryList);
         break;
       case RPAREN:
         if (isQuery) {
-          subqueryList.remove(subqueryList.size() - 1);
+          subQueryList.remove(subQueryList.size() - 1);
         }
         break loop;
       case SELECT:
@@ -213,7 +213,7 @@ public class SqlSimpleParser {
       case UNION:
       case INTERSECT:
       case EXCEPT:
-        subqueryList.remove(subqueryList.size() - 1);
+        subQueryList.remove(subQueryList.size() - 1);
         iter.previous();
         break loop;
       default:
@@ -223,14 +223,14 @@ public class SqlSimpleParser {
     // Fell off end of list. Pretend we saw the required right-paren.
     if (isQuery) {
       outList.subList(start, outList.size()).clear();
-      outList.add(new Query(subqueryList));
+      outList.add(new Query(subQueryList));
       if ((outList.size() >= 2)
           && (outList.get(outList.size() - 2).type == TokenType.LPAREN)) {
         outList.add(new Token(TokenType.RPAREN));
       }
     } else {
       // not a query - just a parenthesized expr
-      outList.addAll(subqueryList);
+      outList.addAll(subQueryList);
     }
   }
 
@@ -479,7 +479,7 @@ public class SqlSimpleParser {
     public Query simplify(String hintToken) {
       TokenType clause = TokenType.SELECT;
       TokenType foundInClause = null;
-      Query foundInSubquery = null;
+      Query foundInSubQuery = null;
       TokenType majorClause = null;
       if (hintToken != null) {
         for (Token token : tokenList) {
@@ -511,7 +511,7 @@ public class SqlSimpleParser {
           case QUERY:
             if (((Query) token).contains(hintToken)) {
               foundInClause = clause;
-              foundInSubquery = (Query) token;
+              foundInSubQuery = (Query) token;
             }
             break;
           }
@@ -566,7 +566,7 @@ public class SqlSimpleParser {
         case QUERY:
 
           // Indicates that the expression to be simplified is
-          // outside this subquery. Preserve a simplified SELECT
+          // outside this sub-query. Preserve a simplified SELECT
           // clause.
           purgeSelectExprsKeepAliases();
           purgeWhere();
@@ -581,7 +581,7 @@ public class SqlSimpleParser {
         case QUERY: {
           Query query = (Query) token;
           query.simplify(
-              (query == foundInSubquery) ? hintToken : null);
+              (query == foundInSubQuery) ? hintToken : null);
           break;
         }
         }

http://git-wip-us.apache.org/repos/asf/calcite/blob/e38d51e8/core/src/main/java/org/apache/calcite/sql/fun/SqlInOperator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/fun/SqlInOperator.java b/core/src/main/java/org/apache/calcite/sql/fun/SqlInOperator.java
index 716902b..2b80173 100644
--- a/core/src/main/java/org/apache/calcite/sql/fun/SqlInOperator.java
+++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlInOperator.java
@@ -45,7 +45,7 @@ import static org.apache.calcite.util.Static.RESOURCE;
 
 /**
  * Definition of the SQL <code>IN</code> operator, which tests for a value's
- * membership in a subquery or a list of values.
+ * membership in a sub-query or a list of values.
  */
 public class SqlInOperator extends SqlBinaryOperator {
   //~ Instance fields --------------------------------------------------------
@@ -183,7 +183,7 @@ public class SqlInOperator extends SqlBinaryOperator {
   public boolean argumentMustBeScalar(int ordinal) {
     // Argument #0 must be scalar, argument #1 can be a list (1, 2) or
     // a query (select deptno from emp). So, only coerce argument #0 into
-    // a scalar subquery. For example, in
+    // a scalar sub-query. For example, in
     //  select * from emp
     //  where (select count(*) from dept) in (select deptno from dept)
     // we should coerce the LHS to a scalar.

http://git-wip-us.apache.org/repos/asf/calcite/blob/e38d51e8/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 3bbb425..18f48d2 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
@@ -342,13 +342,13 @@ public class SqlStdOperatorTable extends ReflectiveSqlOperatorTable {
           OperandTypes.COMPARABLE_ORDERED_COMPARABLE_ORDERED);
 
   /**
-   * <code>IN</code> operator tests for a value's membership in a subquery or
+   * <code>IN</code> operator tests for a value's membership in a sub-query or
    * a list of values.
    */
   public static final SqlBinaryOperator IN = new SqlInOperator(false);
 
   /**
-   * <code>NOT IN</code> operator tests for a value's membership in a subquery
+   * <code>NOT IN</code> operator tests for a value's membership in a sub-query
    * or a list of values.
    */
   public static final SqlBinaryOperator NOT_IN =

http://git-wip-us.apache.org/repos/asf/calcite/blob/e38d51e8/core/src/main/java/org/apache/calcite/sql/parser/SqlAbstractParserImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/parser/SqlAbstractParserImpl.java b/core/src/main/java/org/apache/calcite/sql/parser/SqlAbstractParserImpl.java
index ad605da..45f004f 100644
--- a/core/src/main/java/org/apache/calcite/sql/parser/SqlAbstractParserImpl.java
+++ b/core/src/main/java/org/apache/calcite/sql/parser/SqlAbstractParserImpl.java
@@ -304,19 +304,25 @@ public abstract class SqlAbstractParserImpl {
     /**
      * Accept only non-query expressions in this context.
      */
-    ACCEPT_NONQUERY,
+    ACCEPT_NON_QUERY,
 
     /**
      * Accept only parenthesized queries or non-query expressions in this
      * context.
      */
-    ACCEPT_SUBQUERY,
+    ACCEPT_SUB_QUERY,
 
     /**
      * Accept only CURSOR constructors, parenthesized queries, or non-query
      * expressions in this context.
      */
-    ACCEPT_CURSOR
+    ACCEPT_CURSOR;
+
+    @Deprecated // to be removed before 2.0
+    public static final ExprContext ACCEPT_SUBQUERY = ACCEPT_SUB_QUERY;
+
+    @Deprecated // to be removed before 2.0
+    public static final ExprContext ACCEPT_NONQUERY = ACCEPT_NON_QUERY;
   }
 
   //~ Instance fields --------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/calcite/blob/e38d51e8/core/src/main/java/org/apache/calcite/sql/pretty/SqlPrettyWriter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/pretty/SqlPrettyWriter.java b/core/src/main/java/org/apache/calcite/sql/pretty/SqlPrettyWriter.java
index a1f719b..e212a5d 100644
--- a/core/src/main/java/org/apache/calcite/sql/pretty/SqlPrettyWriter.java
+++ b/core/src/main/java/org/apache/calcite/sql/pretty/SqlPrettyWriter.java
@@ -103,12 +103,12 @@ import java.util.Set;
  * <td>false</td>
  * </tr>
  * <tr>
- * <td>{@link #setSubqueryStyle SubqueryStyle}</td>
+ * <td>{@link #setSubQueryStyle SubQueryStyle}</td>
  * <td>Style for formatting sub-queries. Values are:
- * {@link org.apache.calcite.sql.SqlWriter.SubqueryStyle#HYDE Hyde},
- * {@link org.apache.calcite.sql.SqlWriter.SubqueryStyle#BLACK Black}.</td>
+ * {@link org.apache.calcite.sql.SqlWriter.SubQueryStyle#HYDE Hyde},
+ * {@link org.apache.calcite.sql.SqlWriter.SubQueryStyle#BLACK Black}.</td>
  *
- * <td>{@link org.apache.calcite.sql.SqlWriter.SubqueryStyle#HYDE Hyde}</td>
+ * <td>{@link org.apache.calcite.sql.SqlWriter.SubQueryStyle#HYDE Hyde}</td>
  * </tr>
  * <tr>
  * <td>{@link #setLineLength LineLength}</td>
@@ -153,7 +153,7 @@ public class SqlPrettyWriter implements SqlWriter {
   private boolean windowDeclListNewline;
   private boolean updateSetListNewline;
   private boolean windowNewline;
-  private SubqueryStyle subqueryStyle;
+  private SubQueryStyle subQueryStyle;
   private boolean whereListItemsOnSeparateLines;
 
   private boolean caseClausesOnNewLines;
@@ -197,11 +197,11 @@ public class SqlPrettyWriter implements SqlWriter {
   }
 
   /**
-   * Sets the subquery style. Default is
-   * {@link org.apache.calcite.sql.SqlWriter.SubqueryStyle#HYDE}.
+   * Sets the sub-query style. Default is
+   * {@link org.apache.calcite.sql.SqlWriter.SubQueryStyle#HYDE}.
    */
-  public void setSubqueryStyle(SubqueryStyle subqueryStyle) {
-    this.subqueryStyle = subqueryStyle;
+  public void setSubQueryStyle(SubQueryStyle subQueryStyle) {
+    this.subQueryStyle = subQueryStyle;
   }
 
   public void setWindowNewline(boolean windowNewline) {
@@ -266,7 +266,7 @@ public class SqlPrettyWriter implements SqlWriter {
     windowDeclListNewline = true;
     updateSetListNewline = true;
     windowNewline = false;
-    subqueryStyle = SubqueryStyle.HYDE;
+    subQueryStyle = SubQueryStyle.HYDE;
     alwaysUseParentheses = false;
     whereListItemsOnSeparateLines = false;
     lineLength = 0;
@@ -512,7 +512,7 @@ public class SqlPrettyWriter implements SqlWriter {
             false);
 
       case SUB_QUERY:
-        switch (subqueryStyle) {
+        switch (subQueryStyle) {
         case BLACK:
 
           // Generate, e.g.:
@@ -559,7 +559,7 @@ public class SqlPrettyWriter implements SqlWriter {
             }
           };
         default:
-          throw Util.unexpected(subqueryStyle);
+          throw Util.unexpected(subQueryStyle);
         }
 
       case ORDER_BY:

http://git-wip-us.apache.org/repos/asf/calcite/blob/e38d51e8/core/src/main/java/org/apache/calcite/sql/validate/SelectNamespace.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/validate/SelectNamespace.java b/core/src/main/java/org/apache/calcite/sql/validate/SelectNamespace.java
index c0a2dec..a01227b 100644
--- a/core/src/main/java/org/apache/calcite/sql/validate/SelectNamespace.java
+++ b/core/src/main/java/org/apache/calcite/sql/validate/SelectNamespace.java
@@ -22,7 +22,7 @@ import org.apache.calcite.sql.SqlSelect;
 import org.apache.calcite.sql.type.SqlTypeUtil;
 
 /**
- * Namespace offered by a subquery.
+ * Namespace offered by a sub-query.
  *
  * @see SelectScope
  * @see SetopNamespace

http://git-wip-us.apache.org/repos/asf/calcite/blob/e38d51e8/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java b/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
index c2c24c3..eac1b20 100644
--- a/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
+++ b/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
@@ -1975,7 +1975,7 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
       if (newRight != right) {
         join.setRight(newRight);
       }
-      registerSubqueries(joinScope, join.getCondition());
+      registerSubQueries(joinScope, join.getCondition());
       final JoinNamespace joinNamespace = new JoinNamespace(this, join);
       registerNamespace(null, null, joinNamespace, forceNullable);
       return join;
@@ -2205,7 +2205,7 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
 
       // Start by registering the WHERE clause
       whereScopes.put(select, selectScope);
-      registerOperandSubqueries(
+      registerOperandSubQueries(
           selectScope,
           select,
           SqlSelect.WHERE_OPERAND);
@@ -2240,12 +2240,12 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
       } else {
         selectScopes.put(select, selectScope);
       }
-      registerSubqueries(selectScope, select.getGroup());
-      registerOperandSubqueries(
+      registerSubQueries(selectScope, select.getGroup());
+      registerOperandSubQueries(
           aggScope,
           select,
           SqlSelect.HAVING_OPERAND);
-      registerSubqueries(aggScope, select.getSelectList());
+      registerSubQueries(aggScope, select.getSelectList());
       final SqlNodeList orderList = select.getOrderList();
       if (orderList != null) {
         // If the query is 'SELECT DISTINCT', restrict the columns
@@ -2257,7 +2257,7 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
         OrderByScope orderScope =
             new OrderByScope(aggScope, orderList, select);
         orderScopes.put(select, orderScope);
-        registerSubqueries(orderScope, orderList);
+        registerSubQueries(orderScope, orderList);
 
         if (!isAggregate(select)) {
           // Since this is not an aggregating query,
@@ -2326,9 +2326,9 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
         assert operands.get(i).getKind() == SqlKind.ROW;
 
         // FIXME jvs 9-Feb-2005:  Correlation should
-        // be illegal in these subqueries.  Same goes for
+        // be illegal in these sub-queries.  Same goes for
         // any non-lateral SELECT in the FROM list.
-        registerOperandSubqueries(parentScope, call, i);
+        registerOperandSubQueries(parentScope, call, i);
       }
       break;
 
@@ -2442,7 +2442,7 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
           alias,
           unnestNs,
           forceNullable);
-      registerOperandSubqueries(parentScope, call, 0);
+      registerOperandSubQueries(parentScope, call, 0);
       scopes.put(node, parentScope);
       break;
 
@@ -2459,7 +2459,7 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
           alias,
           procNs,
           forceNullable);
-      registerSubqueries(parentScope, call);
+      registerSubQueries(parentScope, call);
       break;
 
     case MULTISET_QUERY_CONSTRUCTOR:
@@ -2477,7 +2477,7 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
           forceNullable);
       operands = call.getOperandList();
       for (int i = 0; i < operands.size(); i++) {
-        registerOperandSubqueries(parentScope, call, i);
+        registerOperandSubQueries(parentScope, call, i);
       }
       break;
 
@@ -2607,7 +2607,7 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
     }
   }
 
-  private void registerSubqueries(
+  private void registerSubQueries(
       SqlValidatorScope parentScope,
       SqlNode node) {
     if (node == null) {
@@ -2621,7 +2621,7 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
       validateNodeFeature(node);
       SqlCall call = (SqlCall) node;
       for (int i = 0; i < call.operandCount(); i++) {
-        registerOperandSubqueries(parentScope, call, i);
+        registerOperandSubQueries(parentScope, call, i);
       }
     } else if (node instanceof SqlNodeList) {
       SqlNodeList list = (SqlNodeList) node;
@@ -2634,7 +2634,7 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
                   listNode);
           list.set(i, listNode);
         }
-        registerSubqueries(parentScope, listNode);
+        registerSubQueries(parentScope, listNode);
       }
     } else {
       // atomic node -- can be ignored
@@ -2642,15 +2642,15 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
   }
 
   /**
-   * Registers any subqueries inside a given call operand, and converts the
-   * operand to a scalar subquery if the operator requires it.
+   * Registers any sub-queries inside a given call operand, and converts the
+   * operand to a scalar sub-query if the operator requires it.
    *
    * @param parentScope    Parent scope
    * @param call           Call
    * @param operandOrdinal Ordinal of operand within call
    * @see SqlOperator#argumentMustBeScalar(int)
    */
-  private void registerOperandSubqueries(
+  private void registerOperandSubQueries(
       SqlValidatorScope parentScope,
       SqlCall call,
       int operandOrdinal) {
@@ -2666,7 +2666,7 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
               operand);
       call.setOperand(operandOrdinal, operand);
     }
-    registerSubqueries(parentScope, operand);
+    registerSubQueries(parentScope, operand);
   }
 
   public void validateIdentifier(SqlIdentifier id, SqlValidatorScope scope) {
@@ -2816,7 +2816,7 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
 
   /**
    * Validates the FROM clause of a query, or (recursively) a child node of
-   * the FROM clause: AS, OVER, JOIN, VALUES, or subquery.
+   * the FROM clause: AS, OVER, JOIN, VALUES, or sub-query.
    *
    * @param node          Node in FROM clause, typically a table or derived
    *                      table
@@ -3603,7 +3603,7 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
     }
     getRawSelectScope(select).setExpandedSelectList(expandedSelectItems);
 
-    // TODO: when SELECT appears as a value subquery, should be using
+    // TODO: when SELECT appears as a value sub-query, should be using
     // something other than unknownType for targetRowType
     inferUnknownTypes(targetRowType, selectScope, newSelectList);
 
@@ -3640,7 +3640,7 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
 
   /**
    * Processes SubQuery found in Select list. Checks that is actually Scalar
-   * subquery and makes proper entries in each of the 3 lists used to create
+   * sub-query and makes proper entries in each of the 3 lists used to create
    * the final rowType entry.
    *
    * @param parentSelect        base SqlSelect item
@@ -3655,10 +3655,10 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
       List<SqlNode> expandedSelectItems,
       Set<String> aliasList,
       List<Map.Entry<String, RelDataType>> fieldList) {
-    // A scalar subquery only has one output column.
+    // A scalar sub-query only has one output column.
     if (1 != selectItem.getSelectList().size()) {
       throw newValidationError(selectItem,
-          RESOURCE.onlyScalarSubqueryAllowed());
+          RESOURCE.onlyScalarSubQueryAllowed());
     }
 
     // No expansion in this routine just append to list.
@@ -3677,7 +3677,7 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
 
     // we do not want to pass on the RelRecordType returned
     // by the sub query.  Just the type of the single expression
-    // in the subquery select list.
+    // in the sub-query select list.
     assert type instanceof RelRecordType;
     RelRecordType rec = (RelRecordType) type;
 

http://git-wip-us.apache.org/repos/asf/calcite/blob/e38d51e8/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorNamespace.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorNamespace.java b/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorNamespace.java
index db9fd3a..2e2af29 100644
--- a/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorNamespace.java
+++ b/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorNamespace.java
@@ -30,8 +30,8 @@ import java.util.List;
  * and DEPT, and a row type consisting of the combined columns of those tables.
  *
  * <p>Other examples of namespaces include a table in the from list (the
- * namespace contains the constituent columns) and a subquery (the namespace
- * contains the columns in the SELECT clause of the subquery).
+ * namespace contains the constituent columns) and a sub-query (the namespace
+ * contains the columns in the SELECT clause of the sub-query).
  *
  * <p>These various kinds of namespace are implemented by classes
  * {@link IdentifierNamespace} for table names, {@link SelectNamespace} for

http://git-wip-us.apache.org/repos/asf/calcite/blob/e38d51e8/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java b/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
index 5f8f8c5..41e262b 100644
--- a/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
+++ b/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
@@ -1402,11 +1402,11 @@ public class RelDecorrelator implements ReflectiveVisitor {
 
       // Construct a CASE expression to handle the null indicator.
       //
-      // This also covers the case where a left correlated subquery
+      // This also covers the case where a left correlated sub-query
       // projects fields from outer relation. Since LOJ cannot produce
       // nulls on the LHS, the projection now need to make a nullable LHS
       // reference using a nullability indicator. If this this indicator
-      // is null, it means the subquery does not produce any value. As a
+      // is null, it means the sub-query does not produce any value. As a
       // result, any RHS ref by this usbquery needs to produce null value.
 
       // WHEN indicator IS NULL
@@ -1600,7 +1600,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
 
       // check projRel only projects one expression
       // check this project only projects one expression, i.e. scalar
-      // subqueries.
+      // sub-queries.
       List<RexNode> projExprs = project.getProjects();
       if (projExprs.size() != 1) {
         return;
@@ -1677,7 +1677,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
       }
 
       // check this project only projects one expression, i.e. scalar
-      // subqueries.
+      // sub-queries.
       if (project.getProjects().size() != 1) {
         return;
       }

http://git-wip-us.apache.org/repos/asf/calcite/blob/e38d51e8/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java b/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
index c654d31..a712a7c 100644
--- a/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
+++ b/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
@@ -209,7 +209,11 @@ public class SqlToRelConverter {
 
   /** Size of the smallest IN list that will be converted to a semijoin to a
    * static table. */
-  public static final int DEFAULT_IN_SUBQUERY_THRESHOLD = 20;
+  public static final int DEFAULT_IN_SUB_QUERY_THRESHOLD = 20;
+
+  @Deprecated // to be removed before 2.0
+  public static final int DEFAULT_IN_SUBQUERY_THRESHOLD =
+      DEFAULT_IN_SUB_QUERY_THRESHOLD;
 
   //~ Instance fields --------------------------------------------------------
 
@@ -218,7 +222,7 @@ public class SqlToRelConverter {
   protected final Prepare.CatalogReader catalogReader;
   protected final RelOptCluster cluster;
   private DefaultValueFactory defaultValueFactory;
-  private SubqueryConverter subqueryConverter;
+  private SubQueryConverter subQueryConverter;
   protected final List<RelNode> leaves = new ArrayList<>();
   private final List<SqlDynamicParam> dynamicParamSqlNodes = new ArrayList<>();
   private final SqlOperatorTable opTab;
@@ -228,7 +232,7 @@ public class SqlToRelConverter {
   public final SqlToRelConverter.Config config;
 
   /**
-   * Fields used in name resolution for correlated subqueries.
+   * Fields used in name resolution for correlated sub-queries.
    */
   private final Map<CorrelationId, DeferredLookup> mapCorrelToDeferred =
       new HashMap<>();
@@ -240,8 +244,8 @@ public class SqlToRelConverter {
   private final Deque<String> datasetStack = new ArrayDeque<>();
 
   /**
-   * Mapping of non-correlated subqueries that have been converted to their
-   * equivalent constants. Used to avoid re-evaluating the subquery if it's
+   * Mapping of non-correlated sub-queries that have been converted to their
+   * equivalent constants. Used to avoid re-evaluating the sub-query if it's
    * already been evaluated.
    */
   private final Map<SqlNode, RexNode> mapConvertedNonCorrSubqs =
@@ -300,7 +304,7 @@ public class SqlToRelConverter {
     this.validator = validator;
     this.catalogReader = catalogReader;
     this.defaultValueFactory = new NullDefaultValueFactory();
-    this.subqueryConverter = new NoOpSubqueryConverter();
+    this.subQueryConverter = new NoOpSubQueryConverter();
     this.rexBuilder = cluster.getRexBuilder();
     this.typeFactory = rexBuilder.getTypeFactory();
     this.cluster = Preconditions.checkNotNull(cluster);
@@ -365,7 +369,7 @@ public class SqlToRelConverter {
   }
 
   /**
-   * @return mapping of non-correlated subqueries that have been converted to
+   * @return mapping of non-correlated sub-queries that have been converted to
    * the constants that they evaluate to
    */
   public Map<SqlNode, RexNode> getMapConvertedNonCorrSubqs() {
@@ -373,8 +377,8 @@ public class SqlToRelConverter {
   }
 
   /**
-   * Adds to the current map of non-correlated converted subqueries the
-   * elements from another map that contains non-correlated subqueries that
+   * Adds to the current map of non-correlated converted sub-queries the
+   * elements from another map that contains non-correlated sub-queries that
    * have been converted by another SqlToRelConverter.
    *
    * @param alreadyConvertedNonCorrSubqs the other map
@@ -395,13 +399,13 @@ public class SqlToRelConverter {
   }
 
   /**
-   * Sets a new SubqueryConverter. To have any effect, this must be called
+   * Sets a new SubQueryConverter. To have any effect, this must be called
    * before any convert method.
    *
-   * @param converter new SubqueryConverter
+   * @param converter new SubQueryConverter
    */
-  public void setSubqueryConverter(SubqueryConverter converter) {
-    subqueryConverter = converter;
+  public void setSubQueryConverter(SubQueryConverter converter) {
+    subQueryConverter = converter;
   }
 
   /**
@@ -459,7 +463,7 @@ public class SqlToRelConverter {
   }
 
   /**
-   * If subquery is correlated and decorrelation is enabled, performs
+   * If sub-query is correlated and decorrelation is enabled, performs
    * decorrelation.
    *
    * @param query   Query
@@ -981,7 +985,7 @@ public class SqlToRelConverter {
       final Blackboard bb,
       final SqlNode expr,
       RelOptUtil.Logic logic) {
-    findSubqueries(bb, expr, logic, false);
+    findSubQueries(bb, expr, logic, false);
     for (SubQuery node : bb.subQueryList) {
       substituteSubQuery(bb, node);
     }
@@ -1034,7 +1038,7 @@ public class SqlToRelConverter {
       if (query instanceof SqlNodeList) {
         SqlNodeList valueList = (SqlNodeList) query;
         if (!containsNullLiteral(valueList)
-            && valueList.size() < config.getInSubqueryThreshold()) {
+            && valueList.size() < config.getInSubQueryThreshold()) {
           // We're under the threshold, so convert to OR.
           subQuery.expr =
               convertInToOr(
@@ -1076,7 +1080,7 @@ public class SqlToRelConverter {
           SqlTypeUtil.promoteToRowType(typeFactory,
               validator.getValidatedNodeType(leftKeyNode), null);
       converted =
-          convertExists(query, RelOptUtil.SubqueryType.IN, subQuery.logic,
+          convertExists(query, RelOptUtil.SubQueryType.IN, subQuery.logic,
               notIn, targetRowType);
       if (converted.indicator) {
         // Generate
@@ -1122,19 +1126,19 @@ public class SqlToRelConverter {
     case EXISTS:
       // "select from emp where exists (select a from T)"
       //
-      // is converted to the following if the subquery is correlated:
+      // is converted to the following if the sub-query is correlated:
       //
       // "select from emp left outer join (select AGG_TRUE() as indicator
       // from T group by corr_var) q where q.indicator is true"
       //
       // If there is no correlation, the expression is replaced with a
-      // boolean indicating whether the subquery returned 0 or >= 1 row.
+      // boolean indicating whether the sub-query returned 0 or >= 1 row.
       call = (SqlBasicCall) subQuery.node;
       query = call.operand(0);
       if (!config.isExpand()) {
         return;
       }
-      converted = convertExists(query, RelOptUtil.SubqueryType.EXISTS,
+      converted = convertExists(query, RelOptUtil.SubQueryType.EXISTS,
           subQuery.logic, true, null);
       assert !converted.indicator;
       if (convertNonCorrelatedSubQuery(subQuery, bb, converted.r, true)) {
@@ -1144,14 +1148,14 @@ public class SqlToRelConverter {
       return;
 
     case SCALAR_QUERY:
-      // Convert the subquery.  If it's non-correlated, convert it
+      // Convert the sub-query.  If it's non-correlated, convert it
       // to a constant expression.
       if (!config.isExpand()) {
         return;
       }
       call = (SqlBasicCall) subQuery.node;
       query = call.operand(0);
-      converted = convertExists(query, RelOptUtil.SubqueryType.SCALAR,
+      converted = convertExists(query, RelOptUtil.SubQueryType.SCALAR,
           subQuery.logic, true, null);
       assert !converted.indicator;
       if (convertNonCorrelatedSubQuery(subQuery, bb, converted.r, false)) {
@@ -1166,14 +1170,14 @@ public class SqlToRelConverter {
       //
       // select * from unnest(select multiset[deptno] from emps);
       //
-      converted = convertExists(subQuery.node, RelOptUtil.SubqueryType.SCALAR,
+      converted = convertExists(subQuery.node, RelOptUtil.SubQueryType.SCALAR,
           subQuery.logic, true, null);
       assert !converted.indicator;
       subQuery.expr = bb.register(converted.r, JoinRelType.LEFT);
       return;
 
     default:
-      throw Util.newInternal("unexpected kind of subquery :" + subQuery.node);
+      throw Util.newInternal("unexpected kind of sub-query :" + subQuery.node);
     }
   }
 
@@ -1194,7 +1198,7 @@ public class SqlToRelConverter {
       //
       // RexRangeRef contains the following fields:
       //   leftKeysForIn,
-      //   rightKeysForIn (the original subquery select list),
+      //   rightKeysForIn (the original sub-query select list),
       //   nullIndicator
       //
       // The first two lists contain the same number of fields.
@@ -1277,14 +1281,14 @@ public class SqlToRelConverter {
   }
 
   /**
-   * Determines if a subquery is non-correlated and if so, converts it to a
+   * Determines if a sub-query is non-correlated and if so, converts it to a
    * constant.
    *
-   * @param subQuery  the call that references the subquery
-   * @param bb        blackboard used to convert the subquery
-   * @param converted RelNode tree corresponding to the subquery
-   * @param isExists  true if the subquery is part of an EXISTS expression
-   * @return if the subquery can be converted to a constant
+   * @param subQuery  the call that references the sub-query
+   * @param bb        blackboard used to convert the sub-query
+   * @param converted RelNode tree corresponding to the sub-query
+   * @param isExists  true if the sub-query is part of an EXISTS expression
+   * @return Whether the sub-query can be converted to a constant
    */
   private boolean convertNonCorrelatedSubQuery(
       SubQuery subQuery,
@@ -1292,15 +1296,15 @@ public class SqlToRelConverter {
       RelNode converted,
       boolean isExists) {
     SqlCall call = (SqlBasicCall) subQuery.node;
-    if (subqueryConverter.canConvertSubquery()
+    if (subQueryConverter.canConvertSubQuery()
         && isSubQueryNonCorrelated(converted, bb)) {
-      // First check if the subquery has already been converted
-      // because it's a nested subquery.  If so, don't re-evaluate
+      // First check if the sub-query has already been converted
+      // because it's a nested sub-query.  If so, don't re-evaluate
       // it again.
       RexNode constExpr = mapConvertedNonCorrSubqs.get(call);
       if (constExpr == null) {
         constExpr =
-            subqueryConverter.convertSubquery(
+            subQueryConverter.convertSubQuery(
                 call,
                 this,
                 isExists,
@@ -1449,15 +1453,15 @@ public class SqlToRelConverter {
    * predicate. A threshold of 0 forces usage of an inline table in all cases; a
    * threshold of Integer.MAX_VALUE forces usage of OR in all cases
    *
-   * @return threshold, default {@link #DEFAULT_IN_SUBQUERY_THRESHOLD}
+   * @return threshold, default {@link #DEFAULT_IN_SUB_QUERY_THRESHOLD}
    */
   @Deprecated // to be removed before 2.0
   protected int getInSubqueryThreshold() {
-    return config.getInSubqueryThreshold();
+    return config.getInSubQueryThreshold();
   }
 
   /**
-   * Converts an EXISTS or IN predicate into a join. For EXISTS, the subquery
+   * Converts an EXISTS or IN predicate into a join. For EXISTS, the sub-query
    * produces an indicator variable, and the result is a relational expression
    * which outer joins that indicator to the original query. After performing
    * the outer join, the condition will be TRUE if the EXISTS condition holds,
@@ -1465,7 +1469,7 @@ public class SqlToRelConverter {
    *
    * @param seek           A query, for example 'select * from emp' or
    *                       'values (1,2,3)' or '('Foo', 34)'.
-   * @param subqueryType   Whether sub-query is IN, EXISTS or scalar
+   * @param subQueryType   Whether sub-query is IN, EXISTS or scalar
    * @param logic Whether the answer needs to be in full 3-valued logic (TRUE,
    *     FALSE, UNKNOWN) will be required, or whether we can accept an
    *     approximation (say representing UNKNOWN as FALSE)
@@ -1475,7 +1479,7 @@ public class SqlToRelConverter {
    */
   private RelOptUtil.Exists convertExists(
       SqlNode seek,
-      RelOptUtil.SubqueryType subqueryType,
+      RelOptUtil.SubQueryType subQueryType,
       RelOptUtil.Logic logic,
       boolean notIn,
       RelDataType targetDataType) {
@@ -1486,7 +1490,7 @@ public class SqlToRelConverter {
     final Blackboard seekBb = createBlackboard(seekScope, null, false);
     RelNode seekRel = convertQueryOrInList(seekBb, seek, targetDataType);
 
-    return RelOptUtil.createExistsPlan(seekRel, subqueryType, logic, notIn);
+    return RelOptUtil.createExistsPlan(seekRel, subQueryType, logic, notIn);
   }
 
   private RelNode convertQueryOrInList(
@@ -1520,7 +1524,7 @@ public class SqlToRelConverter {
     // NOTE jvs 30-Apr-2006: We combine all rows consisting entirely of
     // literals into a single LogicalValues; this gives the optimizer a smaller
     // input tree.  For everything else (computed expressions, row
-    // subqueries), we union each row in as a projection on top of a
+    // sub-queries), we union each row in as a projection on top of a
     // LogicalOneRow.
 
     final ImmutableList.Builder<ImmutableList<RexLiteral>> tupleList =
@@ -1678,16 +1682,16 @@ public class SqlToRelConverter {
    * @param logic Whether the answer needs to be in full 3-valued logic (TRUE,
    *              FALSE, UNKNOWN) will be required, or whether we can accept
    *              an approximation (say representing UNKNOWN as FALSE)
-   * @param registerOnlyScalarSubqueries if set to true and the parse tree
+   * @param registerOnlyScalarSubQueries if set to true and the parse tree
    *                                     corresponds to a variation of a select
    *                                     node, only register it if it's a scalar
-   *                                     subquery
+   *                                     sub-query
    */
-  private void findSubqueries(
+  private void findSubQueries(
       Blackboard bb,
       SqlNode node,
       RelOptUtil.Logic logic,
-      boolean registerOnlyScalarSubqueries) {
+      boolean registerOnlyScalarSubQueries) {
     final SqlKind kind = node.getKind();
     switch (kind) {
     case EXISTS:
@@ -1697,7 +1701,7 @@ public class SqlToRelConverter {
     case ARRAY_QUERY_CONSTRUCTOR:
     case CURSOR:
     case SCALAR_QUERY:
-      if (!registerOnlyScalarSubqueries
+      if (!registerOnlyScalarSubQueries
           || (kind == SqlKind.SCALAR_QUERY)) {
         bb.registerSubQuery(node, RelOptUtil.Logic.TRUE_FALSE);
       }
@@ -1715,27 +1719,27 @@ public class SqlToRelConverter {
       for (SqlNode operand : ((SqlCall) node).getOperandList()) {
         if (operand != null) {
           // In the case of an IN expression, locate scalar
-          // subqueries so we can convert them to constants
-          findSubqueries(
+          // sub-queries so we can convert them to constants
+          findSubQueries(
               bb,
               operand,
               logic,
-              kind == SqlKind.IN || registerOnlyScalarSubqueries);
+              kind == SqlKind.IN || registerOnlyScalarSubQueries);
         }
       }
     } else if (node instanceof SqlNodeList) {
       for (SqlNode child : (SqlNodeList) node) {
-        findSubqueries(
+        findSubQueries(
             bb,
             child,
             logic,
-            kind == SqlKind.IN || registerOnlyScalarSubqueries);
+            kind == SqlKind.IN || registerOnlyScalarSubQueries);
       }
     }
 
-    // Now that we've located any scalar subqueries inside the IN
+    // Now that we've located any scalar sub-queries inside the IN
     // expression, register the IN expression itself.  We need to
-    // register the scalar subqueries first so they can be converted
+    // register the scalar sub-queries first so they can be converted
     // before the IN expression is converted.
     if (kind == SqlKind.IN) {
       switch (logic) {
@@ -2257,7 +2261,7 @@ public class SqlToRelConverter {
         Map<Integer, Integer> exprProjection =
             bb.mapRootRelToFieldProjection.get(bb.root);
 
-        // subquery can reference group by keys projected from
+        // sub-query can reference group by keys projected from
         // the root of the outer relation.
         if (exprProjection.containsKey(pos)) {
           pos = exprProjection.get(pos);
@@ -2288,15 +2292,15 @@ public class SqlToRelConverter {
   }
 
   /**
-   * Determines whether a subquery is non-correlated. Note that a
-   * non-correlated subquery can contain correlated references, provided those
+   * Determines whether a sub-query is non-correlated. Note that a
+   * non-correlated sub-query can contain correlated references, provided those
    * references do not reference select statements that are parents of the
-   * subquery.
+   * sub-query.
    *
-   * @param subq the subquery
-   * @param bb   blackboard used while converting the subquery, i.e., the
-   *             blackboard of the parent query of this subquery
-   * @return true if the subquery is non-correlated.
+   * @param subq the sub-query
+   * @param bb   blackboard used while converting the sub-query, i.e., the
+   *             blackboard of the parent query of this sub-query
+   * @return true if the sub-query is non-correlated
    */
   private boolean isSubQueryNonCorrelated(RelNode subq, Blackboard bb) {
     Set<CorrelationId> correlatedVariables = RelOptUtil.getVariablesUsed(subq);
@@ -2312,7 +2316,7 @@ public class SqlToRelConverter {
       SqlValidatorScope ancestorScope = resolved.only().scope;
 
       // If the correlated reference is in a scope that's "above" the
-      // subquery, then this is a correlated subquery.
+      // sub-query, then this is a correlated sub-query.
       SqlValidatorScope parentScope = bb.scope;
       do {
         if (ancestorScope == parentScope) {
@@ -2461,7 +2465,7 @@ public class SqlToRelConverter {
       having.accept(aggregateFinder);
     }
 
-    // first replace the subqueries inside the aggregates
+    // first replace the sub-queries inside the aggregates
     // because they will provide input rows to the aggregates.
     replaceSubQueries(bb, aggregateFinder.list,
         RelOptUtil.Logic.TRUE_FALSE_UNKNOWN);
@@ -2586,7 +2590,7 @@ public class SqlToRelConverter {
 
       bb.mapRootRelToFieldProjection.put(bb.root, r.groupExprProjection);
 
-      // Replace subqueries in having here and modify having to use
+      // Replace sub-queries in having here and modify having to use
       // the replaced expressions
       if (having != null) {
         SqlNode newHaving = pushDownNotForIn(having);
@@ -2597,13 +2601,13 @@ public class SqlToRelConverter {
         }
       }
 
-      // Now convert the other subqueries in the select list.
-      // This needs to be done separately from the subquery inside
+      // Now convert the other sub-queries in the select list.
+      // This needs to be done separately from the sub-query inside
       // any aggregate in the select list, and after the aggregate rel
       // is allocated.
       replaceSubQueries(bb, selectList, RelOptUtil.Logic.TRUE_FALSE_UNKNOWN);
 
-      // Now subqueries in the entire select list have been converted.
+      // Now sub-queries in the entire select list have been converted.
       // Convert the select expressions to get the final list to be
       // projected.
       int k = 0;
@@ -2819,7 +2823,7 @@ public class SqlToRelConverter {
 
   @Deprecated // to be removed before 2.0
   protected boolean enableDecorrelation() {
-    // disable subquery decorrelation when needed.
+    // disable sub-query decorrelation when needed.
     // e.g. if outer joins are not supported.
     return config.isDecorrelationEnabled();
   }
@@ -3589,7 +3593,7 @@ public class SqlToRelConverter {
       SqlCall values,
       RelDataType targetRowType) {
     // Attempt direct conversion to LogicalValues; if that fails, deal with
-    // fancy stuff like subqueries below.
+    // fancy stuff like sub-queries below.
     RelNode valuesRel =
         convertRowValues(
             bb,
@@ -3682,8 +3686,8 @@ public class SqlToRelConverter {
 
     /**
      * Project the groupby expressions out of the root of this sub-select.
-     * Subqueries can reference group by expressions projected from the
-     * "right" to the subquery.
+     * Sub-queries can reference group by expressions projected from the
+     * "right" to the sub-query.
      */
     private final Map<RelNode, Map<Integer, Integer>>
     mapRootRelToFieldProjection = new HashMap<>();
@@ -3841,7 +3845,7 @@ public class SqlToRelConverter {
      * @param leaf Whether the relational expression is a leaf, that is,
      *             derived from an atomic relational expression such as a table
      *             name in the from clause, or the projection on top of a
-     *             select-subquery. In particular, relational expressions
+     *             select-sub-query. In particular, relational expressions
      *             derived from JOIN operators are not leaves, but set
      *             expressions are.
      */
@@ -4141,12 +4145,12 @@ public class SqlToRelConverter {
         if (((kind == SqlKind.SCALAR_QUERY)
             || (kind == SqlKind.EXISTS))
             && isConvertedSubq(rex)) {
-          // scalar subquery or EXISTS has been converted to a
+          // scalar sub-query or EXISTS has been converted to a
           // constant
           return rex;
         }
 
-        // The indicator column is the last field of the subquery.
+        // The indicator column is the last field of the sub-query.
         RexNode fieldAccess =
             rexBuilder.makeFieldAccess(
                 rex,
@@ -4195,7 +4199,7 @@ public class SqlToRelConverter {
     }
 
     /**
-     * Determines whether a RexNode corresponds to a subquery that's been
+     * Determines whether a RexNode corresponds to a sub-query that's been
      * converted to a constant.
      *
      * @param rex the expression to be examined
@@ -4348,15 +4352,15 @@ public class SqlToRelConverter {
   }
 
   /**
-   * A default implementation of SubqueryConverter that does no conversion.
+   * A default implementation of SubQueryConverter that does no conversion.
    */
-  private class NoOpSubqueryConverter implements SubqueryConverter {
-    public boolean canConvertSubquery() {
+  private class NoOpSubQueryConverter implements SubQueryConverter {
+    public boolean canConvertSubQuery() {
       return false;
     }
 
-    public RexNode convertSubquery(
-        SqlCall subquery,
+    public RexNode convertSubQuery(
+        SqlCall subQuery,
         SqlToRelConverter parentConverter,
         boolean isExists,
         boolean isExplain) {
@@ -4518,7 +4522,7 @@ public class SqlToRelConverter {
         return null;
       case SELECT:
         // rchen 2006-10-17:
-        // for now do not detect aggregates in subqueries.
+        // for now do not detect aggregates in sub-queries.
         return null;
       }
       final boolean prevInOver = inOver;
@@ -4750,7 +4754,7 @@ public class SqlToRelConverter {
     /**
      * Creates a LookupContext with multiple input relational expressions.
      *
-     * @param bb               Context for translating this subquery
+     * @param bb               Context for translating this sub-query
      * @param rels             Relational expressions
      * @param systemFieldCount Number of system fields
      */
@@ -5045,7 +5049,7 @@ public class SqlToRelConverter {
     boolean isConvertTableAccess();
 
     /** Returns the {@code decorrelationEnabled} option. Controls whether to
-     * disable subquery decorrelation when needed. e.g. if outer joins are not
+     * disable sub-query decorrelation when needed. e.g. if outer joins are not
      * supported. */
     boolean isDecorrelationEnabled();
 
@@ -5067,15 +5071,15 @@ public class SqlToRelConverter {
      * {@link org.apache.calcite.rex.RexSubQuery}. */
     boolean isExpand();
 
-    /** Returns the {@code inSubqueryThreshold} option,
-     * default {@link #DEFAULT_IN_SUBQUERY_THRESHOLD}. Controls the list size
+    /** Returns the {@code inSubQueryThreshold} option,
+     * default {@link #DEFAULT_IN_SUB_QUERY_THRESHOLD}. Controls the list size
      * threshold under which {@link #convertInToOr} is used. Lists of this size
      * or greater will instead be converted to use a join against an inline
      * table ({@link org.apache.calcite.rel.logical.LogicalValues}) rather than
      * a predicate. A threshold of 0 forces usage of an inline table in all
      * cases; a threshold of {@link Integer#MAX_VALUE} forces usage of OR in all
      * cases. */
-    int getInSubqueryThreshold();
+    int getInSubQueryThreshold();
   }
 
   /** Builder for a {@link Config}. */
@@ -5086,7 +5090,7 @@ public class SqlToRelConverter {
     private boolean createValuesRel = true;
     private boolean explain;
     private boolean expand = true;
-    private int inSubqueryThreshold = DEFAULT_IN_SUBQUERY_THRESHOLD;
+    private int inSubQueryThreshold = DEFAULT_IN_SUB_QUERY_THRESHOLD;
 
     private ConfigBuilder() {}
 
@@ -5098,7 +5102,7 @@ public class SqlToRelConverter {
       this.createValuesRel = config.isCreateValuesRel();
       this.explain = config.isExplain();
       this.expand = config.isExpand();
-      this.inSubqueryThreshold = config.getInSubqueryThreshold();
+      this.inSubQueryThreshold = config.getInSubQueryThreshold();
       return this;
     }
 
@@ -5132,8 +5136,13 @@ public class SqlToRelConverter {
       return this;
     }
 
-    public ConfigBuilder withInSubqueryThreshold(int inSubqueryThreshold) {
-      this.inSubqueryThreshold = inSubqueryThreshold;
+    @Deprecated // to be removed before 2.0
+    public ConfigBuilder withInSubqueryThreshold(int inSubQueryThreshold) {
+      return withInSubQueryThreshold(inSubQueryThreshold);
+    }
+
+    public ConfigBuilder withInSubQueryThreshold(int inSubQueryThreshold) {
+      this.inSubQueryThreshold = inSubQueryThreshold;
       return this;
     }
 
@@ -5141,7 +5150,7 @@ public class SqlToRelConverter {
     public Config build() {
       return new ConfigImpl(convertTableAccess, decorrelationEnabled,
           trimUnusedFields, createValuesRel, explain, expand,
-          inSubqueryThreshold);
+          inSubQueryThreshold);
     }
   }
 
@@ -5153,19 +5162,19 @@ public class SqlToRelConverter {
     private final boolean trimUnusedFields;
     private final boolean createValuesRel;
     private final boolean explain;
-    private final int inSubqueryThreshold;
+    private final int inSubQueryThreshold;
     private final boolean expand;
 
     private ConfigImpl(boolean convertTableAccess, boolean decorrelationEnabled,
         boolean trimUnusedFields, boolean createValuesRel, boolean explain,
-        boolean expand, int inSubqueryThreshold) {
+        boolean expand, int inSubQueryThreshold) {
       this.convertTableAccess = convertTableAccess;
       this.decorrelationEnabled = decorrelationEnabled;
       this.trimUnusedFields = trimUnusedFields;
       this.createValuesRel = createValuesRel;
       this.explain = explain;
       this.expand = expand;
-      this.inSubqueryThreshold = inSubqueryThreshold;
+      this.inSubQueryThreshold = inSubQueryThreshold;
     }
 
     public boolean isConvertTableAccess() {
@@ -5192,8 +5201,8 @@ public class SqlToRelConverter {
       return expand;
     }
 
-    public int getInSubqueryThreshold() {
-      return inSubqueryThreshold;
+    public int getInSubQueryThreshold() {
+      return inSubQueryThreshold;
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/calcite/blob/e38d51e8/core/src/main/java/org/apache/calcite/sql2rel/SubQueryConverter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql2rel/SubQueryConverter.java b/core/src/main/java/org/apache/calcite/sql2rel/SubQueryConverter.java
new file mode 100644
index 0000000..574cd82
--- /dev/null
+++ b/core/src/main/java/org/apache/calcite/sql2rel/SubQueryConverter.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.sql2rel;
+
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.sql.SqlCall;
+
+/**
+ * SubQueryConverter provides the interface for classes that convert sub-queries
+ * into equivalent expressions.
+ */
+public interface SubQueryConverter {
+  //~ Methods ----------------------------------------------------------------
+
+  /**
+   * @return Whether the sub-query can be converted
+   */
+  boolean canConvertSubQuery();
+
+  /**
+   * Converts the sub-query to an equivalent expression.
+   *
+   * @param subQuery        the SqlNode tree corresponding to a sub-query
+   * @param parentConverter sqlToRelConverter of the parent query
+   * @param isExists        whether the sub-query is part of an EXISTS
+   *                        expression
+   * @param isExplain       whether the sub-query is part of an EXPLAIN PLAN
+   *                        statement
+   * @return the equivalent expression or null if the sub-query couldn't be
+   * converted
+   */
+  RexNode convertSubQuery(
+      SqlCall subQuery,
+      SqlToRelConverter parentConverter,
+      boolean isExists,
+      boolean isExplain);
+}
+
+// End SubQueryConverter.java