Re: [PR] [FLINK-35155] Introduce TableRuntimeException [flink]

2024-05-06 Thread via GitHub


dawidwys merged PR #24679:
URL: https://github.com/apache/flink/pull/24679


-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-35155] Introduce TableRuntimeException [flink]

2024-04-18 Thread via GitHub


twalthr commented on code in PR #24679:
URL: https://github.com/apache/flink/pull/24679#discussion_r1570922395


##
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/MiscAggFunctionITCase.java:
##
@@ -0,0 +1,54 @@
+/*
+ * 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.planner.functions;
+
+import org.apache.flink.table.api.TableRuntimeException;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.stream.Stream;
+
+import static org.apache.flink.table.api.DataTypes.*;
+import static org.apache.flink.types.RowKind.*;
+
+/** Tests for built-in ARRAY_AGG aggregation functions. */
+class MiscAggFunctionITCase extends BuiltInAggregateFunctionTestBase {
+
+@Override
+Stream getTestCaseSpecs() {
+return Stream.of(
+TestSpec.forExpression("SINGLE_VALUE")
+.withSource(
+ROW(STRING(), INT()),
+Arrays.asList(
+Row.ofKind(INSERT, "A", 1),
+Row.ofKind(INSERT, "A", 2),
+Row.ofKind(INSERT, "B", 2)))
+.testSqlRuntimeError(
+source ->
+"SELECT f0, SINGLE_VALUE(f1) FROM "
++ source
++ " GROUP BY f0",
+ROW(STRING(), INT()),
+ex ->
+
ex.hasRootCauseInstanceOf(TableRuntimeException.class)

Review Comment:
   Yes, let's strive for this. It should be our end goal.



-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-35155] Introduce TableRuntimeException [flink]

2024-04-18 Thread via GitHub


dawidwys commented on PR #24679:
URL: https://github.com/apache/flink/pull/24679#issuecomment-2063994171

   > Let's already fix some other locations with this exception:
   for example:
   AbstractCodeGeneratorCastRule and CastExecutor
   SqlJsonUtils
   
   Sure, any other places that you're aware of?


-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-35155] Introduce TableRuntimeException [flink]

2024-04-18 Thread via GitHub


dawidwys commented on code in PR #24679:
URL: https://github.com/apache/flink/pull/24679#discussion_r1570850917


##
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/BuiltInAggregateFunctionTestBase.java:
##
@@ -344,6 +361,38 @@ public void execute(TableEnvironment tEnv, Table 
sourceTable) {
 protected abstract TableResult getResult(TableEnvironment tEnv, Table 
sourceTable);
 }
 
+private abstract static class RuntimeFailureItem implements TestItem {

Review Comment:
   I followed the `SuccessItem` convention. `Success/Failure`, but sure I'll 
rename it.



-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-35155] Introduce TableRuntimeException [flink]

2024-04-18 Thread via GitHub


dawidwys commented on code in PR #24679:
URL: https://github.com/apache/flink/pull/24679#discussion_r1570846758


##
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/MiscAggFunctionITCase.java:
##
@@ -0,0 +1,54 @@
+/*
+ * 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.planner.functions;
+
+import org.apache.flink.table.api.TableRuntimeException;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.stream.Stream;
+
+import static org.apache.flink.table.api.DataTypes.*;
+import static org.apache.flink.types.RowKind.*;
+
+/** Tests for built-in ARRAY_AGG aggregation functions. */
+class MiscAggFunctionITCase extends BuiltInAggregateFunctionTestBase {
+
+@Override
+Stream getTestCaseSpecs() {
+return Stream.of(
+TestSpec.forExpression("SINGLE_VALUE")
+.withSource(
+ROW(STRING(), INT()),
+Arrays.asList(
+Row.ofKind(INSERT, "A", 1),
+Row.ofKind(INSERT, "A", 2),
+Row.ofKind(INSERT, "B", 2)))
+.testSqlRuntimeError(
+source ->
+"SELECT f0, SINGLE_VALUE(f1) FROM "
++ source
++ " GROUP BY f0",
+ROW(STRING(), INT()),
+ex ->
+
ex.hasRootCauseInstanceOf(TableRuntimeException.class)

Review Comment:
   Are you confident that's the only exception we will ever want to test 
against? If that's the case, sure I can hardcode it for that exception.



-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-35155] Introduce TableRuntimeException [flink]

2024-04-18 Thread via GitHub


twalthr commented on code in PR #24679:
URL: https://github.com/apache/flink/pull/24679#discussion_r1570701741


##
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/BuiltInAggregateFunctionTestBase.java:
##
@@ -344,6 +361,38 @@ public void execute(TableEnvironment tEnv, Table 
sourceTable) {
 protected abstract TableResult getResult(TableEnvironment tEnv, Table 
sourceTable);
 }
 
+private abstract static class RuntimeFailureItem implements TestItem {

Review Comment:
   call it `RuntimeErrorItem` to be in sync with subclasses



##
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/MiscAggFunctionITCase.java:
##
@@ -0,0 +1,54 @@
+/*
+ * 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.planner.functions;
+
+import org.apache.flink.table.api.TableRuntimeException;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.stream.Stream;
+
+import static org.apache.flink.table.api.DataTypes.*;
+import static org.apache.flink.types.RowKind.*;
+
+/** Tests for built-in ARRAY_AGG aggregation functions. */
+class MiscAggFunctionITCase extends BuiltInAggregateFunctionTestBase {
+
+@Override
+Stream getTestCaseSpecs() {
+return Stream.of(
+TestSpec.forExpression("SINGLE_VALUE")
+.withSource(
+ROW(STRING(), INT()),
+Arrays.asList(
+Row.ofKind(INSERT, "A", 1),
+Row.ofKind(INSERT, "A", 2),
+Row.ofKind(INSERT, "B", 2)))
+.testSqlRuntimeError(
+source ->
+"SELECT f0, SINGLE_VALUE(f1) FROM "
++ source
++ " GROUP BY f0",
+ROW(STRING(), INT()),
+ex ->
+
ex.hasRootCauseInstanceOf(TableRuntimeException.class)

Review Comment:
   can we simplify the test base and test always against 
`TableRuntimeException`? so the method can only take the expected message.



-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-35155] Introduce TableRuntimeException [flink]

2024-04-18 Thread via GitHub


flinkbot commented on PR #24679:
URL: https://github.com/apache/flink/pull/24679#issuecomment-2063755509

   
   ## CI report:
   
   * c7d65d5679cbe4bfc52db6a2a718b8a5d2515ea3 UNKNOWN
   
   
   Bot commands
 The @flinkbot bot supports the following commands:
   
- `@flinkbot run azure` re-run the last Azure build
   


-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[PR] [FLINK-35155] Introduce TableRuntimeException [flink]

2024-04-18 Thread via GitHub


dawidwys opened a new pull request, #24679:
URL: https://github.com/apache/flink/pull/24679

   ## What is the purpose of the change
   
   Introduce `TableRuntimeException` to better classify intentional exceptions 
thrown from SQL runtime.
   
   
   ## Verifying this change
   
   Added tests
   
   ## Does this pull request potentially affect one of the following parts:
   
 - Dependencies (does it add or upgrade a dependency): (yes / **no**)
 - The public API, i.e., is any changed class annotated with 
`@Public(Evolving)`: (**yes** / no)
 - The serializers: (yes / **no** / don't know)
 - The runtime per-record code paths (performance sensitive): (yes / **no** 
/ don't know)
 - Anything that affects deployment or recovery: JobManager (and its 
components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (yes / **no** / don't 
know)
 - The S3 file system connector: (yes / **no** / don't know)
   
   ## Documentation
   
 - Does this pull request introduce a new feature? (yes / **no**)
 - If yes, how is the feature documented? (**not applicable** / docs / 
JavaDocs / not documented)
   


-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org