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



##########
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:
       Let's not start this discussion now. It seems the backticks are hard to 
read in strings. We could have used `asSummaryString` in `toString` but now it 
is kind of too late I guess.




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