github-actions[bot] commented on code in PR #61398:
URL: https://github.com/apache/doris/pull/61398#discussion_r2998644467
##########
be/src/exec/scan/file_scanner.cpp:
##########
@@ -1697,6 +1716,14 @@ Status FileScanner::_init_expr_ctxes() {
continue;
}
+ if
(it->second->col_name().starts_with(IcebergTableReader::ROW_LINEAGE_ROW_ID)) {
+ _row_lineage_columns.row_id_column_idx =
_default_val_row_desc->get_column_id(slot_id);
+ }
+
+ if
(it->second->col_name().starts_with(IcebergTableReader::ROW_LINEAGE_LAST_UPDATED_SEQ_NUMBER))
{
Review Comment:
**[Minor]** `starts_with(IcebergTableReader::ROW_LINEAGE_ROW_ID)` should be
an exact match (`==`) instead. The constant is `"_row_id"`, and `starts_with`
would incorrectly match any column name that begins with `_row_id` (e.g.,
`_row_id_backup`). The adjacent code uses exact match for
`BeConsts::ICEBERG_ROWID_COL`; this should be consistent.
Same applies to the
`starts_with(IcebergTableReader::ROW_LINEAGE_LAST_UPDATED_SEQ_NUMBER)` check 4
lines below.
```cpp
if (it->second->col_name() == IcebergTableReader::ROW_LINEAGE_ROW_ID) {
_row_lineage_columns.row_id_column_idx =
_default_val_row_desc->get_column_id(slot_id);
}
if (it->second->col_name() ==
IcebergTableReader::ROW_LINEAGE_LAST_UPDATED_SEQ_NUMBER) {
_row_lineage_columns.last_updated_sequence_number_column_idx = ...
}
```
##########
fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/helper/IcebergRewritableDeletePlanner.java:
##########
@@ -0,0 +1,86 @@
+// 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.doris.datasource.iceberg.helper;
+
+import org.apache.doris.common.UserException;
+import org.apache.doris.datasource.iceberg.IcebergExternalTable;
+import org.apache.doris.datasource.iceberg.IcebergUtils;
+import org.apache.doris.datasource.iceberg.source.IcebergScanNode;
+import org.apache.doris.nereids.NereidsPlanner;
+import org.apache.doris.planner.ScanNode;
+import org.apache.doris.thrift.TIcebergRewritableDeleteFileSet;
+
+import org.apache.iceberg.DeleteFile;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+public final class IcebergRewritableDeletePlanner {
+ private static final int ICEBERG_DELETION_VECTOR_MIN_VERSION = 3;
+
+ private IcebergRewritableDeletePlanner() {
+ }
+
+ public static IcebergRewritableDeletePlan collectForDelete(
+ IcebergExternalTable table, NereidsPlanner planner) throws
UserException {
+ return collect(table, planner);
+ }
+
+ public static IcebergRewritableDeletePlan collectForMerge(
+ IcebergExternalTable table, NereidsPlanner planner) throws
UserException {
+ return collect(table, planner);
+ }
+
+ private static IcebergRewritableDeletePlan collect(
+ IcebergExternalTable table, NereidsPlanner planner) {
+ if (table == null
+ || planner == null
+ || IcebergUtils.getFormatVersion(table.getIcebergTable()) <
ICEBERG_DELETION_VECTOR_MIN_VERSION) {
+ return IcebergRewritableDeletePlan.empty();
+ }
+
+ List<TIcebergRewritableDeleteFileSet> thriftDeleteFileSets = new
ArrayList<>();
+ Map<String, List<DeleteFile>> deleteFilesByReferencedDataFile = new
LinkedHashMap<>();
+
+ for (ScanNode scanNode : planner.getScanNodes()) {
+ if (!(scanNode instanceof IcebergScanNode)) {
+ continue;
+ }
+ IcebergScanNode icebergScanNode = (IcebergScanNode) scanNode;
+
+
deleteFilesByReferencedDataFile.putAll(icebergScanNode.deleteFilesByReferencedDataFile);
+ icebergScanNode.deleteFilesDescByReferencedDataFile.forEach(
+ (key, value) -> {
+ TIcebergRewritableDeleteFileSet deleteFileSet = new
TIcebergRewritableDeleteFileSet();
+ deleteFileSet.setReferencedDataFilePath(key);
+ thriftDeleteFileSets.add(deleteFileSet);
Review Comment:
**[Critical Bug]** `setDeleteFiles(value)` is never called on
`deleteFileSet`. The lambda captures `(key, value)` from
`deleteFilesDescByReferencedDataFile` but only uses `key` — `value` (the
`List<TIcebergDeleteFileDesc>`) is silently discarded.
On the BE side (`viceberg_delete_sink.cpp:174`), the code skips entries
where `!delete_file_set.__isset.delete_files`, so all rewritable entries are
effectively no-ops. This means when a second DELETE hits a data file that
already has deletion vectors, the previous deletes are **not merged** into the
new DV, causing those previously deleted rows to reappear.
Fix:
```java
icebergScanNode.deleteFilesDescByReferencedDataFile.forEach(
(key, value) -> {
TIcebergRewritableDeleteFileSet deleteFileSet = new
TIcebergRewritableDeleteFileSet();
deleteFileSet.setReferencedDataFilePath(key);
deleteFileSet.setDeleteFiles(value); // <-- missing line
thriftDeleteFileSets.add(deleteFileSet);
}
);
```
--
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]