-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[refine](column) enforce nullable nested types for array and map #62491
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,7 +48,13 @@ namespace ErrorCodes { | |
| extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH; | ||
| } | ||
|
|
||
| DataTypeArray::DataTypeArray(const DataTypePtr& nested_) : nested {nested_} {} | ||
| DataTypeArray::DataTypeArray(const DataTypePtr& nested_) { | ||
| DataTypePtr nullable_nested = make_nullable(nested_); | ||
| auto nested_type = std::dynamic_pointer_cast<const DataTypeNullable>(nullable_nested); | ||
| DORIS_CHECK(nested_type != nullptr); | ||
| nested = std::move(nested_type); | ||
| nested_as_base = nested; | ||
|
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.
|
||
| } | ||
|
|
||
| MutableColumnPtr DataTypeArray::create_column() const { | ||
| return ColumnArray::create(nested->create_column(), ColumnArray::ColumnOffsets::create()); | ||
|
|
@@ -72,9 +78,10 @@ bool DataTypeArray::equals(const IDataType& rhs) const { | |
|
|
||
| // here we should remove nullable, otherwise here always be 1 | ||
| size_t DataTypeArray::get_number_of_dimensions() const { | ||
| const DataTypeArray* nested_array = | ||
| typeid_cast<const DataTypeArray*>(remove_nullable(nested).get()); | ||
| if (!nested_array) return 1; | ||
| auto* nested_array = typeid_cast<const DataTypeArray*>(remove_nullable(nested).get()); | ||
| if (!nested_array) { | ||
| return 1; | ||
| } | ||
| return 1 + | ||
| nested_array | ||
| ->get_number_of_dimensions(); /// Every modern C++ compiler optimizes tail recursion. | ||
|
|
@@ -133,7 +140,7 @@ const char* DataTypeArray::deserialize(const char* buf, MutableColumnPtr* column | |
|
|
||
| void DataTypeArray::to_pb_column_meta(PColumnMeta* col_meta) const { | ||
| IDataType::to_pb_column_meta(col_meta); | ||
| auto children = col_meta->add_children(); | ||
| auto* children = col_meta->add_children(); | ||
| get_nested_type()->to_pb_column_meta(children); | ||
| } | ||
|
|
||
|
|
||
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.
Wrapping every array child in
make_nullable()changes the type metadata you export later.DataTypeArray::to_protobuf()usesnested->is_nullable(), and FE'sFoldConstantRuleOnBE.convertToNereidsType()reconstructsArrayTypefrom that flag. After this change, a folded expression likeCAST([1] AS ARRAY<INT NOT NULL>)will round-trip back to FE asARRAY<INT>because BE now always reportscontains_null=true. FE still treatsArrayType.containsNullas part of exact type matching, so this is a real regression in the constant-folding path, not just an internal invariant cleanup. Please preserve the original child-nullability flag on the exported type metadata path or add a compatibility fix/test for it.