Airblader commented on a change in pull request #17060:
URL: https://github.com/apache/flink/pull/17060#discussion_r699048585



##########
File path: 
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/common/CommonExecSink.java
##########
@@ -260,76 +191,135 @@ public DynamicTableSinkSpec getTableSinkSpec() {
      * the parallelism is provided, otherwise it uses parallelism of input 
transformation.
      */
     private int deriveSinkParallelism(
-            ParallelismProvider parallelismProvider, int inputParallelism) {
-        final Optional<Integer> parallelismOptional = 
parallelismProvider.getParallelism();
-        if (parallelismOptional.isPresent()) {
-            int sinkParallelism = parallelismOptional.get();
-            if (sinkParallelism <= 0) {
-                throw new TableException(
-                        String.format(
-                                "Table: %s configured sink parallelism: "
-                                        + "%s should not be less than zero or 
equal to zero",
-                                
tableSinkSpec.getObjectIdentifier().asSummaryString(),
-                                sinkParallelism));
-            }
-            return sinkParallelism;
-        } else {
-            // use input parallelism if not specified
+            Transformation<RowData> inputTransform, SinkRuntimeProvider 
runtimeProvider) {
+        final int inputParallelism = inputTransform.getParallelism();
+        if (!(runtimeProvider instanceof ParallelismProvider)) {
             return inputParallelism;
         }
+        final ParallelismProvider parallelismProvider = (ParallelismProvider) 
runtimeProvider;
+        return parallelismProvider
+                .getParallelism()
+                .map(
+                        sinkParallelism -> {
+                            if (sinkParallelism <= 0) {
+                                throw new TableException(
+                                        String.format(
+                                                "Invalid configured 
parallelism %s for table '%s'.",
+                                                sinkParallelism,
+                                                tableSinkSpec
+                                                        .getObjectIdentifier()
+                                                        .asSummaryString()));

Review comment:
       This is a complete nit, but I don't really understand why we're going 
through the trouble of calling a method (rather than relying on toString) to 
print a potentially incorrect representation rather than a properly escaped one.




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