-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[fix](iceberg) Guard synthesized slots in _create_column_ids #65610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Gabriel39
merged 4 commits into
apache:master
from
hubgeter:fix-iceberg-children-column-exists-crash
Jul 16, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ | |
| #include <unordered_map> | ||
| #include <vector> | ||
|
|
||
| #include "common/consts.h" | ||
| #include "common/object_pool.h" | ||
| #include "core/block/block.h" | ||
| #include "core/block/column_with_type_and_name.h" | ||
|
|
@@ -1166,4 +1167,96 @@ TEST_F(IcebergReaderCreateColumnIdsTest, test_create_column_ids_6) { | |
| } | ||
| } | ||
|
|
||
| } // namespace doris | ||
| // Regression coverage for _create_column_ids() driven by the schema-mapping StructNode: | ||
| // 1. Synthesized/metadata slots (e.g. the TopN global row-id column) are never serialized into | ||
| // the Iceberg schema tree, so they are absent from the node. Before the | ||
| // get_children().contains() guard, StructNode::children_column_exists() was called on such an | ||
| // unregistered name and hit DCHECK(children.contains(name)) -> abort in debug/ASAN builds | ||
| // (and threw std::out_of_range from .at() in release). The projected row-id slot reproduces | ||
| // that; with the guard it is skipped instead. | ||
| // 2. A projected column must resolve to its physical file column BY NAME through the node, not by | ||
| // Iceberg field id and not by its own (table) name, so partial-id / name-mapping files stay | ||
| // correct. Table column "a" maps to physical "legacy_a", while an unrelated "stale" column | ||
| // carries a field id that collides with the projected slot's default field id (0). The result | ||
| // must be "legacy_a"'s column id, never "stale"'s -- a regression to id-only or identity-name | ||
| // binding would produce a different set and fail here. | ||
| TEST_F(IcebergReaderCreateColumnIdsTest, parquet_name_mapped_and_synthesized_slots) { | ||
| // Physical Parquet schema (BY_NAME / partial-id file): | ||
| // legacy_a: id-less real data column -> column id 1 | ||
| // stale: unrelated column carrying stale id 0 -> column id 2 | ||
| FieldDescriptor field_desc; | ||
| FieldSchema legacy_a; | ||
| legacy_a.name = "legacy_a"; | ||
| legacy_a.data_type = | ||
| DataTypeFactory::instance().create_data_type(PrimitiveType::TYPE_BIGINT, true); | ||
| legacy_a.field_id = -1; | ||
| field_desc._fields.emplace_back(legacy_a); | ||
| FieldSchema stale; | ||
| stale.name = "stale"; | ||
| stale.data_type = | ||
| DataTypeFactory::instance().create_data_type(PrimitiveType::TYPE_BIGINT, true); | ||
| stale.field_id = 0; // collides with the projected slot's default col_unique_id (0) | ||
| field_desc._fields.emplace_back(stale); | ||
|
|
||
| // Table column "a" resolves BY NAME to physical "legacy_a"; the synthesized global row-id | ||
| // column is intentionally NOT registered. | ||
| auto struct_node = std::make_shared<TableSchemaChangeHelper::StructNode>(); | ||
| struct_node->add_children("a", "legacy_a", TableSchemaChangeHelper::ConstNode::get_instance()); | ||
| std::shared_ptr<TableSchemaChangeHelper::Node> table_info_node = struct_node; | ||
|
|
||
| SlotDescriptor a_slot; | ||
| a_slot._type = DataTypeFactory::instance().create_data_type(PrimitiveType::TYPE_BIGINT, true); | ||
| a_slot._col_name = "a"; | ||
|
|
||
| SlotDescriptor row_id_slot; | ||
| row_id_slot._type = | ||
| DataTypeFactory::instance().create_data_type(PrimitiveType::TYPE_BIGINT, true); | ||
| row_id_slot._col_name = BeConsts::GLOBAL_ROWID_COL; | ||
|
|
||
| TupleDescriptor tuple_desc; | ||
| tuple_desc.add_slot(&a_slot); | ||
| tuple_desc.add_slot(&row_id_slot); | ||
|
|
||
| // No abort on the synthesized slot; "a" resolves BY NAME to "legacy_a" (column id 1), never to | ||
| // "stale" (column id 2) through the colliding field id. | ||
| const ColumnIdResult result = | ||
| IcebergParquetReader::_create_column_ids(&field_desc, &tuple_desc, table_info_node); | ||
| EXPECT_EQ(result.column_ids, (std::set<uint64_t> {1})); | ||
| EXPECT_TRUE(result.filter_column_ids.empty()); | ||
| } | ||
|
|
||
| TEST_F(IcebergReaderCreateColumnIdsTest, orc_name_mapped_and_synthesized_slots) { | ||
| // Physical ORC schema (BY_NAME): legacy_a -> column id 1, stale -> column id 2. "stale" carries | ||
| // an iceberg.id attribute colliding with the projected slot's default field id (0). | ||
| std::unique_ptr<orc::Type> orc_type( | ||
| orc::Type::buildTypeFromString("struct<legacy_a:bigint,stale:bigint>")); | ||
| orc_type->getSubtype(1)->setAttribute(IcebergOrcReader::ICEBERG_ORC_ATTRIBUTE, "0"); | ||
|
|
||
| // Table column "a" resolves BY NAME to physical "legacy_a"; the synthesized global row-id | ||
| // column is intentionally NOT registered. | ||
| auto struct_node = std::make_shared<TableSchemaChangeHelper::StructNode>(); | ||
| struct_node->add_children("a", "legacy_a", TableSchemaChangeHelper::ConstNode::get_instance()); | ||
| std::shared_ptr<TableSchemaChangeHelper::Node> table_info_node = struct_node; | ||
|
|
||
| SlotDescriptor a_slot; | ||
| a_slot._type = DataTypeFactory::instance().create_data_type(PrimitiveType::TYPE_BIGINT, true); | ||
| a_slot._col_name = "a"; | ||
|
|
||
| SlotDescriptor row_id_slot; | ||
| row_id_slot._type = | ||
| DataTypeFactory::instance().create_data_type(PrimitiveType::TYPE_BIGINT, true); | ||
| row_id_slot._col_name = BeConsts::GLOBAL_ROWID_COL; | ||
|
|
||
| TupleDescriptor tuple_desc; | ||
| tuple_desc.add_slot(&a_slot); | ||
| tuple_desc.add_slot(&row_id_slot); | ||
|
|
||
| // No abort on the synthesized slot; "a" resolves BY NAME to "legacy_a" (column id 1), never to | ||
| // "stale" (column id 2) through the colliding field id. | ||
| const ColumnIdResult result = | ||
| IcebergOrcReader::_create_column_ids(orc_type.get(), &tuple_desc, table_info_node); | ||
| EXPECT_EQ(result.column_ids, (std::set<uint64_t> {1})); | ||
| EXPECT_TRUE(result.filter_column_ids.empty()); | ||
| } | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This touched C++ file is missing its final newline ( |
||
| } // namespace doris | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These new BE unit tests only cover the unregistered synthesized-slot crash with an identity schema mapping (
id->id). The production branch being protected also relies onchildren_file_column_name()to keep column-id pruning aligned with BY_NAME/name-mapping decisions, and the existing review threads already caught bugs in that non-identity partial-id boundary. Please add Parquet and ORC cases where the logical slot maps throughStructNodeto a differently named physical field, ideally with an unrelated/stale field id present, so the test would fail if_create_column_ids()regressed back to id-only or identity-name binding.