stevenzwu commented on code in PR #4744:
URL: https://github.com/apache/iceberg/pull/4744#discussion_r884027693


##########
core/src/main/java/org/apache/iceberg/BaseIncrementalAppendScan.java:
##########
@@ -0,0 +1,179 @@
+/*
+ * 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;
+
+import java.util.List;
+import java.util.Set;
+import org.apache.iceberg.events.IncrementalScanEvent;
+import org.apache.iceberg.events.Listeners;
+import org.apache.iceberg.io.CloseableIterable;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.FluentIterable;
+import org.apache.iceberg.relocated.com.google.common.collect.Iterables;
+import org.apache.iceberg.relocated.com.google.common.collect.Lists;
+import org.apache.iceberg.relocated.com.google.common.collect.Sets;
+import org.apache.iceberg.util.SnapshotUtil;
+import org.apache.iceberg.util.TableScanUtil;
+
+class BaseIncrementalAppendScan extends BaseScan<IncrementalAppendScan> 
implements IncrementalAppendScan {
+
+  BaseIncrementalAppendScan(TableOperations ops, Table table) {
+    this(ops, table, table.schema(), new TableScanContext());
+  }
+
+  BaseIncrementalAppendScan(TableOperations ops, Table table, Schema schema, 
TableScanContext context) {
+    super(ops, table, schema, context);
+  }
+
+  @Override
+  protected IncrementalAppendScan newRefinedScan(
+      TableOperations newOps, Table newTable, Schema newSchema, 
TableScanContext newContext) {
+    return new BaseIncrementalAppendScan(newOps, newTable, newSchema, 
newContext);
+  }
+
+  @Override
+  public IncrementalAppendScan fromSnapshotInclusive(long fromSnapshotId) {

Review Comment:
   In Kafka source case, users can pin the read Avro schema. As long as  schema 
evolution is backward compatible (like an extra column), this is fine. If users 
don't pin read schema, only Avro GenericRecord is possible with a schema 
registry. Kafka record contains a schema id or fingerprint that consumers can 
use to look up schema from registry. SpecificRecord implicitly pinned the read 
schema to the schema used to generate the SpecificRecord code. 
   
   Similarly with Flink Iceberg source (as an example), users can set 
read/projected schema. Then the Flink reader should emit `RowData` with fields 
only from the pinned read schema. if users don't pin the read schema, current 
table schema is used as read schema. Read schema stays the same until the next 
time the Flink job is redeployed and then read schema is refreshed to the table 
schema again. 
   
   If a mandatory field is deleted (incompatible schema change), then consumer 
apps may be broken if the deleted column is accessed. 
   
   Here is probably a more tricky scenario that would fail
   - users don't pin read schema
   - a new required column is added to Iceberg table schema
   - read scanned some old snapshots/data where is new required column is not 
present
   
   Either users should pin read schema or users need to make sure not to scan 
old data where current table is incompatible. I would think adding a required 
column is also an incompatible schema evolution as it is incompatible to older 
data.
   
   cc @rdblue @kbendick @Fokko for more inputs
   
   
   
   



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