Skip to content

Commit

Permalink
[fix](nestedtype)fix nested type with is_exclusive (apache#40398)
Browse files Browse the repository at this point in the history
is_exclusive in column_array/map/struct has wrong semantic , we should
make sure it's nested column is also is_exclusive which can make
behavior right in some operator like join.
  • Loading branch information
amorynan committed Oct 10, 2024
1 parent 66967cb commit ce0d972
Show file tree
Hide file tree
Showing 7 changed files with 792 additions and 0 deletions.
5 changes: 5 additions & 0 deletions be/src/vec/columns/column_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ class ColumnArray final : public COWHelper<IColumn, ColumnArray> {
bool is_column_array() const override { return true; }
bool can_be_inside_nullable() const override { return true; }
bool is_variable_length() const override { return true; }

bool is_exclusive() const override {
return IColumn::is_exclusive() && data->is_exclusive() && offsets->is_exclusive();
}

MutableColumnPtr clone_resized(size_t size) const override;
size_t size() const override;
void resize(size_t n) override;
Expand Down
4 changes: 4 additions & 0 deletions be/src/vec/columns/column_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ class ColumnMap final : public COWHelper<IColumn, ColumnMap> {
bool is_variable_length() const override { return true; }

bool can_be_inside_nullable() const override { return true; }
bool is_exclusive() const override {
return IColumn::is_exclusive() && keys_column->is_exclusive() &&
values_column->is_exclusive() && offsets_column->is_exclusive();
}

Field operator[](size_t n) const override;
void get(size_t n, Field& res) const override;
Expand Down
10 changes: 10 additions & 0 deletions be/src/vec/columns/column_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1001,4 +1001,14 @@ void ColumnObject::insert_indices_from(const IColumn& src, const int* indices_be
});
}

bool ColumnObject::is_exclusive() const {
bool is_exclusive = IColumn::is_exclusive();
for_each_imutable_subcolumn([&](const auto& subcolumn) {
if (!subcolumn.is_exclusive()) {
is_exclusive = false;
}
});
return is_exclusive;
}

} // namespace doris::vectorized
2 changes: 2 additions & 0 deletions be/src/vec/columns/column_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ class ColumnObject final : public COWHelper<IColumn, ColumnObject> {
/// Checks that all subcolumns have consistent sizes.
void check_consistency() const;

bool is_exclusive() const override;

bool has_subcolumn(const PathInData& key) const;

// return null if not found
Expand Down
9 changes: 9 additions & 0 deletions be/src/vec/columns/column_struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ class ColumnStruct final : public COWHelper<IColumn, ColumnStruct> {
MutableColumnPtr clone_resized(size_t size) const override;
size_t size() const override { return columns.at(0)->size(); }

bool is_exclusive() const override {
for (const auto& col : columns) {
if (!col->is_exclusive()) {
return false;
}
}
return IColumn::is_exclusive();
}

Field operator[](size_t n) const override;
void get(size_t n, Field& res) const override;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !nested_with_join --
0

-- !nested_with_join_2 --
0

-- !nested_with_join_3 --
0

-- !nested_with_join_4 --
max_allowed_packet 4194304 16777216 1

-- !nested_with_join_5 --
0

-- !nested_with_join_6 --
0

-- !nested_with_join_7 --
0

-- !nested_with_join_8 --
0

-- !nested_with_join_9 --
0

-- !nested_with_join_10 --
0

-- !nested_with_join_11 --
0

-- !nested_with_join_12 --
0

-- !nested_with_join_13 --
0

-- !nested_with_join_14 --
0

-- !nested_with_join_15 --
0

-- !nested_with_join_16 --
0

-- !nested_with_join_17 --
0

-- !nested_with_join_18 --
10

-- !nested_with_join_19 --
0

-- !nested_with_join_20 --
10

-- !nested_with_join_21 --
0

-- !nested_with_join_22 --
15

-- !nested_with_join_23 --
0

-- !nested_with_join_24 --
15

-- !nested_with_join_25 --
0

-- !nested_with_join_26 --
10

-- !nested_with_join_27 --
0

-- !nested_with_join_28 --
10

-- !nested_with_join_29 --

Loading

0 comments on commit ce0d972

Please sign in to comment.