xiedeyantu commented on code in PR #4241:
URL: https://github.com/apache/calcite/pull/4241#discussion_r1996628802


##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -992,11 +1004,17 @@ private static String toSql(RelNode root, SqlDialect 
dialect,
         + "GROUP BY ROLLUP(`product_class_id`, `brand_name`)\n"
         + "ORDER BY `product_class_id` IS NULL, `product_class_id`, 
`brand_name` IS NULL, "
         + "`brand_name`";
+    final String expectedDoris = "SELECT `product_class_id`, `brand_name`\n"
+        + "FROM `foodmart`.`product`\n"
+        + "GROUP BY ROLLUP(`product_class_id`, `brand_name`)\n"
+        + "ORDER BY `product_class_id` IS NULL, `product_class_id`, 
`brand_name` IS NULL, "
+        + "`brand_name`";
     sql(query)
         .ok(expected)
         .withMysql().ok(expectedMysql)
         .withMysql8().ok(expectedMysql8)
-        .withStarRocks().ok(expectedStarRocks);
+        .withStarRocks().ok(expectedStarRocks)

Review Comment:
   > Maybe add a dialect for Doris is better?
   
   In order to reduce repetition, I don't think we should add a separate 
'expected' repetition. The existing ones with repetition should also be removed 
I think.



##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -2698,10 +2709,22 @@ private SqlDialect nonOrdinalDialect() {
         + "EXTRACT(MINUTE FROM TIMESTAMP '2023-12-01 00:00:00'), "
         + "EXTRACT(SECOND FROM TIMESTAMP '2023-12-01 00:00:00')\n"
         + "FROM (VALUES (0)) AS t (ZERO)";
+    final String expectedDoris = "SELECT "

Review Comment:
   > There are extra spaces here. Could you please check it?
   
   Here I have kept the same format as above, do I need to change them all?



##########
core/src/main/java/org/apache/calcite/sql/dialect/DorisSqlDialect.java:
##########
@@ -0,0 +1,178 @@
+/*
+ * 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.config.NullCollation;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeSystem;
+import org.apache.calcite.rel.type.RelDataTypeSystemImpl;
+import org.apache.calcite.sql.SqlAbstractDateTimeLiteral;
+import org.apache.calcite.sql.SqlAlienSystemTypeNameSpec;
+import org.apache.calcite.sql.SqlBasicTypeNameSpec;
+import org.apache.calcite.sql.SqlCall;
+import org.apache.calcite.sql.SqlDataTypeSpec;
+import org.apache.calcite.sql.SqlDialect;
+import org.apache.calcite.sql.SqlLiteral;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.fun.SqlFloorFunction;
+import org.apache.calcite.sql.parser.SqlParserPos;
+import org.apache.calcite.sql.type.SqlTypeName;
+
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+import static org.apache.calcite.util.RelToSqlConverterUtil.unparseHiveTrim;
+import static 
org.apache.calcite.util.RelToSqlConverterUtil.unparseSparkArrayAndMap;
+
+/**
+ * A <code>SqlDialect</code> implementation for the Doris database.
+ */
+public class DorisSqlDialect extends MysqlSqlDialect {
+
+  /** Doris type system. */
+  public static final RelDataTypeSystem DORIS_TYPE_SYSTEM =
+      new RelDataTypeSystemImpl() {
+        @Override public int getMaxPrecision(SqlTypeName typeName) {
+          switch (typeName) {
+          case CHAR:
+            return 255;
+          case VARCHAR:
+            return 65533;
+          case VARBINARY:
+            return 1048576;
+          default:
+            return super.getMaxPrecision(typeName);
+          }
+        }
+        @Override public int getDefaultPrecision(SqlTypeName typeName) {
+          if (typeName == SqlTypeName.CHAR) {
+            return RelDataType.PRECISION_NOT_SPECIFIED;
+          }
+          return super.getDefaultPrecision(typeName);
+        }
+      };
+
+  public static final Context DEFAULT_CONTEXT = SqlDialect.EMPTY_CONTEXT
+      .withDatabaseProduct(DatabaseProduct.STARROCKS)

Review Comment:
   > Here need change it to DatabaseProduct.Doris?
   
   Yes, thanks.



##########
core/src/main/java/org/apache/calcite/sql/dialect/DorisSqlDialect.java:
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.config.NullCollation;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeSystem;
+import org.apache.calcite.rel.type.RelDataTypeSystemImpl;
+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;
+import org.apache.calcite.sql.type.SqlTypeName;
+
+import static 
org.apache.calcite.util.RelToSqlConverterUtil.unparseSparkArrayAndMap;
+
+/**
+ * A <code>SqlDialect</code> implementation for the Doris database.
+ */
+public class DorisSqlDialect extends StarRocksSqlDialect {
+
+  /** Doris type system. */
+  public static final RelDataTypeSystem DORIS_TYPE_SYSTEM =

Review Comment:
   Done



##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -2677,78 +2688,90 @@ private SqlDialect nonOrdinalDialect() {
         + "EXTRACT(HOUR FROM TIMESTAMP '2023-12-01 00:00:00'),\n"
         + "EXTRACT(MINUTE FROM TIMESTAMP '2023-12-01 00:00:00'),\n"
         + "EXTRACT(SECOND FROM TIMESTAMP '2023-12-01 00:00:00')";
-    final String expectedClickHouse = "SELECT "
-        + "EXTRACT(YEAR FROM toDate('2023-12-01')), "
-        + "EXTRACT(QUARTER FROM toDate('2023-12-01')), "
-        + "EXTRACT(MONTH FROM toDate('2023-12-01')), "
-        + "toWeek(toDate('2023-12-01')), "
-        + "DAYOFYEAR(toDate('2023-12-01')), "
-        + "EXTRACT(DAY FROM toDate('2023-12-01')), "
-        + "DAYOFWEEK(toDate('2023-12-01')), "
-        + "EXTRACT(HOUR FROM toDateTime('2023-12-01 00:00:00')), "
-        + "EXTRACT(MINUTE FROM toDateTime('2023-12-01 00:00:00')), "
-        + "EXTRACT(SECOND FROM toDateTime('2023-12-01 00:00:00'))";
-    final String expectedMySQL = "SELECT "
-        + "EXTRACT(YEAR FROM DATE '2023-12-01'), "
-        + "EXTRACT(QUARTER FROM DATE '2023-12-01'), "
-        + "EXTRACT(MONTH FROM DATE '2023-12-01'), "
-        + "EXTRACT(WEEK FROM DATE '2023-12-01'), "
-        + "DAYOFYEAR(DATE '2023-12-01'), "
-        + "EXTRACT(DAY FROM DATE '2023-12-01'), "
-        + "DAYOFWEEK(DATE '2023-12-01'), "
-        + "EXTRACT(HOUR FROM TIMESTAMP '2023-12-01 00:00:00'), "
-        + "EXTRACT(MINUTE FROM TIMESTAMP '2023-12-01 00:00:00'), "
-        + "EXTRACT(SECOND FROM TIMESTAMP '2023-12-01 00:00:00')";
-    final String expectedStarRocks = "SELECT "
-        + "EXTRACT(YEAR FROM DATE '2023-12-01'), "
-        + "EXTRACT(QUARTER FROM DATE '2023-12-01'), "
-        + "EXTRACT(MONTH FROM DATE '2023-12-01'), "
-        + "EXTRACT(WEEK FROM DATE '2023-12-01'), "
-        + "DAYOFYEAR(DATE '2023-12-01'), "
-        + "EXTRACT(DAY FROM DATE '2023-12-01'), "
-        + "DAYOFWEEK(DATE '2023-12-01'), "
-        + "EXTRACT(HOUR FROM DATETIME '2023-12-01 00:00:00'), "
-        + "EXTRACT(MINUTE FROM DATETIME '2023-12-01 00:00:00'), "
-        + "EXTRACT(SECOND FROM DATETIME '2023-12-01 00:00:00')";
-    final String expectedHive = "SELECT "
-        + "EXTRACT(YEAR FROM DATE '2023-12-01'), "
-        + "EXTRACT(QUARTER FROM DATE '2023-12-01'), "
-        + "EXTRACT(MONTH FROM DATE '2023-12-01'), "
-        + "EXTRACT(WEEK FROM DATE '2023-12-01'), "
-        + "EXTRACT(DOY FROM DATE '2023-12-01'), "
-        + "EXTRACT(DAY FROM DATE '2023-12-01'), "
-        + "EXTRACT(DOW FROM DATE '2023-12-01'), "
-        + "EXTRACT(HOUR FROM TIMESTAMP '2023-12-01 00:00:00'), "
-        + "EXTRACT(MINUTE FROM TIMESTAMP '2023-12-01 00:00:00'), "
-        + "EXTRACT(SECOND FROM TIMESTAMP '2023-12-01 00:00:00')";
-    final String expectedPostgresql = "SELECT "
-        + "EXTRACT(YEAR FROM DATE '2023-12-01'), "
-        + "EXTRACT(QUARTER FROM DATE '2023-12-01'), "
-        + "EXTRACT(MONTH FROM DATE '2023-12-01'), "
-        + "EXTRACT(WEEK FROM DATE '2023-12-01'), "
-        + "EXTRACT(DOY FROM DATE '2023-12-01'), "
-        + "EXTRACT(DAY FROM DATE '2023-12-01'), "
-        + "EXTRACT(DOW FROM DATE '2023-12-01'), "
-        + "EXTRACT(HOUR FROM TIMESTAMP '2023-12-01 00:00:00'), "
-        + "EXTRACT(MINUTE FROM TIMESTAMP '2023-12-01 00:00:00'), "
-        + "EXTRACT(SECOND FROM TIMESTAMP '2023-12-01 00:00:00')\n"
+    final String expectedClickHouse = "SELECT"

Review Comment:
   > Please revert the unwanted changes. The issue related to the format can be 
fixed in the same PR later.
   
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to