http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/main/java/org/apache/calcite/sql/dialect/HsqldbHandler.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/dialect/HsqldbHandler.java 
b/core/src/main/java/org/apache/calcite/sql/dialect/HsqldbHandler.java
deleted file mode 100644
index 62e54bf..0000000
--- a/core/src/main/java/org/apache/calcite/sql/dialect/HsqldbHandler.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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.sql.dialect;
-
-import org.apache.calcite.avatica.util.TimeUnitRange;
-import org.apache.calcite.sql.SqlCall;
-import org.apache.calcite.sql.SqlDialect;
-import org.apache.calcite.sql.SqlLiteral;
-import org.apache.calcite.sql.SqlWriter;
-import org.apache.calcite.sql.fun.SqlFloorFunction;
-
-/**
- * Defines how a SQL parse tree should be unparsed to SQL
- * for execution against an HSQLDB database.
- *
- * <p>It reverts to the unparse method of the operator
- * if this database's implementation is standard.
- */
-public class HsqldbHandler extends SqlDialect.BaseHandler {
-  public static final HsqldbHandler INSTANCE = new HsqldbHandler();
-
-  @Override public void unparseCall(SqlWriter writer, SqlCall call,
-      int leftPrec, int rightPrec) {
-    switch (call.getKind()) {
-    case FLOOR:
-      if (call.operandCount() != 2) {
-        super.unparseCall(writer, call, leftPrec, rightPrec);
-        return;
-      }
-
-      final SqlLiteral timeUnitNode = call.operand(1);
-      final TimeUnitRange timeUnit = 
timeUnitNode.getValueAs(TimeUnitRange.class);
-
-      final String translatedLit = convertTimeUnit(timeUnit);
-      SqlCall call2 = SqlFloorFunction.replaceTimeUnitOperand(call, 
translatedLit,
-          timeUnitNode.getParserPosition());
-      SqlFloorFunction.unparseDatetimeFunction(writer, call2, "TRUNC", true);
-      break;
-
-    default:
-      super.unparseCall(writer, call, leftPrec, rightPrec);
-    }
-  }
-
-  private static String convertTimeUnit(TimeUnitRange unit) {
-    switch (unit) {
-    case YEAR:
-      return "YYYY";
-    case MONTH:
-      return "MM";
-    case DAY:
-      return "DD";
-    case WEEK:
-      return "WW";
-    case HOUR:
-      return "HH24";
-    case MINUTE:
-      return "MI";
-    case SECOND:
-      return "SS";
-    default:
-      throw new AssertionError("could not convert time unit to HSQLDB 
equivalent: "
-          + unit);
-    }
-  }
-}
-
-// End HsqldbHandler.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/main/java/org/apache/calcite/sql/dialect/HsqldbSqlDialect.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/dialect/HsqldbSqlDialect.java 
b/core/src/main/java/org/apache/calcite/sql/dialect/HsqldbSqlDialect.java
new file mode 100644
index 0000000..d2ac74a
--- /dev/null
+++ b/core/src/main/java/org/apache/calcite/sql/dialect/HsqldbSqlDialect.java
@@ -0,0 +1,126 @@
+/*
+ * 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.sql.dialect;
+
+import org.apache.calcite.avatica.util.TimeUnitRange;
+import org.apache.calcite.sql.SqlBasicCall;
+import org.apache.calcite.sql.SqlCall;
+import org.apache.calcite.sql.SqlDialect;
+import org.apache.calcite.sql.SqlLiteral;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlNodeList;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.fun.SqlCase;
+import org.apache.calcite.sql.fun.SqlFloorFunction;
+import org.apache.calcite.sql.fun.SqlStdOperatorTable;
+import org.apache.calcite.sql.parser.SqlParserPos;
+
+/**
+ * A <code>SqlDialect</code> implementation for the Hsqldb database.
+ */
+public class HsqldbSqlDialect extends SqlDialect {
+  public static final SqlDialect DEFAULT =
+      new HsqldbSqlDialect(EMPTY_CONTEXT
+          .withDatabaseProduct(DatabaseProduct.HSQLDB));
+
+  /** Creates an HsqldbSqlDialect. */
+  public HsqldbSqlDialect(Context context) {
+    super(context);
+  }
+
+  @Override public boolean supportsCharSet() {
+    return false;
+  }
+
+  @Override public void unparseCall(SqlWriter writer, SqlCall call,
+      int leftPrec, int rightPrec) {
+    switch (call.getKind()) {
+    case FLOOR:
+      if (call.operandCount() != 2) {
+        super.unparseCall(writer, call, leftPrec, rightPrec);
+        return;
+      }
+
+      final SqlLiteral timeUnitNode = call.operand(1);
+      final TimeUnitRange timeUnit = 
timeUnitNode.getValueAs(TimeUnitRange.class);
+
+      final String translatedLit = convertTimeUnit(timeUnit);
+      SqlCall call2 = SqlFloorFunction.replaceTimeUnitOperand(call, 
translatedLit,
+          timeUnitNode.getParserPosition());
+      SqlFloorFunction.unparseDatetimeFunction(writer, call2, "TRUNC", true);
+      break;
+
+    default:
+      super.unparseCall(writer, call, leftPrec, rightPrec);
+    }
+  }
+
+  @Override public SqlNode rewriteSingleValueExpr(SqlNode aggCall) {
+    final SqlNode operand = ((SqlBasicCall) aggCall).operand(0);
+    final SqlLiteral nullLiteral = SqlLiteral.createNull(SqlParserPos.ZERO);
+    final SqlNode unionOperand = 
SqlStdOperatorTable.VALUES.createCall(SqlParserPos.ZERO,
+        SqlLiteral.createApproxNumeric("0", SqlParserPos.ZERO));
+    // For hsqldb, generate
+    //   CASE COUNT(*)
+    //   WHEN 0 THEN NULL
+    //   WHEN 1 THEN MIN(<result>)
+    //   ELSE (VALUES 1 UNION ALL VALUES 1)
+    //   END
+    final SqlNode caseExpr =
+        new SqlCase(SqlParserPos.ZERO,
+            SqlStdOperatorTable.COUNT.createCall(SqlParserPos.ZERO, operand),
+            SqlNodeList.of(
+                SqlLiteral.createExactNumeric("0", SqlParserPos.ZERO),
+                SqlLiteral.createExactNumeric("1", SqlParserPos.ZERO)
+            ),
+            SqlNodeList.of(
+                nullLiteral,
+                SqlStdOperatorTable.MIN.createCall(SqlParserPos.ZERO, operand)
+            ),
+            SqlStdOperatorTable.SCALAR_QUERY.createCall(SqlParserPos.ZERO,
+                SqlStdOperatorTable.UNION_ALL
+                    .createCall(SqlParserPos.ZERO, unionOperand, 
unionOperand)));
+
+    LOGGER.debug("SINGLE_VALUE rewritten into [{}]", caseExpr);
+
+    return caseExpr;
+  }
+
+  private static String convertTimeUnit(TimeUnitRange unit) {
+    switch (unit) {
+    case YEAR:
+      return "YYYY";
+    case MONTH:
+      return "MM";
+    case DAY:
+      return "DD";
+    case WEEK:
+      return "WW";
+    case HOUR:
+      return "HH24";
+    case MINUTE:
+      return "MI";
+    case SECOND:
+      return "SS";
+    default:
+      throw new AssertionError("could not convert time unit to HSQLDB 
equivalent: "
+          + unit);
+    }
+  }
+}
+
+// End HsqldbSqlDialect.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/main/java/org/apache/calcite/sql/dialect/InfobrightSqlDialect.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/dialect/InfobrightSqlDialect.java 
b/core/src/main/java/org/apache/calcite/sql/dialect/InfobrightSqlDialect.java
new file mode 100644
index 0000000..78ba060
--- /dev/null
+++ 
b/core/src/main/java/org/apache/calcite/sql/dialect/InfobrightSqlDialect.java
@@ -0,0 +1,36 @@
+/*
+ * 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.sql.dialect;
+
+import org.apache.calcite.sql.SqlDialect;
+
+/**
+ * A <code>SqlDialect</code> implementation for the Infobright database.
+ */
+public class InfobrightSqlDialect extends SqlDialect {
+  public static final SqlDialect DEFAULT =
+      new InfobrightSqlDialect(EMPTY_CONTEXT
+          .withDatabaseProduct(DatabaseProduct.INFOBRIGHT)
+          .withIdentifierQuoteString("`"));
+
+  /** Creates an InfobrightSqlDialect. */
+  public InfobrightSqlDialect(Context context) {
+    super(context);
+  }
+}
+
+// End InfobrightSqlDialect.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/main/java/org/apache/calcite/sql/dialect/InformixSqlDialect.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/dialect/InformixSqlDialect.java 
b/core/src/main/java/org/apache/calcite/sql/dialect/InformixSqlDialect.java
new file mode 100644
index 0000000..cf5c280
--- /dev/null
+++ b/core/src/main/java/org/apache/calcite/sql/dialect/InformixSqlDialect.java
@@ -0,0 +1,35 @@
+/*
+ * 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.sql.dialect;
+
+import org.apache.calcite.sql.SqlDialect;
+
+/**
+ * A <code>SqlDialect</code> implementation for the Informix database.
+ */
+public class InformixSqlDialect extends SqlDialect {
+  public static final SqlDialect DEFAULT =
+      new InformixSqlDialect(EMPTY_CONTEXT
+          .withDatabaseProduct(DatabaseProduct.INFORMIX));
+
+  /** Creates an InformixSqlDialect. */
+  public InformixSqlDialect(Context context) {
+    super(context);
+  }
+}
+
+// End InformixSqlDialect.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/main/java/org/apache/calcite/sql/dialect/IngresSqlDialect.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/dialect/IngresSqlDialect.java 
b/core/src/main/java/org/apache/calcite/sql/dialect/IngresSqlDialect.java
new file mode 100644
index 0000000..b9cff58
--- /dev/null
+++ b/core/src/main/java/org/apache/calcite/sql/dialect/IngresSqlDialect.java
@@ -0,0 +1,35 @@
+/*
+ * 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.sql.dialect;
+
+import org.apache.calcite.sql.SqlDialect;
+
+/**
+ * A <code>SqlDialect</code> implementation for the Ingres database.
+ */
+public class IngresSqlDialect extends SqlDialect {
+  public static final SqlDialect DEFAULT =
+      new IngresSqlDialect(EMPTY_CONTEXT
+          .withDatabaseProduct(DatabaseProduct.INGRES));
+
+  /** Creates an IngresSqlDialect. */
+  public IngresSqlDialect(Context context) {
+    super(context);
+  }
+}
+
+// End IngresSqlDialect.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/main/java/org/apache/calcite/sql/dialect/InterbaseSqlDialect.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/dialect/InterbaseSqlDialect.java 
b/core/src/main/java/org/apache/calcite/sql/dialect/InterbaseSqlDialect.java
new file mode 100644
index 0000000..1712fc9
--- /dev/null
+++ b/core/src/main/java/org/apache/calcite/sql/dialect/InterbaseSqlDialect.java
@@ -0,0 +1,35 @@
+/*
+ * 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.sql.dialect;
+
+import org.apache.calcite.sql.SqlDialect;
+
+/**
+ * A <code>SqlDialect</code> implementation for the Interbase database.
+ */
+public class InterbaseSqlDialect extends SqlDialect {
+  public static final SqlDialect DEFAULT =
+      new InterbaseSqlDialect(EMPTY_CONTEXT
+          .withDatabaseProduct(DatabaseProduct.INTERBASE));
+
+  /** Creates an InterbaseSqlDialect. */
+  public InterbaseSqlDialect(Context context) {
+    super(context);
+  }
+}
+
+// End InterbaseSqlDialect.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/main/java/org/apache/calcite/sql/dialect/LucidDbSqlDialect.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/dialect/LucidDbSqlDialect.java 
b/core/src/main/java/org/apache/calcite/sql/dialect/LucidDbSqlDialect.java
new file mode 100644
index 0000000..7d2f72a
--- /dev/null
+++ b/core/src/main/java/org/apache/calcite/sql/dialect/LucidDbSqlDialect.java
@@ -0,0 +1,36 @@
+/*
+ * 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.sql.dialect;
+
+import org.apache.calcite.sql.SqlDialect;
+
+/**
+ * A <code>SqlDialect</code> implementation for the LucidDB database.
+ */
+public class LucidDbSqlDialect extends SqlDialect {
+  public static final SqlDialect DEFAULT =
+      new LucidDbSqlDialect(EMPTY_CONTEXT
+          .withDatabaseProduct(DatabaseProduct.LUCIDDB)
+          .withIdentifierQuoteString("\""));
+
+  /** Creates a LucidDbSqlDialect. */
+  public LucidDbSqlDialect(Context context) {
+    super(context);
+  }
+}
+
+// End LucidDbSqlDialect.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/main/java/org/apache/calcite/sql/dialect/MssqlHandler.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/dialect/MssqlHandler.java 
b/core/src/main/java/org/apache/calcite/sql/dialect/MssqlHandler.java
deleted file mode 100644
index 31aa287..0000000
--- a/core/src/main/java/org/apache/calcite/sql/dialect/MssqlHandler.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * 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.sql.dialect;
-
-import org.apache.calcite.avatica.util.TimeUnitRange;
-import org.apache.calcite.sql.SqlCall;
-import org.apache.calcite.sql.SqlDialect;
-import org.apache.calcite.sql.SqlFunction;
-import org.apache.calcite.sql.SqlFunctionCategory;
-import org.apache.calcite.sql.SqlKind;
-import org.apache.calcite.sql.SqlLiteral;
-import org.apache.calcite.sql.SqlUtil;
-import org.apache.calcite.sql.SqlWriter;
-import org.apache.calcite.sql.fun.SqlStdOperatorTable;
-import org.apache.calcite.sql.type.ReturnTypes;
-
-/**
- * Defines how a SQL parse tree should be unparsed to SQL
- * for execution against a Microsoft SQL Server database.
- *
- * <p>It reverts to the unparse method of the operator
- * if this database's implementation is standard.
- */
-public class MssqlHandler extends SqlDialect.BaseHandler {
-  public static final MssqlHandler INSTANCE = new MssqlHandler();
-  public static final SqlFunction MSSQL_SUBSTRING =
-      new SqlFunction("SUBSTRING", SqlKind.OTHER_FUNCTION,
-          ReturnTypes.ARG0_NULLABLE_VARYING, null, null,
-          SqlFunctionCategory.STRING);
-
-  @Override public void unparseCall(SqlWriter writer, SqlCall call,
-      int leftPrec, int rightPrec) {
-    if (call.getOperator() == SqlStdOperatorTable.SUBSTRING) {
-      if (call.operandCount() != 3) {
-        throw new IllegalArgumentException("MSSQL SUBSTRING requires FROM and 
FOR arguments");
-      }
-      SqlUtil.unparseFunctionSyntax(MSSQL_SUBSTRING, writer, call);
-
-    } else {
-      switch (call.getKind()) {
-      case FLOOR:
-        if (call.operandCount() != 2) {
-          super.unparseCall(writer, call, leftPrec, rightPrec);
-          return;
-        }
-        unparseFloor(writer, call);
-        break;
-
-      default:
-        super.unparseCall(writer, call, leftPrec, rightPrec);
-      }
-    }
-  }
-
-  /**
-   * Unparses datetime floor for Microsoft SQL Server.
-   * There is no TRUNC function, so simulate this using calls to CONVERT.
-   *
-   * @param writer Writer
-   * @param call Call
-   */
-  private void unparseFloor(SqlWriter writer, SqlCall call) {
-    SqlLiteral node = call.operand(1);
-    TimeUnitRange unit = (TimeUnitRange) node.getValue();
-
-    switch (unit) {
-    case YEAR:
-      unparseFloorWithUnit(writer, call, 4, "-01-01");
-      break;
-    case MONTH:
-      unparseFloorWithUnit(writer, call, 7, "-01");
-      break;
-    case WEEK:
-      writer.print("CONVERT(DATETIME, CONVERT(VARCHAR(10), "
-          + "DATEADD(day, - (6 + DATEPART(weekday, ");
-      call.operand(0).unparse(writer, 0, 0);
-      writer.print(")) % 7, ");
-      call.operand(0).unparse(writer, 0, 0);
-      writer.print("), 126))");
-      break;
-    case DAY:
-      unparseFloorWithUnit(writer, call, 10, "");
-      break;
-    case HOUR:
-      unparseFloorWithUnit(writer, call, 13, ":00:00");
-      break;
-    case MINUTE:
-      unparseFloorWithUnit(writer, call, 16, ":00");
-      break;
-    case SECOND:
-      unparseFloorWithUnit(writer, call, 19, ":00");
-      break;
-    default:
-      throw new IllegalArgumentException("MSSQL does not support FLOOR for 
time unit: "
-          + unit);
-    }
-  }
-
-  private void unparseFloorWithUnit(SqlWriter writer, SqlCall call, int 
charLen,
-      String offset) {
-    writer.print("CONVERT");
-    SqlWriter.Frame frame = writer.startList("(", ")");
-    writer.print("DATETIME, CONVERT(VARCHAR(" + charLen + "), ");
-    call.operand(0).unparse(writer, 0, 0);
-    writer.print(", 126)");
-
-    if (offset.length() > 0) {
-      writer.print("+'" + offset + "'");
-    }
-    writer.endList(frame);
-  }
-}
-
-// End MssqlHandler.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/main/java/org/apache/calcite/sql/dialect/MssqlSqlDialect.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/dialect/MssqlSqlDialect.java 
b/core/src/main/java/org/apache/calcite/sql/dialect/MssqlSqlDialect.java
new file mode 100644
index 0000000..3ee35e1
--- /dev/null
+++ b/core/src/main/java/org/apache/calcite/sql/dialect/MssqlSqlDialect.java
@@ -0,0 +1,139 @@
+/*
+ * 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.sql.dialect;
+
+import org.apache.calcite.avatica.util.TimeUnitRange;
+import org.apache.calcite.sql.SqlAbstractDateTimeLiteral;
+import org.apache.calcite.sql.SqlCall;
+import org.apache.calcite.sql.SqlDialect;
+import org.apache.calcite.sql.SqlFunction;
+import org.apache.calcite.sql.SqlFunctionCategory;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlLiteral;
+import org.apache.calcite.sql.SqlUtil;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.fun.SqlStdOperatorTable;
+import org.apache.calcite.sql.type.ReturnTypes;
+
+/**
+ * A <code>SqlDialect</code> implementation for the Microsoft SQL Server
+ * database.
+ */
+public class MssqlSqlDialect extends SqlDialect {
+  public static final SqlDialect DEFAULT =
+      new MssqlSqlDialect(EMPTY_CONTEXT
+          .withDatabaseProduct(DatabaseProduct.MSSQL)
+          .withIdentifierQuoteString("["));
+
+  private static final SqlFunction MSSQL_SUBSTRING =
+      new SqlFunction("SUBSTRING", SqlKind.OTHER_FUNCTION,
+          ReturnTypes.ARG0_NULLABLE_VARYING, null, null,
+          SqlFunctionCategory.STRING);
+
+  /** Creates a MssqlSqlDialect. */
+  public MssqlSqlDialect(Context context) {
+    super(context);
+  }
+
+  @Override public void unparseDateTimeLiteral(SqlWriter writer,
+      SqlAbstractDateTimeLiteral literal, int leftPrec, int rightPrec) {
+    writer.literal("'" + literal.toFormattedString() + "'");
+  }
+
+  @Override public void unparseCall(SqlWriter writer, SqlCall call,
+      int leftPrec, int rightPrec) {
+    if (call.getOperator() == SqlStdOperatorTable.SUBSTRING) {
+      if (call.operandCount() != 3) {
+        throw new IllegalArgumentException("MSSQL SUBSTRING requires FROM and 
FOR arguments");
+      }
+      SqlUtil.unparseFunctionSyntax(MSSQL_SUBSTRING, writer, call);
+    } else {
+      switch (call.getKind()) {
+      case FLOOR:
+        if (call.operandCount() != 2) {
+          super.unparseCall(writer, call, leftPrec, rightPrec);
+          return;
+        }
+        unparseFloor(writer, call);
+        break;
+
+      default:
+        super.unparseCall(writer, call, leftPrec, rightPrec);
+      }
+    }
+  }
+
+  /**
+   * Unparses datetime floor for Microsoft SQL Server.
+   * There is no TRUNC function, so simulate this using calls to CONVERT.
+   *
+   * @param writer Writer
+   * @param call Call
+   */
+  private void unparseFloor(SqlWriter writer, SqlCall call) {
+    SqlLiteral node = call.operand(1);
+    TimeUnitRange unit = (TimeUnitRange) node.getValue();
+
+    switch (unit) {
+    case YEAR:
+      unparseFloorWithUnit(writer, call, 4, "-01-01");
+      break;
+    case MONTH:
+      unparseFloorWithUnit(writer, call, 7, "-01");
+      break;
+    case WEEK:
+      writer.print("CONVERT(DATETIME, CONVERT(VARCHAR(10), "
+          + "DATEADD(day, - (6 + DATEPART(weekday, ");
+      call.operand(0).unparse(writer, 0, 0);
+      writer.print(")) % 7, ");
+      call.operand(0).unparse(writer, 0, 0);
+      writer.print("), 126))");
+      break;
+    case DAY:
+      unparseFloorWithUnit(writer, call, 10, "");
+      break;
+    case HOUR:
+      unparseFloorWithUnit(writer, call, 13, ":00:00");
+      break;
+    case MINUTE:
+      unparseFloorWithUnit(writer, call, 16, ":00");
+      break;
+    case SECOND:
+      unparseFloorWithUnit(writer, call, 19, ":00");
+      break;
+    default:
+      throw new IllegalArgumentException("MSSQL does not support FLOOR for 
time unit: "
+          + unit);
+    }
+  }
+
+  private void unparseFloorWithUnit(SqlWriter writer, SqlCall call, int 
charLen,
+      String offset) {
+    writer.print("CONVERT");
+    SqlWriter.Frame frame = writer.startList("(", ")");
+    writer.print("DATETIME, CONVERT(VARCHAR(" + charLen + "), ");
+    call.operand(0).unparse(writer, 0, 0);
+    writer.print(", 126)");
+
+    if (offset.length() > 0) {
+      writer.print("+'" + offset + "'");
+    }
+    writer.endList(frame);
+  }
+}
+
+// End MssqlSqlDialect.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/main/java/org/apache/calcite/sql/dialect/MysqlHandler.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/dialect/MysqlHandler.java 
b/core/src/main/java/org/apache/calcite/sql/dialect/MysqlHandler.java
deleted file mode 100644
index adf7061..0000000
--- a/core/src/main/java/org/apache/calcite/sql/dialect/MysqlHandler.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * 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.sql.dialect;
-
-import org.apache.calcite.avatica.util.TimeUnitRange;
-import org.apache.calcite.sql.SqlCall;
-import org.apache.calcite.sql.SqlDialect;
-import org.apache.calcite.sql.SqlLiteral;
-import org.apache.calcite.sql.SqlWriter;
-
-/**
- * Defines how a SQL parse tree should be unparsed to SQL
- * for execution against a MySQL database.
- *
- * <p>It reverts to the unparse method of the operator
- * if this database's implementation is standard.
- */
-public class MysqlHandler extends SqlDialect.BaseHandler {
-  public static final MysqlHandler INSTANCE = new MysqlHandler();
-
-  @Override public void unparseCall(SqlWriter writer, SqlCall call,
-      int leftPrec, int rightPrec) {
-    switch (call.getKind()) {
-    case FLOOR:
-      if (call.operandCount() != 2) {
-        super.unparseCall(writer, call, leftPrec, rightPrec);
-        return;
-      }
-
-      unparseFloor(writer, call);
-      break;
-
-    default:
-      super.unparseCall(writer, call, leftPrec, rightPrec);
-    }
-  }
-
-  /**
-   * Unparses datetime floor for MySQL. There is no TRUNC function, so simulate
-   * this using calls to DATE_FORMAT.
-   *
-   * @param writer Writer
-   * @param call Call
-   */
-  private void unparseFloor(SqlWriter writer, SqlCall call) {
-    SqlLiteral node = call.operand(1);
-    TimeUnitRange unit = (TimeUnitRange) node.getValue();
-
-    if (unit == TimeUnitRange.WEEK) {
-      writer.print("STR_TO_DATE");
-      SqlWriter.Frame frame = writer.startList("(", ")");
-
-      writer.print("DATE_FORMAT(");
-      call.operand(0).unparse(writer, 0, 0);
-      writer.print(", '%x%v-1'), '%x%v-%w'");
-      writer.endList(frame);
-      return;
-    }
-
-    String format;
-    switch (unit) {
-    case YEAR:
-      format = "%Y-01-01";
-      break;
-    case MONTH:
-      format = "%Y-%m-01";
-      break;
-    case DAY:
-      format = "%Y-%m-%d";
-      break;
-    case HOUR:
-      format = "%Y-%m-%d %k:00:00";
-      break;
-    case MINUTE:
-      format = "%Y-%m-%d %k:%i:00";
-      break;
-    case SECOND:
-      format = "%Y-%m-%d %k:%i:%s";
-      break;
-    default:
-      throw new AssertionError("MYSQL does not support FLOOR for time unit: "
-          + unit);
-    }
-
-    writer.print("DATE_FORMAT");
-    SqlWriter.Frame frame = writer.startList("(", ")");
-    call.operand(0).unparse(writer, 0, 0);
-    writer.sep(",", true);
-    writer.print("'" + format + "'");
-    writer.endList(frame);
-  }
-}
-
-// End MysqlHandler.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/main/java/org/apache/calcite/sql/dialect/MysqlSqlDialect.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/dialect/MysqlSqlDialect.java 
b/core/src/main/java/org/apache/calcite/sql/dialect/MysqlSqlDialect.java
new file mode 100644
index 0000000..e9ae479
--- /dev/null
+++ b/core/src/main/java/org/apache/calcite/sql/dialect/MysqlSqlDialect.java
@@ -0,0 +1,215 @@
+/*
+ * 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.sql.dialect;
+
+import org.apache.calcite.avatica.util.TimeUnitRange;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.sql.SqlBasicCall;
+import org.apache.calcite.sql.SqlCall;
+import org.apache.calcite.sql.SqlDataTypeSpec;
+import org.apache.calcite.sql.SqlDialect;
+import org.apache.calcite.sql.SqlFunction;
+import org.apache.calcite.sql.SqlFunctionCategory;
+import org.apache.calcite.sql.SqlIdentifier;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlLiteral;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlNodeList;
+import org.apache.calcite.sql.SqlSelect;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.fun.SqlCase;
+import org.apache.calcite.sql.fun.SqlStdOperatorTable;
+import org.apache.calcite.sql.parser.SqlParserPos;
+import org.apache.calcite.sql.type.InferTypes;
+import org.apache.calcite.sql.type.OperandTypes;
+import org.apache.calcite.sql.type.ReturnTypes;
+
+/**
+ * A <code>SqlDialect</code> implementation for the MySQL database.
+ */
+public class MysqlSqlDialect extends SqlDialect {
+  public static final SqlDialect DEFAULT =
+      new MysqlSqlDialect(EMPTY_CONTEXT
+          .withDatabaseProduct(DatabaseProduct.MYSQL)
+          .withIdentifierQuoteString("`"));
+
+  /** MySQL specific function. */
+  public static final SqlFunction ISNULL_FUNCTION =
+      new SqlFunction("ISNULL", SqlKind.OTHER_FUNCTION,
+          ReturnTypes.BOOLEAN, InferTypes.FIRST_KNOWN,
+          OperandTypes.ANY, SqlFunctionCategory.SYSTEM);
+
+  /** Creates a MysqlSqlDialect. */
+  public MysqlSqlDialect(Context context) {
+    super(context);
+  }
+
+  @Override public boolean supportsCharSet() {
+    return false;
+  }
+
+  @Override public boolean supportsOffsetFetch() {
+    return false;
+  }
+
+  @Override public SqlNode emulateNullDirection(SqlNode node, boolean 
nullsFirst) {
+    node = ISNULL_FUNCTION.createCall(SqlParserPos.ZERO, node);
+    if (nullsFirst) {
+      node = SqlStdOperatorTable.DESC.createCall(SqlParserPos.ZERO, node);
+    }
+    return node;
+  }
+
+  @Override public boolean supportsAggregateFunction(SqlKind kind) {
+    switch (kind) {
+    case COUNT:
+    case SUM:
+    case SUM0:
+    case MIN:
+    case MAX:
+    case SINGLE_VALUE:
+      return true;
+    }
+    return false;
+  }
+
+  @Override public boolean supportsNestedAggregations() {
+    return false;
+  }
+
+  @Override public CalendarPolicy getCalendarPolicy() {
+    return CalendarPolicy.SHIFT;
+  }
+
+  @Override public SqlNode getCastSpec(RelDataType type) {
+    switch (type.getSqlTypeName()) {
+    case VARCHAR:
+      // MySQL doesn't have a VARCHAR type, only CHAR.
+      return new SqlDataTypeSpec(new SqlIdentifier("CHAR", SqlParserPos.ZERO),
+          type.getPrecision(), -1, null, null, SqlParserPos.ZERO);
+    case INTEGER:
+      return new SqlDataTypeSpec(new SqlIdentifier("_UNSIGNED", 
SqlParserPos.ZERO),
+          type.getPrecision(), -1, null, null, SqlParserPos.ZERO);
+    }
+    return super.getCastSpec(type);
+  }
+
+  @Override public SqlNode rewriteSingleValueExpr(SqlNode aggCall) {
+    final SqlNode operand = ((SqlBasicCall) aggCall).operand(0);
+    final SqlLiteral nullLiteral = SqlLiteral.createNull(SqlParserPos.ZERO);
+    final SqlNode unionOperand = new SqlSelect(SqlParserPos.ZERO, 
SqlNodeList.EMPTY,
+        SqlNodeList.of(nullLiteral), null, null, null, null, 
SqlNodeList.EMPTY, null, null, null);
+    // For MySQL, generate
+    //   CASE COUNT(*)
+    //   WHEN 0 THEN NULL
+    //   WHEN 1 THEN <result>
+    //   ELSE (SELECT NULL UNION ALL SELECT NULL)
+    //   END
+    final SqlNode caseExpr =
+        new SqlCase(SqlParserPos.ZERO,
+            SqlStdOperatorTable.COUNT.createCall(SqlParserPos.ZERO, operand),
+            SqlNodeList.of(
+                SqlLiteral.createExactNumeric("0", SqlParserPos.ZERO),
+                SqlLiteral.createExactNumeric("1", SqlParserPos.ZERO)
+            ),
+            SqlNodeList.of(
+                nullLiteral,
+                operand
+            ),
+            SqlStdOperatorTable.SCALAR_QUERY.createCall(SqlParserPos.ZERO,
+                SqlStdOperatorTable.UNION_ALL
+                    .createCall(SqlParserPos.ZERO, unionOperand, 
unionOperand)));
+
+    LOGGER.debug("SINGLE_VALUE rewritten into [{}]", caseExpr);
+
+    return caseExpr;
+  }
+
+  @Override public void unparseCall(SqlWriter writer, SqlCall call,
+      int leftPrec, int rightPrec) {
+    switch (call.getKind()) {
+    case FLOOR:
+      if (call.operandCount() != 2) {
+        super.unparseCall(writer, call, leftPrec, rightPrec);
+        return;
+      }
+
+      unparseFloor(writer, call);
+      break;
+
+    default:
+      super.unparseCall(writer, call, leftPrec, rightPrec);
+    }
+  }
+
+  /**
+   * Unparses datetime floor for MySQL. There is no TRUNC function, so simulate
+   * this using calls to DATE_FORMAT.
+   *
+   * @param writer Writer
+   * @param call Call
+   */
+  private void unparseFloor(SqlWriter writer, SqlCall call) {
+    SqlLiteral node = call.operand(1);
+    TimeUnitRange unit = (TimeUnitRange) node.getValue();
+
+    if (unit == TimeUnitRange.WEEK) {
+      writer.print("STR_TO_DATE");
+      SqlWriter.Frame frame = writer.startList("(", ")");
+
+      writer.print("DATE_FORMAT(");
+      call.operand(0).unparse(writer, 0, 0);
+      writer.print(", '%x%v-1'), '%x%v-%w'");
+      writer.endList(frame);
+      return;
+    }
+
+    String format;
+    switch (unit) {
+    case YEAR:
+      format = "%Y-01-01";
+      break;
+    case MONTH:
+      format = "%Y-%m-01";
+      break;
+    case DAY:
+      format = "%Y-%m-%d";
+      break;
+    case HOUR:
+      format = "%Y-%m-%d %k:00:00";
+      break;
+    case MINUTE:
+      format = "%Y-%m-%d %k:%i:00";
+      break;
+    case SECOND:
+      format = "%Y-%m-%d %k:%i:%s";
+      break;
+    default:
+      throw new AssertionError("MYSQL does not support FLOOR for time unit: "
+          + unit);
+    }
+
+    writer.print("DATE_FORMAT");
+    SqlWriter.Frame frame = writer.startList("(", ")");
+    call.operand(0).unparse(writer, 0, 0);
+    writer.sep(",", true);
+    writer.print("'" + format + "'");
+    writer.endList(frame);
+  }
+}
+
+// End MysqlSqlDialect.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/main/java/org/apache/calcite/sql/dialect/NeoviewSqlDialect.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/dialect/NeoviewSqlDialect.java 
b/core/src/main/java/org/apache/calcite/sql/dialect/NeoviewSqlDialect.java
new file mode 100644
index 0000000..7b0b67a
--- /dev/null
+++ b/core/src/main/java/org/apache/calcite/sql/dialect/NeoviewSqlDialect.java
@@ -0,0 +1,35 @@
+/*
+ * 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.sql.dialect;
+
+import org.apache.calcite.sql.SqlDialect;
+
+/**
+ * A <code>SqlDialect</code> implementation for the Neoview database.
+ */
+public class NeoviewSqlDialect extends SqlDialect {
+  public static final SqlDialect DEFAULT =
+      new NeoviewSqlDialect(EMPTY_CONTEXT
+          .withDatabaseProduct(DatabaseProduct.NEOVIEW));
+
+  /** Creates a NeoviewSqlDialect. */
+  public NeoviewSqlDialect(Context context) {
+    super(context);
+  }
+}
+
+// End NeoviewSqlDialect.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/main/java/org/apache/calcite/sql/dialect/NetezzaSqlDialect.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/dialect/NetezzaSqlDialect.java 
b/core/src/main/java/org/apache/calcite/sql/dialect/NetezzaSqlDialect.java
new file mode 100644
index 0000000..60be00c
--- /dev/null
+++ b/core/src/main/java/org/apache/calcite/sql/dialect/NetezzaSqlDialect.java
@@ -0,0 +1,36 @@
+/*
+ * 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.sql.dialect;
+
+import org.apache.calcite.sql.SqlDialect;
+
+/**
+ * A <code>SqlDialect</code> implementation for the Netezza database.
+ */
+public class NetezzaSqlDialect extends SqlDialect {
+  public static final SqlDialect DEFAULT =
+      new NetezzaSqlDialect(EMPTY_CONTEXT
+          .withDatabaseProduct(DatabaseProduct.NETEZZA)
+          .withIdentifierQuoteString("\""));
+
+  /** Creates a NetezzaSqlDialect. */
+  public NetezzaSqlDialect(Context context) {
+    super(context);
+  }
+}
+
+// End NetezzaSqlDialect.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/main/java/org/apache/calcite/sql/dialect/OracleHandler.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/dialect/OracleHandler.java 
b/core/src/main/java/org/apache/calcite/sql/dialect/OracleHandler.java
deleted file mode 100644
index a67eb01..0000000
--- a/core/src/main/java/org/apache/calcite/sql/dialect/OracleHandler.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.sql.dialect;
-
-import org.apache.calcite.avatica.util.TimeUnitRange;
-import org.apache.calcite.sql.SqlCall;
-import org.apache.calcite.sql.SqlDialect;
-import org.apache.calcite.sql.SqlLiteral;
-import org.apache.calcite.sql.SqlUtil;
-import org.apache.calcite.sql.SqlWriter;
-import org.apache.calcite.sql.fun.OracleSqlOperatorTable;
-import org.apache.calcite.sql.fun.SqlFloorFunction;
-import org.apache.calcite.sql.fun.SqlStdOperatorTable;
-
-/**
- * Defines how a SQL parse tree should be unparsed to SQL
- * for execution against an Oracle database.
- *
- * <p>It reverts to the unparse method of the operator
- * if this database's implementation is standard.
- */
-public class OracleHandler extends SqlDialect.BaseHandler {
-  public static final OracleHandler INSTANCE = new OracleHandler();
-
-  @Override public void unparseCall(SqlWriter writer, SqlCall call,
-      int leftPrec, int rightPrec) {
-    if (call.getOperator() == SqlStdOperatorTable.SUBSTRING) {
-      SqlUtil.unparseFunctionSyntax(OracleSqlOperatorTable.SUBSTR, writer, 
call);
-
-    } else {
-      switch (call.getKind()) {
-      case FLOOR:
-        if (call.operandCount() != 2) {
-          super.unparseCall(writer, call, leftPrec, rightPrec);
-          return;
-        }
-
-        final SqlLiteral timeUnitNode = call.operand(1);
-        final TimeUnitRange timeUnit = 
timeUnitNode.getValueAs(TimeUnitRange.class);
-
-        SqlCall call2 = SqlFloorFunction.replaceTimeUnitOperand(call, 
timeUnit.name(),
-            timeUnitNode.getParserPosition());
-        SqlFloorFunction.unparseDatetimeFunction(writer, call2, "TRUNC", true);
-        break;
-
-      default:
-        super.unparseCall(writer, call, leftPrec, rightPrec);
-      }
-    }
-  }
-}
-
-// End OracleHandler.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/main/java/org/apache/calcite/sql/dialect/OracleSqlDialect.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/dialect/OracleSqlDialect.java 
b/core/src/main/java/org/apache/calcite/sql/dialect/OracleSqlDialect.java
new file mode 100644
index 0000000..cdac9d7
--- /dev/null
+++ b/core/src/main/java/org/apache/calcite/sql/dialect/OracleSqlDialect.java
@@ -0,0 +1,78 @@
+/*
+ * 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.sql.dialect;
+
+import org.apache.calcite.avatica.util.TimeUnitRange;
+import org.apache.calcite.sql.SqlCall;
+import org.apache.calcite.sql.SqlDialect;
+import org.apache.calcite.sql.SqlLiteral;
+import org.apache.calcite.sql.SqlUtil;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.fun.OracleSqlOperatorTable;
+import org.apache.calcite.sql.fun.SqlFloorFunction;
+import org.apache.calcite.sql.fun.SqlStdOperatorTable;
+
+/**
+ * A <code>SqlDialect</code> implementation for the Oracle database.
+ */
+public class OracleSqlDialect extends SqlDialect {
+  public static final SqlDialect DEFAULT =
+      new OracleSqlDialect(EMPTY_CONTEXT
+          .withDatabaseProduct(DatabaseProduct.ORACLE)
+          .withIdentifierQuoteString("\""));
+
+  /** Creates an OracleSqlDialect. */
+  public OracleSqlDialect(Context context) {
+    super(context);
+  }
+
+  @Override public boolean supportsCharSet() {
+    return false;
+  }
+
+  @Override protected boolean allowsAs() {
+    return false;
+  }
+
+  @Override public void unparseCall(SqlWriter writer, SqlCall call,
+      int leftPrec, int rightPrec) {
+    if (call.getOperator() == SqlStdOperatorTable.SUBSTRING) {
+      SqlUtil.unparseFunctionSyntax(OracleSqlOperatorTable.SUBSTR, writer, 
call);
+    } else {
+      switch (call.getKind()) {
+      case FLOOR:
+        if (call.operandCount() != 2) {
+          super.unparseCall(writer, call, leftPrec, rightPrec);
+          return;
+        }
+
+        final SqlLiteral timeUnitNode = call.operand(1);
+        final TimeUnitRange timeUnit = 
timeUnitNode.getValueAs(TimeUnitRange.class);
+
+        SqlCall call2 = SqlFloorFunction.replaceTimeUnitOperand(call, 
timeUnit.name(),
+            timeUnitNode.getParserPosition());
+        SqlFloorFunction.unparseDatetimeFunction(writer, call2, "TRUNC", true);
+        break;
+
+      default:
+        super.unparseCall(writer, call, leftPrec, rightPrec);
+      }
+    }
+  }
+}
+
+// End OracleSqlDialect.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/main/java/org/apache/calcite/sql/dialect/ParaccelSqlDialect.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/dialect/ParaccelSqlDialect.java 
b/core/src/main/java/org/apache/calcite/sql/dialect/ParaccelSqlDialect.java
new file mode 100644
index 0000000..07b2d24
--- /dev/null
+++ b/core/src/main/java/org/apache/calcite/sql/dialect/ParaccelSqlDialect.java
@@ -0,0 +1,36 @@
+/*
+ * 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.sql.dialect;
+
+import org.apache.calcite.sql.SqlDialect;
+
+/**
+ * A <code>SqlDialect</code> implementation for the Paraccel database.
+ */
+public class ParaccelSqlDialect extends SqlDialect {
+  public static final SqlDialect DEFAULT =
+      new ParaccelSqlDialect(EMPTY_CONTEXT
+          .withDatabaseProduct(DatabaseProduct.PARACCEL)
+          .withIdentifierQuoteString("\""));
+
+  /** Creates a ParaccelSqlDialect. */
+  public ParaccelSqlDialect(Context context) {
+    super(context);
+  }
+}
+
+// End ParaccelSqlDialect.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/main/java/org/apache/calcite/sql/dialect/PhoenixSqlDialect.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/dialect/PhoenixSqlDialect.java 
b/core/src/main/java/org/apache/calcite/sql/dialect/PhoenixSqlDialect.java
new file mode 100644
index 0000000..cb409fe
--- /dev/null
+++ b/core/src/main/java/org/apache/calcite/sql/dialect/PhoenixSqlDialect.java
@@ -0,0 +1,40 @@
+/*
+ * 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.sql.dialect;
+
+import org.apache.calcite.sql.SqlDialect;
+
+/**
+ * A <code>SqlDialect</code> implementation for the Apache Phoenix database.
+ */
+public class PhoenixSqlDialect extends SqlDialect {
+  public static final SqlDialect DEFAULT =
+      new PhoenixSqlDialect(EMPTY_CONTEXT
+          .withDatabaseProduct(DatabaseProduct.PHOENIX)
+          .withIdentifierQuoteString("\""));
+
+  /** Creates a PhoenixSqlDialect. */
+  public PhoenixSqlDialect(Context context) {
+    super(context);
+  }
+
+  @Override public boolean supportsCharSet() {
+    return false;
+  }
+}
+
+// End PhoenixSqlDialect.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/main/java/org/apache/calcite/sql/dialect/PostgresqlHandler.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/dialect/PostgresqlHandler.java 
b/core/src/main/java/org/apache/calcite/sql/dialect/PostgresqlHandler.java
deleted file mode 100644
index 8b35346..0000000
--- a/core/src/main/java/org/apache/calcite/sql/dialect/PostgresqlHandler.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.sql.dialect;
-
-import org.apache.calcite.avatica.util.TimeUnitRange;
-import org.apache.calcite.sql.SqlCall;
-import org.apache.calcite.sql.SqlDialect;
-import org.apache.calcite.sql.SqlLiteral;
-import org.apache.calcite.sql.SqlWriter;
-import org.apache.calcite.sql.fun.SqlFloorFunction;
-
-/**
- * Defines how a SQL parse tree should be unparsed to SQL
- * for execution against a Postgresql database.
- *
- * <p>It reverts to the unparse method of the operator
- * if this database's implementation is standard.
- */
-public class PostgresqlHandler extends SqlDialect.BaseHandler {
-  public static final PostgresqlHandler INSTANCE = new PostgresqlHandler();
-
-  @Override public void unparseCall(SqlWriter writer, SqlCall call,
-      int leftPrec, int rightPrec) {
-    switch (call.getKind()) {
-    case FLOOR:
-      if (call.operandCount() != 2) {
-        super.unparseCall(writer, call, leftPrec, rightPrec);
-        return;
-      }
-
-      final SqlLiteral timeUnitNode = call.operand(1);
-      final TimeUnitRange timeUnit = 
timeUnitNode.getValueAs(TimeUnitRange.class);
-
-      SqlCall call2 = SqlFloorFunction.replaceTimeUnitOperand(call, 
timeUnit.name(),
-          timeUnitNode.getParserPosition());
-      SqlFloorFunction.unparseDatetimeFunction(writer, call2, "DATE_TRUNC", 
false);
-      break;
-
-    default:
-      super.unparseCall(writer, call, leftPrec, rightPrec);
-    }
-  }
-}
-
-// End PostgresqlHandler.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/main/java/org/apache/calcite/sql/dialect/PostgresqlSqlDialect.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/dialect/PostgresqlSqlDialect.java 
b/core/src/main/java/org/apache/calcite/sql/dialect/PostgresqlSqlDialect.java
new file mode 100644
index 0000000..6a6014e
--- /dev/null
+++ 
b/core/src/main/java/org/apache/calcite/sql/dialect/PostgresqlSqlDialect.java
@@ -0,0 +1,75 @@
+/*
+ * 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.sql.dialect;
+
+import org.apache.calcite.avatica.util.TimeUnitRange;
+import org.apache.calcite.sql.SqlCall;
+import org.apache.calcite.sql.SqlDialect;
+import org.apache.calcite.sql.SqlLiteral;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.fun.SqlFloorFunction;
+
+/**
+ * A <code>SqlDialect</code> implementation for the PostgreSQL database.
+ */
+public class PostgresqlSqlDialect extends SqlDialect {
+  public static final SqlDialect DEFAULT =
+      new PostgresqlSqlDialect(EMPTY_CONTEXT
+          .withDatabaseProduct(DatabaseProduct.POSTGRESQL)
+          .withIdentifierQuoteString("\""));
+
+  /** Creates a PostgresqlSqlDialect. */
+  public PostgresqlSqlDialect(Context context) {
+    super(context);
+  }
+
+  @Override public boolean supportsCharSet() {
+    return false;
+  }
+
+  @Override protected boolean requiresAliasForFromItems() {
+    return true;
+  }
+
+  @Override public boolean supportsNestedAggregations() {
+    return false;
+  }
+
+  @Override public void unparseCall(SqlWriter writer, SqlCall call,
+      int leftPrec, int rightPrec) {
+    switch (call.getKind()) {
+    case FLOOR:
+      if (call.operandCount() != 2) {
+        super.unparseCall(writer, call, leftPrec, rightPrec);
+        return;
+      }
+
+      final SqlLiteral timeUnitNode = call.operand(1);
+      final TimeUnitRange timeUnit = 
timeUnitNode.getValueAs(TimeUnitRange.class);
+
+      SqlCall call2 = SqlFloorFunction.replaceTimeUnitOperand(call, 
timeUnit.name(),
+          timeUnitNode.getParserPosition());
+      SqlFloorFunction.unparseDatetimeFunction(writer, call2, "DATE_TRUNC", 
false);
+      break;
+
+    default:
+      super.unparseCall(writer, call, leftPrec, rightPrec);
+    }
+  }
+}
+
+// End PostgresqlSqlDialect.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/main/java/org/apache/calcite/sql/dialect/RedshiftSqlDialect.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/dialect/RedshiftSqlDialect.java 
b/core/src/main/java/org/apache/calcite/sql/dialect/RedshiftSqlDialect.java
new file mode 100644
index 0000000..33ba101
--- /dev/null
+++ b/core/src/main/java/org/apache/calcite/sql/dialect/RedshiftSqlDialect.java
@@ -0,0 +1,40 @@
+/*
+ * 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.sql.dialect;
+
+import org.apache.calcite.sql.SqlDialect;
+
+/**
+ * A <code>SqlDialect</code> implementation for the Redshift database.
+ */
+public class RedshiftSqlDialect extends SqlDialect {
+  public static final SqlDialect DEFAULT =
+      new RedshiftSqlDialect(EMPTY_CONTEXT
+          .withDatabaseProduct(DatabaseProduct.REDSHIFT)
+          .withIdentifierQuoteString("\""));
+
+  /** Creates a RedshiftSqlDialect. */
+  public RedshiftSqlDialect(Context context) {
+    super(context);
+  }
+
+  @Override public boolean supportsOffsetFetch() {
+    return false;
+  }
+}
+
+// End RedshiftSqlDialect.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/main/java/org/apache/calcite/sql/dialect/SybaseSqlDialect.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/dialect/SybaseSqlDialect.java 
b/core/src/main/java/org/apache/calcite/sql/dialect/SybaseSqlDialect.java
new file mode 100644
index 0000000..0b50e4b
--- /dev/null
+++ b/core/src/main/java/org/apache/calcite/sql/dialect/SybaseSqlDialect.java
@@ -0,0 +1,35 @@
+/*
+ * 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.sql.dialect;
+
+import org.apache.calcite.sql.SqlDialect;
+
+/**
+ * A <code>SqlDialect</code> implementation for the Sybase database.
+ */
+public class SybaseSqlDialect extends SqlDialect {
+  public static final SqlDialect DEFAULT =
+      new SybaseSqlDialect(EMPTY_CONTEXT
+          .withDatabaseProduct(DatabaseProduct.SYBASE));
+
+  /** Creates a SybaseSqlDialect. */
+  public SybaseSqlDialect(Context context) {
+    super(context);
+  }
+}
+
+// End SybaseSqlDialect.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/main/java/org/apache/calcite/sql/dialect/TeradataSqlDialect.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/dialect/TeradataSqlDialect.java 
b/core/src/main/java/org/apache/calcite/sql/dialect/TeradataSqlDialect.java
new file mode 100644
index 0000000..b2a52fc
--- /dev/null
+++ b/core/src/main/java/org/apache/calcite/sql/dialect/TeradataSqlDialect.java
@@ -0,0 +1,36 @@
+/*
+ * 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.sql.dialect;
+
+import org.apache.calcite.sql.SqlDialect;
+
+/**
+ * A <code>SqlDialect</code> implementation for the Teradata database.
+ */
+public class TeradataSqlDialect extends SqlDialect {
+  public static final SqlDialect DEFAULT =
+      new TeradataSqlDialect(EMPTY_CONTEXT
+          .withDatabaseProduct(DatabaseProduct.TERADATA)
+          .withIdentifierQuoteString("\""));
+
+  /** Creates a TeradataSqlDialect. */
+  public TeradataSqlDialect(Context context) {
+    super(context);
+  }
+}
+
+// End TeradataSqlDialect.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/main/java/org/apache/calcite/sql/dialect/VerticaSqlDialect.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/dialect/VerticaSqlDialect.java 
b/core/src/main/java/org/apache/calcite/sql/dialect/VerticaSqlDialect.java
new file mode 100644
index 0000000..5781feb
--- /dev/null
+++ b/core/src/main/java/org/apache/calcite/sql/dialect/VerticaSqlDialect.java
@@ -0,0 +1,40 @@
+/*
+ * 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.sql.dialect;
+
+import org.apache.calcite.sql.SqlDialect;
+
+/**
+ * A <code>SqlDialect</code> implementation for the Vertica database.
+ */
+public class VerticaSqlDialect extends SqlDialect {
+  public static final SqlDialect DEFAULT =
+      new VerticaSqlDialect(EMPTY_CONTEXT
+          .withDatabaseProduct(DatabaseProduct.VERTICA)
+          .withIdentifierQuoteString("\""));
+
+  /** Creates a VerticaSqlDialect. */
+  public VerticaSqlDialect(Context context) {
+    super(context);
+  }
+
+  @Override public boolean supportsNestedAggregations() {
+    return false;
+  }
+}
+
+// End VerticaSqlDialect.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/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 dde8d28..0afd951 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
@@ -20,6 +20,7 @@ import org.apache.calcite.avatica.util.Spaces;
 import org.apache.calcite.sql.SqlDialect;
 import org.apache.calcite.sql.SqlNode;
 import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.dialect.AnsiSqlDialect;
 import org.apache.calcite.sql.util.SqlBuilder;
 import org.apache.calcite.sql.util.SqlString;
 import org.apache.calcite.util.Unsafe;
@@ -131,7 +132,7 @@ public class SqlPrettyWriter implements SqlWriter {
    * Bean holding the default property values.
    */
   private static final Bean DEFAULT_BEAN =
-      new SqlPrettyWriter(SqlDialect.DUMMY).getBean();
+      new SqlPrettyWriter(AnsiSqlDialect.DEFAULT).getBean();
   protected static final String NL = System.getProperty("line.separator");
 
   //~ Instance fields --------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/main/java/org/apache/calcite/sql/type/IntervalSqlType.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/type/IntervalSqlType.java 
b/core/src/main/java/org/apache/calcite/sql/type/IntervalSqlType.java
index d4b2284..4789c06 100644
--- a/core/src/main/java/org/apache/calcite/sql/type/IntervalSqlType.java
+++ b/core/src/main/java/org/apache/calcite/sql/type/IntervalSqlType.java
@@ -22,6 +22,7 @@ import org.apache.calcite.rel.type.RelDataTypeFactoryImpl;
 import org.apache.calcite.rel.type.RelDataTypeSystem;
 import org.apache.calcite.sql.SqlDialect;
 import org.apache.calcite.sql.SqlIntervalQualifier;
+import org.apache.calcite.sql.dialect.AnsiSqlDialect;
 import org.apache.calcite.sql.parser.SqlParserPos;
 import org.apache.calcite.sql.pretty.SqlPrettyWriter;
 import org.apache.calcite.sql.util.SqlString;
@@ -56,7 +57,7 @@ public class IntervalSqlType extends AbstractSqlType {
 
   protected void generateTypeString(StringBuilder sb, boolean withDetail) {
     sb.append("INTERVAL ");
-    final SqlDialect dialect = SqlDialect.DUMMY;
+    final SqlDialect dialect = AnsiSqlDialect.DEFAULT;
     final SqlPrettyWriter writer = new SqlPrettyWriter(dialect);
     writer.setAlwaysUseParentheses(false);
     writer.setSelectListItemsOnSeparateLines(false);

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java 
b/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
index fb5d118..6716d3d 100644
--- 
a/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
+++ 
b/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
@@ -30,6 +30,7 @@ import org.apache.calcite.schema.SchemaPlus;
 import org.apache.calcite.sql.SqlDialect;
 import org.apache.calcite.sql.SqlDialect.DatabaseProduct;
 import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.dialect.CalciteSqlDialect;
 import org.apache.calcite.sql.parser.SqlParser;
 import org.apache.calcite.sql2rel.SqlToRelConverter;
 import org.apache.calcite.test.CalciteAssert;
@@ -74,7 +75,7 @@ public class RelToSqlConverterTest {
   /** Initiates a test case with a given SQL query. */
   private Sql sql(String sql) {
     return new Sql(CalciteAssert.SchemaSpec.JDBC_FOODMART, sql,
-        SqlDialect.CALCITE, DEFAULT_REL_CONFIG,
+        CalciteSqlDialect.DEFAULT, DEFAULT_REL_CONFIG,
         ImmutableList.<Function<RelNode, RelNode>>of());
   }
 

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/test/java/org/apache/calcite/sql/parser/SqlParserTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/calcite/sql/parser/SqlParserTest.java 
b/core/src/test/java/org/apache/calcite/sql/parser/SqlParserTest.java
index 117862e..1042e20 100644
--- a/core/src/test/java/org/apache/calcite/sql/parser/SqlParserTest.java
+++ b/core/src/test/java/org/apache/calcite/sql/parser/SqlParserTest.java
@@ -18,10 +18,10 @@ package org.apache.calcite.sql.parser;
 
 import org.apache.calcite.avatica.util.Casing;
 import org.apache.calcite.avatica.util.Quoting;
-import org.apache.calcite.sql.SqlDialect;
 import org.apache.calcite.sql.SqlKind;
 import org.apache.calcite.sql.SqlNode;
 import org.apache.calcite.sql.SqlSetOption;
+import org.apache.calcite.sql.dialect.CalciteSqlDialect;
 import org.apache.calcite.sql.parser.impl.SqlParserImpl;
 import org.apache.calcite.sql.pretty.SqlPrettyWriter;
 import org.apache.calcite.sql.validate.SqlConformance;
@@ -7259,11 +7259,11 @@ public class SqlParserTest {
     SqlNode node = getSqlParser("alter system set schema = true").parseStmt();
     SqlSetOption opt = (SqlSetOption) node;
     assertThat(opt.getScope(), equalTo("SYSTEM"));
-    SqlPrettyWriter writer = new SqlPrettyWriter(SqlDialect.CALCITE);
+    SqlPrettyWriter writer = new SqlPrettyWriter(CalciteSqlDialect.DEFAULT);
     assertThat(writer.format(opt.getName()), equalTo("\"SCHEMA\""));
-    writer = new SqlPrettyWriter(SqlDialect.CALCITE);
+    writer = new SqlPrettyWriter(CalciteSqlDialect.DEFAULT);
     assertThat(writer.format(opt.getValue()), equalTo("TRUE"));
-    writer = new SqlPrettyWriter(SqlDialect.CALCITE);
+    writer = new SqlPrettyWriter(CalciteSqlDialect.DEFAULT);
     assertThat(writer.format(opt),
         equalTo("ALTER SYSTEM SET \"SCHEMA\" = TRUE"));
 
@@ -7291,10 +7291,10 @@ public class SqlParserTest {
     node = getSqlParser("reset schema").parseStmt();
     opt = (SqlSetOption) node;
     assertThat(opt.getScope(), equalTo(null));
-    writer = new SqlPrettyWriter(SqlDialect.CALCITE);
+    writer = new SqlPrettyWriter(CalciteSqlDialect.DEFAULT);
     assertThat(writer.format(opt.getName()), equalTo("\"SCHEMA\""));
     assertThat(opt.getValue(), equalTo(null));
-    writer = new SqlPrettyWriter(SqlDialect.CALCITE);
+    writer = new SqlPrettyWriter(CalciteSqlDialect.DEFAULT);
     assertThat(writer.format(opt),
         equalTo("RESET \"SCHEMA\""));
 
@@ -8185,7 +8185,7 @@ public class SqlParserTest {
       // Unparse again in Calcite dialect (which we can parse), and
       // minimal parentheses.
       final String sql1 =
-          sqlNode.toSqlString(SqlDialect.CALCITE, false).getSql();
+          sqlNode.toSqlString(CalciteSqlDialect.DEFAULT, false).getSql();
 
       // Parse and unparse again.
       SqlNode sqlNode2;
@@ -8197,7 +8197,7 @@ public class SqlParserTest {
         quoting = q;
       }
       final String sql2 =
-          sqlNode2.toSqlString(SqlDialect.CALCITE, false).getSql();
+          sqlNode2.toSqlString(CalciteSqlDialect.DEFAULT, false).getSql();
 
       // Should be the same as we started with.
       assertEquals(sql1, sql2);
@@ -8219,7 +8219,7 @@ public class SqlParserTest {
       // Unparse again in Calcite dialect (which we can parse), and
       // minimal parentheses.
       final String sql1 =
-          sqlNode.toSqlString(SqlDialect.CALCITE, false).getSql();
+          sqlNode.toSqlString(CalciteSqlDialect.DEFAULT, false).getSql();
 
       // Parse and unparse again.
       SqlNode sqlNode2;
@@ -8231,7 +8231,7 @@ public class SqlParserTest {
         quoting = q;
       }
       final String sql2 =
-          sqlNode2.toSqlString(SqlDialect.CALCITE, false).getSql();
+          sqlNode2.toSqlString(CalciteSqlDialect.DEFAULT, false).getSql();
 
       // Should be the same as we started with.
       assertEquals(sql1, sql2);

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java 
b/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
index 15ddb13..7c0be3f 100644
--- a/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
+++ b/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
@@ -26,7 +26,6 @@ import org.apache.calcite.sql.SqlAggFunction;
 import org.apache.calcite.sql.SqlCall;
 import org.apache.calcite.sql.SqlCallBinding;
 import org.apache.calcite.sql.SqlDataTypeSpec;
-import org.apache.calcite.sql.SqlDialect;
 import org.apache.calcite.sql.SqlIdentifier;
 import org.apache.calcite.sql.SqlJdbcFunctionCall;
 import org.apache.calcite.sql.SqlLiteral;
@@ -34,6 +33,8 @@ import org.apache.calcite.sql.SqlNode;
 import org.apache.calcite.sql.SqlNodeList;
 import org.apache.calcite.sql.SqlOperandCountRange;
 import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.dialect.AnsiSqlDialect;
+import org.apache.calcite.sql.dialect.CalciteSqlDialect;
 import org.apache.calcite.sql.fun.OracleSqlOperatorTable;
 import org.apache.calcite.sql.fun.SqlStdOperatorTable;
 import org.apache.calcite.sql.parser.SqlParserPos;
@@ -6733,7 +6734,7 @@ public abstract class SqlOperatorBaseTest {
         SqlLiteral literal =
             type.getSqlTypeName().createLiteral(o, SqlParserPos.ZERO);
         SqlString literalString =
-            literal.toSqlString(SqlDialect.DUMMY);
+            literal.toSqlString(AnsiSqlDialect.DEFAULT);
         final String expr =
             "CAST(" + literalString
                 + " AS " + type + ")";
@@ -6783,7 +6784,7 @@ public abstract class SqlOperatorBaseTest {
         SqlLiteral literal =
             type.getSqlTypeName().createLiteral(o, SqlParserPos.ZERO);
         SqlString literalString =
-            literal.toSqlString(SqlDialect.DUMMY);
+            literal.toSqlString(AnsiSqlDialect.DEFAULT);
 
         if ((type.getSqlTypeName() == SqlTypeName.BIGINT)
             || ((type.getSqlTypeName() == SqlTypeName.DECIMAL)
@@ -6900,7 +6901,7 @@ public abstract class SqlOperatorBaseTest {
             continue;
           }
           final SqlPrettyWriter writer =
-              new SqlPrettyWriter(SqlDialect.CALCITE);
+              new SqlPrettyWriter(CalciteSqlDialect.DEFAULT);
           op.unparse(writer, call, 0, 0);
           final String s = writer.toSqlString().toString();
           if (s.startsWith("OVERLAY(")

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/test/java/org/apache/calcite/sql/test/SqlPrettyWriterTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/calcite/sql/test/SqlPrettyWriterTest.java 
b/core/src/test/java/org/apache/calcite/sql/test/SqlPrettyWriterTest.java
index 83d5a7e..ce7a806 100644
--- a/core/src/test/java/org/apache/calcite/sql/test/SqlPrettyWriterTest.java
+++ b/core/src/test/java/org/apache/calcite/sql/test/SqlPrettyWriterTest.java
@@ -17,9 +17,9 @@
 package org.apache.calcite.sql.test;
 
 import org.apache.calcite.sql.SqlCall;
-import org.apache.calcite.sql.SqlDialect;
 import org.apache.calcite.sql.SqlNode;
 import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.dialect.AnsiSqlDialect;
 import org.apache.calcite.sql.parser.SqlParseException;
 import org.apache.calcite.sql.parser.SqlParser;
 import org.apache.calcite.sql.pretty.SqlPrettyWriter;
@@ -78,7 +78,7 @@ public class SqlPrettyWriterTest {
       String expected) {
     final SqlNode node = parseQuery(sql);
     final SqlPrettyWriter prettyWriter =
-        new SqlPrettyWriter(SqlDialect.DUMMY);
+        new SqlPrettyWriter(AnsiSqlDialect.DEFAULT);
     prettyWriter.setAlwaysUseParentheses(false);
     if (newlines) {
       prettyWriter.setCaseClausesOnNewLines(true);
@@ -101,7 +101,7 @@ public class SqlPrettyWriterTest {
     final SqlCall rowCall = valuesCall.operand(0);
     final SqlNode node = rowCall.operand(0);
     final SqlPrettyWriter prettyWriter =
-        new SqlPrettyWriter(SqlDialect.DUMMY);
+        new SqlPrettyWriter(AnsiSqlDialect.DEFAULT);
     prettyWriter.setAlwaysUseParentheses(false);
     if (newlines) {
       prettyWriter.setCaseClausesOnNewLines(true);
@@ -153,34 +153,34 @@ public class SqlPrettyWriterTest {
 
   @Test public void testDefault() throws Exception {
     final SqlPrettyWriter prettyWriter =
-        new SqlPrettyWriter(SqlDialect.DUMMY);
+        new SqlPrettyWriter(AnsiSqlDialect.DEFAULT);
     checkSimple(prettyWriter, "${desc}", "${formatted}");
   }
 
   @Test public void testIndent8() throws Exception {
     final SqlPrettyWriter prettyWriter =
-        new SqlPrettyWriter(SqlDialect.DUMMY);
+        new SqlPrettyWriter(AnsiSqlDialect.DEFAULT);
     prettyWriter.setIndentation(8);
     checkSimple(prettyWriter, "${desc}", "${formatted}");
   }
 
   @Test public void testClausesNotOnNewLine() throws Exception {
     final SqlPrettyWriter prettyWriter =
-        new SqlPrettyWriter(SqlDialect.DUMMY);
+        new SqlPrettyWriter(AnsiSqlDialect.DEFAULT);
     prettyWriter.setClauseStartsLine(false);
     checkSimple(prettyWriter, "${desc}", "${formatted}");
   }
 
   @Test public void testSelectListItemsOnSeparateLines() throws Exception {
     final SqlPrettyWriter prettyWriter =
-        new SqlPrettyWriter(SqlDialect.DUMMY);
+        new SqlPrettyWriter(AnsiSqlDialect.DEFAULT);
     prettyWriter.setSelectListItemsOnSeparateLines(true);
     checkSimple(prettyWriter, "${desc}", "${formatted}");
   }
 
   @Test public void testSelectListExtraIndentFlag() throws Exception {
     final SqlPrettyWriter prettyWriter =
-        new SqlPrettyWriter(SqlDialect.DUMMY);
+        new SqlPrettyWriter(AnsiSqlDialect.DEFAULT);
     prettyWriter.setSelectListItemsOnSeparateLines(true);
     prettyWriter.setSelectListExtraIndentFlag(false);
     checkSimple(prettyWriter, "${desc}", "${formatted}");
@@ -188,21 +188,21 @@ public class SqlPrettyWriterTest {
 
   @Test public void testKeywordsLowerCase() throws Exception {
     final SqlPrettyWriter prettyWriter =
-        new SqlPrettyWriter(SqlDialect.DUMMY);
+        new SqlPrettyWriter(AnsiSqlDialect.DEFAULT);
     prettyWriter.setKeywordsLowerCase(true);
     checkSimple(prettyWriter, "${desc}", "${formatted}");
   }
 
   @Test public void testParenthesizeAllExprs() throws Exception {
     final SqlPrettyWriter prettyWriter =
-        new SqlPrettyWriter(SqlDialect.DUMMY);
+        new SqlPrettyWriter(AnsiSqlDialect.DEFAULT);
     prettyWriter.setAlwaysUseParentheses(true);
     checkSimple(prettyWriter, "${desc}", "${formatted}");
   }
 
   @Test public void testOnlyQuoteIdentifiersWhichNeedIt() throws Exception {
     final SqlPrettyWriter prettyWriter =
-        new SqlPrettyWriter(SqlDialect.DUMMY);
+        new SqlPrettyWriter(AnsiSqlDialect.DEFAULT);
     prettyWriter.setQuoteAllIdentifiers(false);
     checkSimple(prettyWriter, "${desc}", "${formatted}");
   }
@@ -211,7 +211,7 @@ public class SqlPrettyWriterTest {
     // Note that ( is at the indent, SELECT is on the same line, and ) is
     // below it.
     final SqlPrettyWriter prettyWriter =
-        new SqlPrettyWriter(SqlDialect.DUMMY);
+        new SqlPrettyWriter(AnsiSqlDialect.DEFAULT);
     prettyWriter.setSubQueryStyle(SqlWriter.SubQueryStyle.BLACK);
     checkSimple(prettyWriter, "${desc}", "${formatted}");
   }
@@ -330,7 +330,7 @@ public class SqlPrettyWriterTest {
 
   private void checkPrettySeparateLines(String sql) {
     final SqlPrettyWriter prettyWriter =
-        new SqlPrettyWriter(SqlDialect.DUMMY);
+        new SqlPrettyWriter(AnsiSqlDialect.DEFAULT);
     prettyWriter.setSelectListItemsOnSeparateLines(true);
     prettyWriter.setSelectListExtraIndentFlag(false);
 

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/test/java/org/apache/calcite/sql/test/SqlTesterImpl.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/sql/test/SqlTesterImpl.java 
b/core/src/test/java/org/apache/calcite/sql/test/SqlTesterImpl.java
index f4b2fbd..c96c4e8 100644
--- a/core/src/test/java/org/apache/calcite/sql/test/SqlTesterImpl.java
+++ b/core/src/test/java/org/apache/calcite/sql/test/SqlTesterImpl.java
@@ -24,13 +24,13 @@ import org.apache.calcite.rel.type.RelDataTypeField;
 import org.apache.calcite.runtime.Utilities;
 import org.apache.calcite.sql.SqlCall;
 import org.apache.calcite.sql.SqlCollation;
-import org.apache.calcite.sql.SqlDialect;
 import org.apache.calcite.sql.SqlIntervalLiteral;
 import org.apache.calcite.sql.SqlLiteral;
 import org.apache.calcite.sql.SqlNode;
 import org.apache.calcite.sql.SqlOperator;
 import org.apache.calcite.sql.SqlOperatorTable;
 import org.apache.calcite.sql.SqlSelect;
+import org.apache.calcite.sql.dialect.AnsiSqlDialect;
 import org.apache.calcite.sql.fun.SqlStdOperatorTable;
 import org.apache.calcite.sql.parser.SqlParseException;
 import org.apache.calcite.sql.parser.SqlParser;
@@ -475,7 +475,7 @@ public class SqlTesterImpl implements SqlTester, 
AutoCloseable {
       String expectedRewrite) {
     SqlNode rewrittenNode = parseAndValidate(validator, query);
     String actualRewrite =
-        rewrittenNode.toSqlString(SqlDialect.DUMMY, false).getSql();
+        rewrittenNode.toSqlString(AnsiSqlDialect.DEFAULT, false).getSql();
     TestUtil.assertEqualsVerbose(expectedRewrite, Util.toLinux(actualRewrite));
   }
 

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/test/java/org/apache/calcite/test/SqlLimitsTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/SqlLimitsTest.java 
b/core/src/test/java/org/apache/calcite/test/SqlLimitsTest.java
index 86c55f0..1bb26d4 100644
--- a/core/src/test/java/org/apache/calcite/test/SqlLimitsTest.java
+++ b/core/src/test/java/org/apache/calcite/test/SqlLimitsTest.java
@@ -21,8 +21,8 @@ import org.apache.calcite.jdbc.JavaTypeFactoryImpl;
 import org.apache.calcite.rel.type.RelDataType;
 import org.apache.calcite.rel.type.RelDataTypeFactory;
 import org.apache.calcite.rel.type.RelDataTypeSystem;
-import org.apache.calcite.sql.SqlDialect;
 import org.apache.calcite.sql.SqlLiteral;
+import org.apache.calcite.sql.dialect.AnsiSqlDialect;
 import org.apache.calcite.sql.parser.SqlParserPos;
 import org.apache.calcite.sql.type.BasicSqlType;
 import org.apache.calcite.sql.type.SqlTypeName;
@@ -204,7 +204,7 @@ public class SqlLimitsTest {
     SqlLiteral literal =
         type.getSqlTypeName().createLiteral(o, SqlParserPos.ZERO);
     pw.print("; as SQL: ");
-    pw.print(literal.toSqlString(SqlDialect.DUMMY));
+    pw.print(literal.toSqlString(AnsiSqlDialect.DEFAULT));
     pw.println();
   }
 

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/test/java/org/apache/calcite/tools/FrameworksTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/tools/FrameworksTest.java 
b/core/src/test/java/org/apache/calcite/tools/FrameworksTest.java
index 6170563..6de282e 100644
--- a/core/src/test/java/org/apache/calcite/tools/FrameworksTest.java
+++ b/core/src/test/java/org/apache/calcite/tools/FrameworksTest.java
@@ -39,10 +39,10 @@ import org.apache.calcite.schema.Schemas;
 import org.apache.calcite.schema.Table;
 import org.apache.calcite.schema.impl.AbstractTable;
 import org.apache.calcite.server.CalciteServerStatement;
-import org.apache.calcite.sql.SqlDialect;
 import org.apache.calcite.sql.SqlExplainFormat;
 import org.apache.calcite.sql.SqlExplainLevel;
 import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.dialect.AnsiSqlDialect;
 import org.apache.calcite.sql.fun.SqlStdOperatorTable;
 import org.apache.calcite.sql.type.SqlTypeName;
 import org.apache.calcite.test.CalciteAssert;
@@ -186,7 +186,7 @@ public class FrameworksTest {
     SqlNode val = planner.validate(parse);
 
     String valStr =
-        val.toSqlString(SqlDialect.DUMMY, false).getSql();
+        val.toSqlString(AnsiSqlDialect.DEFAULT, false).getSql();
 
     String expandedStr =
         "SELECT `emps`.`empid`, `emps`.`deptno`, `emps`.`name`, 
`emps`.`salary`, `emps`.`commission`\n"

http://git-wip-us.apache.org/repos/asf/calcite/blob/914b5cfb/core/src/test/java/org/apache/calcite/util/Smalls.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/util/Smalls.java 
b/core/src/test/java/org/apache/calcite/util/Smalls.java
index 6ea55bf..1b8824a 100644
--- a/core/src/test/java/org/apache/calcite/util/Smalls.java
+++ b/core/src/test/java/org/apache/calcite/util/Smalls.java
@@ -47,8 +47,8 @@ import org.apache.calcite.schema.TranslatableTable;
 import org.apache.calcite.schema.impl.AbstractTable;
 import org.apache.calcite.schema.impl.ViewTable;
 import org.apache.calcite.sql.SqlCall;
-import org.apache.calcite.sql.SqlDialect;
 import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.dialect.CalciteSqlDialect;
 import org.apache.calcite.sql.type.SqlTypeName;
 
 import com.google.common.collect.ImmutableList;
@@ -357,7 +357,7 @@ public class Smalls {
             return typeFactory.builder().add("c", SqlTypeName.VARCHAR, 100)
                     .build();
           }
-        }, "values (" + SqlDialect.CALCITE.quoteStringLiteral(s) + ")",
+        }, "values (" + CalciteSqlDialect.DEFAULT.quoteStringLiteral(s) + ")",
         ImmutableList.<String>of(), Arrays.asList("view"));
   }
 
@@ -371,8 +371,8 @@ public class Smalls {
                 .build();
           }
         },
-        "values " + SqlDialect.CALCITE.quoteStringLiteral(o.toString())
-            + ", " + SqlDialect.CALCITE.quoteStringLiteral(p.toString()),
+        "values " + CalciteSqlDialect.DEFAULT.quoteStringLiteral(o.toString())
+            + ", " + 
CalciteSqlDialect.DEFAULT.quoteStringLiteral(p.toString()),
         ImmutableList.<String>of(), Arrays.asList("view"));
   }
 

Reply via email to