swapna267 commented on code in PR #15780:
URL: https://github.com/apache/iceberg/pull/15780#discussion_r3002399079


##########
flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/sink/dynamic/DynamicRecordWithDefaults.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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.iceberg.flink.sink.dynamic;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.iceberg.DistributionMode;
+import org.apache.iceberg.flink.FlinkWriteConf;
+import org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+
+/**
+ * DynamicRecord extension that provides overrides from FlinkWriteConf when 
the base record doesn't
+ * have fields set.
+ */
+@Internal
+class DynamicRecordWithDefaults extends DynamicRecord {
+
+  private final FlinkWriteConf flinkWriteConf;
+
+  DynamicRecordWithDefaults(DynamicRecord source, FlinkWriteConf 
flinkWriteConf) {
+    super(
+        source.tableIdentifier(),
+        source.branch(),
+        source.schema(),
+        source.rowData(),
+        source.spec(),
+        source.distributionMode(),
+        source.writeParallelism());
+    setUpsertMode(source.upsertMode());
+    setEqualityFields(source.equalityFields());
+    this.flinkWriteConf = flinkWriteConf;
+  }
+
+  @Override
+  public String branch() {
+    return MoreObjects.firstNonNull(super.branch(), flinkWriteConf.branch());
+  }
+
+  @Override
+  public DistributionMode distributionMode() {
+    return MoreObjects.firstNonNull(super.distributionMode(), 
flinkWriteConf.distributionMode());
+  }
+
+  @Override
+  public int writeParallelism() {
+    if (super.writeParallelism() != Integer.MAX_VALUE) {
+      return super.writeParallelism();
+    }

Review Comment:
   
https://github.com/apache/iceberg/blob/main/flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/sink/dynamic/DynamicRecord.java#L51-L71
   
   DynamicRecord constructor has `writeParallelism ` as primitive int. And we 
basically are using Integer.MAX_VALUE to fall back to other value like job 
parallelism.
   
   ```
      * @param writeParallelism The number of parallel writers. Can be set to 
any value {@literal > 0},
      *     but will always be automatically capped by the maximum write 
parallelism, which is the
      *     parallelism of the sink. Set to Integer.MAX_VALUE for always using 
the maximum available
      *     write parallelism.
   ```



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to