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


##########
flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/FlinkDynamicSinkOptions.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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;

Review Comment:
   Same here.



##########
flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/FlinkDynamicSinkConf.java:
##########
@@ -0,0 +1,103 @@
+/*
+ * 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;

Review Comment:
   Should probably be in the `dynamic` package. Or should we create a config 
package?



##########
flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/sink/dynamic/DynamicIcebergSink.java:
##########
@@ -84,14 +86,16 @@ public class DynamicIcebergSink
       Map<String, String> snapshotProperties,
       String uidPrefix,
       Map<String, String> writeProperties,
-      Configuration flinkConfig,
-      int cacheMaximumSize) {
+      Configuration flinkConfig) {
     this.catalogLoader = catalogLoader;
     this.snapshotProperties = snapshotProperties;
     this.uidPrefix = uidPrefix;
     this.writeProperties = writeProperties;
     this.flinkConfig = flinkConfig;
-    this.cacheMaximumSize = cacheMaximumSize;
+
+    FlinkDynamicSinkConf flinkDynamicSinkConf =
+        new FlinkDynamicSinkConf(writeProperties, flinkConfig);

Review Comment:
   Can we directly pass `FlinkDynamicSinkConf` to the constructor?



##########
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:
   Not sure about this logic. The default for writeParallelism is 0.



##########
flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/sink/dynamic/DynamicRecordProcessor.java:
##########
@@ -52,27 +58,30 @@ class DynamicRecordProcessor<T> extends ProcessFunction<T, 
DynamicRecordInternal
   private transient TableUpdater updater;
   private transient OutputTag<DynamicRecordInternal> updateStream;
   private transient Collector<DynamicRecordInternal> collector;
+  private transient FlinkWriteConf flinkWriteConf;
   private transient Context context;
 
   DynamicRecordProcessor(
       DynamicRecordGenerator<T> generator,
       CatalogLoader catalogLoader,
-      boolean immediateUpdate,
-      int cacheMaximumSize,
-      long cacheRefreshMs,
-      int inputSchemasPerTableCacheMaximumSize,
       TableCreator tableCreator,
-      boolean caseSensitive,
-      boolean dropUnusedColumns) {
+      Map<String, String> writeProperties,
+      Configuration flinkConfig) {
     this.generator = generator;
     this.catalogLoader = catalogLoader;
-    this.immediateUpdate = immediateUpdate;
-    this.cacheMaximumSize = cacheMaximumSize;
-    this.cacheRefreshMs = cacheRefreshMs;
-    this.inputSchemasPerTableCacheMaximumSize = 
inputSchemasPerTableCacheMaximumSize;
+    this.writeProperties = writeProperties;
+    this.flinkConfig = flinkConfig;
+
+    FlinkDynamicSinkConf flinkDynamicSinkConf =
+        new FlinkDynamicSinkConf(writeProperties, flinkConfig);

Review Comment:
   Could we create the config only once and pass it to the constructor?



##########
flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/sink/dynamic/DynamicIcebergSink.java:
##########
@@ -302,7 +300,9 @@ public Builder<T> toBranch(String branch) {
     }
 
     public Builder<T> immediateTableUpdate(boolean newImmediateUpdate) {
-      this.immediateUpdate = newImmediateUpdate;
+      writeOptions.put(
+          FlinkDynamicSinkOptions.IMMEDIATE_TABLE_UPDATE.key(),
+          Boolean.toString(newImmediateUpdate));

Review Comment:
   I'm not sure this should go into `WriteOptions`. I think it is better to 
have a separate config for DynamicSink options.



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

Review Comment:
   ```suggestion
   class DynamicRecordWithConfig extends DynamicRecord {
   ```
   
   Should we add a test to verify config handling?



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