Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions be/src/core/column/column_variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ size_t get_number_of_dimensions(const IDataType& type) {
// which indicates NG-originated array<object> data.
bool is_nested_group_type(const DataTypePtr& type) {
auto base = get_base_type_of_array(type);
if (get_number_of_dimensions(*type) > 0) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Preserve regular-array rows when the NG type becomes the LCT. If the destination already contains a mixed Array<Jsonb> and the source is NESTED_TYPE, this newly true result makes resolve_ng_type_conflict() select the NG type and leave the old array part in place; Subcolumn::finalize() then sees an NG/non-NG mismatch and inserts defaults for every old row. Reversing the inputs instead reaches the same-dimensional array cast at lines 392-424 and preserves the values, so hierarchical/materialized merges become order-dependent. Distinguish genuine scalar conflicts from regular arrays during resolution/finalization, and cover both input orders.

base = remove_nullable(base);
}
return typeid_cast<const DataTypeVariant*>(base.get()) != nullptr;
}

Expand Down
8 changes: 8 additions & 0 deletions be/test/core/column/column_variant_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3610,6 +3610,14 @@ TEST_F(ColumnVariantTest, subcolumn_finalize_and_insert) {
array_subcolumn.finalize();
}

TEST(ColumnVariantNestedGroupTypeTest, nullable_array_element_is_recognized) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Please exercise the conflict-policy behavior, not only the helper. The reported regression is that this predicate used to bypass Subcolumn::insert_range_from/finalize, but this test would still pass if the merge kept the wrong LCT, discarded the NestedGroup row, or ignored the ERROR policy. Add a focused merge test with an actual NESTED_TYPE value and a scalar in both source/destination orders, asserting that the default policy preserves the NestedGroup value and defaults only the scalar; also cover variant_nested_group_discard_scalar_on_conflict=false throwing in both orders.

EXPECT_TRUE(is_nested_group_type(ColumnVariant::NESTED_TYPE));

auto variant = std::make_shared<DataTypeVariant>(0, false);
EXPECT_TRUE(is_nested_group_type(variant));
EXPECT_FALSE(is_nested_group_type(make_nullable(variant)));
}

TEST_F(ColumnVariantTest, deserialize_mixed_array_elements) {
ColumnVariant::Subcolumn subcolumn(0, true /* is_nullable */, false /* is_root */);

Expand Down
Loading