gustavodemorais commented on code in PR #27973:
URL: https://github.com/apache/flink/pull/27973#discussion_r3110636236


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/runtime/stream/sql/ChangelogFunctionITCase.java:
##########
@@ -0,0 +1,70 @@
+/*
+ * 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.runtime.stream.sql;
+
+import org.apache.flink.table.planner.factories.TestValuesTableFactory;
+import org.apache.flink.table.planner.runtime.utils.StreamingTestBase;
+import org.apache.flink.types.Row;
+import org.apache.flink.util.CollectionUtil;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+/** IT tests for the built-in TO_CHANGELOG and FROM_CHANGELOG process table 
functions. */
+class ChangelogFunctionITCase extends StreamingTestBase {

Review Comment:
   In general, we want to move away from IT test cases and use the new suite. 
   
   Can you write a semantic test for this? Similar to 
https://github.com/apache/flink/blob/bcb3682605e46c23c074fe2d31f0639cc22ff212/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/stream/ToChangelogTestPrograms.java#L435



##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/ptf/FromChangelogFunction.java:
##########
@@ -137,7 +138,10 @@ public void eval(
         final StringData opCode = input.getString(opColumnIndex);
         final RowKind rowKind = opMap.get(opCode);
         if (rowKind == null) {
-            return;
+            throw new TableRuntimeException(
+                    String.format(
+                            "Received invalid op code '%s'. Defined op codes 
are: %s. Failing as configured.",

Review Comment:
   nit :D - not configured yet
   
   
   ```suggestion
                               "Received invalid op code '%s'. Defined op codes 
are: %s.",
   ```



##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/ptf/FromChangelogFunction.java:
##########
@@ -137,7 +138,10 @@ public void eval(
         final StringData opCode = input.getString(opColumnIndex);
         final RowKind rowKind = opMap.get(opCode);
         if (rowKind == null) {
-            return;
+            throw new TableRuntimeException(
+                    String.format(
+                            "Received invalid op code '%s'. Defined op codes 
are: %s. Failing as configured.",
+                            opCode, opMap.keySet()));

Review Comment:
   Did you check how the error looks like? AI says
   
   ```
     Comment: opMap.keySet() is a Set<StringData>. When printed, this renders 
as [BinaryStringData{...}, ...] depending on the implementation. Consider 
mapping to plain strings for a readable error message: 
opMap.keySet().stream().map(Object::toString).collect(Collectors.joining(", ")).
   
     Concepts: StringData is an internal Flink type. While 
BinaryStringData.toString() does return the underlying string, the 
Set.toString() wrapping produces [value1, value2] which may be acceptable, but 
explicitly converting ensures the message is always human-friendly regardless 
of the StringData
     implementation.
   
   ```



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