hubgeter commented on code in PR #60482:
URL: https://github.com/apache/doris/pull/60482#discussion_r2980144579


##########
be/src/exec/sink/viceberg_merge_sink.cpp:
##########
@@ -0,0 +1,370 @@
+// 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.
+
+#include "exec/sink/viceberg_merge_sink.h"
+
+#include <fmt/format.h>
+
+#include "common/consts.h"
+#include "common/exception.h"
+#include "common/logging.h"
+#include "core/block/block.h"
+#include "core/column/column_nullable.h"
+#include "core/column/column_vector.h"
+#include "exec/sink/viceberg_delete_sink.h"
+#include "exec/sink/writer/iceberg/viceberg_table_writer.h"
+#include "format/table/iceberg/schema.h"
+#include "format/table/iceberg/schema_parser.h"
+#include "runtime/runtime_state.h"
+#include "util/string_util.h"
+
+namespace doris {
+
+namespace {
+constexpr int8_t kInsertOperation = 1;

Review Comment:
    Both `viceberg_merge_sink`  and  `merge_partitioner` have these 
definitions; consider whether to combine them.  `kInsertOperation, 
_is_delete_op ...`



##########
be/src/format/table/iceberg_reader.cpp:
##########
@@ -127,6 +138,24 @@ Status IcebergTableReader::init_row_filters() {
         return Status::OK();
     }
 
+    // Initialize file information for $row_id generation
+    // Extract from table_desc which contains current file's metadata
+    if (_need_row_id_column) {
+        std::string file_path = table_desc.original_file_path;
+        int32_t partition_spec_id = 0;
+        std::string partition_data_json;
+        if (table_desc.__isset.partition_spec_id) {
+            partition_spec_id = table_desc.partition_spec_id;
+        }
+        if (table_desc.__isset.partition_data_json) {
+            partition_data_json = table_desc.partition_data_json;
+        }
+
+        set_current_file_info(file_path, partition_spec_id, 
partition_data_json);

Review Comment:
   The `set_current_file_info` method seems somewhat unnecessary.



##########
be/src/format/table/iceberg_reader.cpp:
##########
@@ -99,6 +99,17 @@ 
IcebergTableReader::IcebergTableReader(std::unique_ptr<GenericReader> file_forma
 
 Status IcebergTableReader::get_next_block_inner(Block* block, size_t* 
read_rows, bool* eof) {
     RETURN_IF_ERROR(_expand_block_if_need(block));
+
+    if (_need_row_id_column) {
+        if (auto* parquet_reader = 
dynamic_cast<ParquetReader*>(_file_format_reader.get())) {
+            parquet_reader->set_iceberg_rowid_params(_current_file_path, 
_partition_spec_id,

Review Comment:
   set_iceberg_rowid_params  can called at IcebergParquetReader / 
IcebergOrcReader  init_reader.



##########
be/src/format/column_processor.h:
##########
@@ -0,0 +1,56 @@
+// 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.
+
+#pragma once
+
+#include <string>
+
+namespace doris {
+class SlotDescriptor;
+
+/// Column categories for table format reading.
+///
+/// Each column requested by the query is classified into one of these 
categories.
+/// The category determines how the column's value is obtained:
+///   - REGULAR:       Read directly from the data file (Parquet/ORC).
+///   - PARTITION_KEY:  Filled from partition metadata (e.g. Hive path 
partitions).
+///   - MISSING:        Column exists in table schema but not in the file 
(schema evolution),
+///                     filled with default value or null.
+///   - SYNTHESIZED:    Never in the data file; fully computed at runtime
+///                     (e.g. Doris V2 __DORIS_ICEBERG_ROWID_COL__).
+///   - GENERATED:      May or may not exist in the data file. If present but 
null,
+///                     the value is backfilled at runtime (e.g. Iceberg V3 
_row_id).
+///   - INTERNAL:       Read from the data file but consumed internally by the 
TableReader
+///                     and removed from the output block (e.g. Hive ACID 
system columns).
+enum class ColumnCategory {

Review Comment:
   remove this.



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