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 Sep 5, 2024
1 parent 961d2c9 commit fc3d161
Show file tree
Hide file tree
Showing 7 changed files with 793 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 @@ -130,6 +130,11 @@ class ColumnArray final : public COWHelper<IColumn, ColumnArray> {
const char* get_family_name() const override { return "Array"; }
bool is_column_array() 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
5 changes: 5 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,11 @@ class ColumnMap final : public COWHelper<IColumn, ColumnMap> {
MutableColumnPtr clone_resized(size_t size) const override;
bool is_variable_length() 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;
StringRef get_data_at(size_t n) 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 @@ -1632,6 +1632,16 @@ void ColumnObject::for_each_imutable_subcolumn(ImutableColumnCallback callback)
}
}

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

void ColumnObject::update_hash_with_value(size_t n, SipHash& hash) const {
for_each_imutable_subcolumn(
[&](const auto& subcolumn) { return subcolumn.update_hash_with_value(n, hash); });
Expand Down
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 @@ -280,6 +280,8 @@ class ColumnObject final : public COWHelper<IColumn, ColumnObject> {
// Only single scalar root column
bool is_scalar_variant() const;

bool is_exclusive() const override;

ColumnPtr get_root() const { return subcolumns.get_root()->data.get_finalized_column_ptr(); }

bool has_subcolumn(const PathInData& key) const;
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 @@ -90,6 +90,15 @@ class ColumnStruct final : public COWHelper<IColumn, ColumnStruct> {

bool is_variable_length() const override { return true; }

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 fc3d161

Please sign in to comment.