luoyuxia commented on code in PR #21629:
URL: https://github.com/apache/flink/pull/21629#discussion_r1066748204


##########
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/functions/hive/HiveSumAggFunction.java:
##########
@@ -125,10 +126,16 @@ private DataType initResultType(DataType argsType) {
                 int precision =
                         Math.min(MAX_PRECISION, 
getPrecision(argsType.getLogicalType()) + 10);
                 return DataTypes.DECIMAL(precision, 
getScale(argsType.getLogicalType()));
+            case TIMESTAMP_WITHOUT_TIME_ZONE:
+                throw new TableException(
+                        String.format(
+                                "Native hive sum aggregate function does not 
support type: '%s'. Please set option '%s' to false.",
+                                argsType.getLogicalType().getTypeRoot(),
+                                
TABLE_EXEC_HIVE_NATIVE_AGG_FUNCTION_ENABLED.key()));
             default:
                 throw new TableException(
                         String.format(
-                                "Sum aggregate function does not support type: 
'%s'. Please re-check the data type.",
+                                "Native hive sum aggregate function does not 
support type: '%s'. Please re-check the data type.",

Review Comment:
   Combine this with `case TIMESTAMP_WITHOUT_TIME_ZONE` ? 



##########
flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/connectors/hive/HiveDialectAggITCase.java:
##########
@@ -0,0 +1,196 @@
+/*
+ * 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.flink.connectors.hive;
+
+import org.apache.flink.table.api.SqlDialect;
+import org.apache.flink.table.api.TableEnvironment;
+import org.apache.flink.table.catalog.hive.HiveCatalog;
+import org.apache.flink.table.catalog.hive.HiveTestUtils;
+import org.apache.flink.table.module.CoreModule;
+import org.apache.flink.table.module.hive.HiveModule;
+import org.apache.flink.types.Row;
+import org.apache.flink.util.CollectionUtil;
+
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+
+import java.util.List;
+
+import static 
org.apache.flink.connectors.hive.HiveOptions.TABLE_EXEC_HIVE_NATIVE_AGG_FUNCTION_ENABLED;
+import static org.apache.flink.core.testutils.FlinkAssertions.anyCauseMatches;
+import static 
org.apache.flink.table.planner.utils.TableTestUtil.readFromResource;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+/** Test for native hive agg function compatibility. */
+public class HiveDialectAggITCase {
+
+    @ClassRule public static TemporaryFolder tempFolder = new 
TemporaryFolder();
+
+    private static HiveCatalog hiveCatalog;
+    private static TableEnvironment tableEnv;
+
+    @BeforeClass
+    public static void setup() throws Exception {
+        hiveCatalog = HiveTestUtils.createHiveCatalog();
+        // required by query like "src.`[k].*` from src"
+        
hiveCatalog.getHiveConf().setVar(HiveConf.ConfVars.HIVE_QUOTEDID_SUPPORT, 
"none");
+        hiveCatalog.open();
+        tableEnv = getTableEnvWithHiveCatalog();
+        // enable native hive agg function
+        tableEnv.getConfig().set(TABLE_EXEC_HIVE_NATIVE_AGG_FUNCTION_ENABLED, 
true);
+
+        // create tables
+        tableEnv.executeSql("create table foo (x int, y int)");
+
+        HiveTestUtils.createTextTableInserter(hiveCatalog, "default", "foo")
+                .addRow(new Object[] {1, 1})
+                .addRow(new Object[] {2, 2})
+                .addRow(new Object[] {3, 3})
+                .addRow(new Object[] {4, 4})
+                .addRow(new Object[] {5, 5})
+                .commit();
+    }
+
+    @Test
+    public void testSumAggFunctionPlan() {

Review Comment:
   add a test to validate the fall back can work?



##########
flink-table/flink-sql-gateway-api/src/main/java/org/apache/flink/table/gateway/api/session/FunctionCreator.java:
##########
@@ -0,0 +1,42 @@
+/*
+ * 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.flink.table.gateway.api.session;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.configuration.ReadableConfig;
+import org.apache.flink.table.catalog.Catalog;
+import org.apache.flink.table.module.Module;
+
+import java.util.Map;
+
+/**
+ * An interface used to create {@link Module} or {@link Catalog}.
+ *
+ * @param <R> type of the return value
+ */
+@PublicEvolving

Review Comment:
   is it must a PublicEvolving? 



-- 
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