github-actions[bot] commented on code in PR #62586:
URL: https://github.com/apache/doris/pull/62586#discussion_r3127943392
##########
be/src/format/table/paimon_reader.cpp:
##########
@@ -50,12 +50,45 @@ Status
PaimonOrcReader::on_before_init_reader(ReaderInitContext* ctx) {
get_tuple_descriptor(), orc_type_ptr));
ctx->table_info_node = table_info_node_ptr;
- for (const auto& desc : *ctx->column_descs) {
- if (desc.category == ColumnCategory::REGULAR ||
- desc.category == ColumnCategory::GENERATED) {
+ bool has_partition_from_path = false;
+ std::unordered_set<std::string> partition_col_names;
+ if (ctx->range->__isset.columns_from_path_keys) {
Review Comment:
This fallback only activates when FE filled `columns_from_path*`, but
`PaimonScanNode` currently computes `paimonPartitionValues` only when
`enable_runtime_filter_partition_prune` is true. If a session runs `set
enable_runtime_filter_partition_prune = false`, native scans of Hive-migrated
Paimon files still come here without any `columns_from_path_keys`,
`has_partition_from_path` stays false, and we keep trying to read the missing
partition column from the file. So the reported crash is still reproducible in
a valid session setting. The same dependency exists in the Parquet branch below.
##########
be/src/format/table/paimon_reader.cpp:
##########
@@ -50,12 +50,45 @@ Status
PaimonOrcReader::on_before_init_reader(ReaderInitContext* ctx) {
get_tuple_descriptor(), orc_type_ptr));
ctx->table_info_node = table_info_node_ptr;
- for (const auto& desc : *ctx->column_descs) {
- if (desc.category == ColumnCategory::REGULAR ||
- desc.category == ColumnCategory::GENERATED) {
+ bool has_partition_from_path = false;
+ std::unordered_set<std::string> partition_col_names;
+ if (ctx->range->__isset.columns_from_path_keys) {
+ partition_col_names.insert(ctx->range->columns_from_path_keys.begin(),
+ ctx->range->columns_from_path_keys.end());
+ }
+ std::map<std::string, uint64_t> file_column_name_idx_map;
+ for (uint64_t idx = 0; idx < orc_type_ptr->getSubtypeCount(); idx++) {
+ file_column_name_idx_map.emplace(orc_type_ptr->getFieldName(idx), idx);
+ }
+
+ for (auto& desc : *ctx->column_descs) {
+ if (desc.category == ColumnCategory::REGULAR) {
+ // `table_info_node` is built from the table/history schema. For
normal Paimon
+ // writes, partition columns are physically materialized in data
files, so the
+ // schema usually matches the file layout and these columns can be
read from the
+ // file as regular columns. For Hive-migrated Paimon tables,
legacy files may not
+ // contain those partition columns even though they still exist in
schema. When
+ // the mapped file column is absent, reclassify the column as
PARTITION_KEY and
+ // fill it from `columns_from_path` instead of reading it from the
file.
+ // This is similar to Iceberg partition fallback.
+ if (partition_col_names.contains(desc.name) &&
+ table_info_node_ptr->children_column_exists(desc.name)) {
+ if (!file_column_name_idx_map.contains(
+
table_info_node_ptr->children_file_column_name(desc.name))) {
+ desc.category = ColumnCategory::PARTITION_KEY;
Review Comment:
`ctx->column_descs` is not reader-local here:
`FileScanner::_fill_base_init_context()` passes the same `_column_descs` vector
into every range handled by this scanner. After a migrated split flips `dt` (or
another partition column) to `PARTITION_KEY`, the next normal Paimon split
handled by the same scanner will skip that column in `ctx->column_names`, and
this new reader instance will not call `_extract_partition_values()` for it
either. On mixed tables (including the regression setup after the
post-migration insert), later native-written files can therefore stop
materializing the real partition column depending on split order. Please keep
this fallback classification local to the current reader/range instead of
mutating the shared descriptor vector. The same issue is repeated in the
Parquet branch below.
--
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]