-
Notifications
You must be signed in to change notification settings - Fork 445
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
[GLUTEN-8253][CH] Fix cast failed when in-filter with tuple values #8256
base: main
Are you sure you want to change the base?
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 |
---|---|---|
|
@@ -418,12 +418,11 @@ const ActionsDAG::Node * ExpressionParser::parseExpression(ActionsDAG & actions_ | |
} | ||
|
||
DB::DataTypePtr elem_type; | ||
std::tie(elem_type, std::ignore) = LiteralParser::parse(options[0].literal()); | ||
elem_type = wrapNullableType(nullable, elem_type); | ||
|
||
DB::MutableColumnPtr elem_column = elem_type->createColumn(); | ||
elem_column->reserve(options_len); | ||
for (int i = 0; i < options_len; ++i) | ||
std::vector<std::pair<DB::DataTypePtr, DB::Field>> options_type_and_field; | ||
auto first_option = LiteralParser::parse(options[0].literal()); | ||
elem_type = wrapNullableType(nullable, first_option.first); | ||
options_type_and_field.emplace_back(first_option); | ||
for (int i = 1; i < options_len; ++i) | ||
{ | ||
auto type_and_field = LiteralParser::parse(options[i].literal()); | ||
auto option_type = wrapNullableType(nullable, type_and_field.first); | ||
|
@@ -433,8 +432,31 @@ const ActionsDAG::Node * ExpressionParser::parseExpression(ActionsDAG & actions_ | |
"SingularOrList options type mismatch:{} and {}", | ||
elem_type->getName(), | ||
option_type->getName()); | ||
options_type_and_field.emplace_back(type_and_field); | ||
} | ||
|
||
elem_column->insert(type_and_field.second); | ||
// check tuple internal types | ||
if (isTuple(elem_type) && isTuple(args[0]->result_type)) | ||
{ | ||
// align tuple inner types with nullable | ||
auto tuple_type = std::static_pointer_cast<const DB::DataTypeTuple>(elem_type); | ||
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. use checkAndGetDataType |
||
auto result_type = std::static_pointer_cast<const DB::DataTypeTuple>(args[0]->result_type); | ||
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. as above |
||
assert(tuple_type->getElements().size() == result_type->getElements().size()); | ||
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. use chassert |
||
DataTypes new_types; | ||
for (int i = 0; i < tuple_type->getElements().size(); ++i) | ||
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. better to refactor it with
|
||
{ | ||
auto tuple_elem_type = tuple_type->getElements()[i]; | ||
auto result_elem_type = result_type->getElements()[i]; | ||
if (result_elem_type->isNullable() && !tuple_elem_type->isNullable()) | ||
new_types.emplace_back(wrapNullableType(tuple_elem_type)); | ||
} | ||
elem_type = std::make_shared<DB::DataTypeTuple>(new_types); | ||
} | ||
DB::MutableColumnPtr elem_column = elem_type->createColumn(); | ||
elem_column->reserve(options_len); | ||
for (int i = 0; i < options_len; ++i) | ||
{ | ||
elem_column->insert(options_type_and_field[i].second); | ||
} | ||
auto name = getUniqueName("__set"); | ||
ColumnWithTypeAndName elem_block{std::move(elem_column), elem_type, name}; | ||
|
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.
better add std::move