-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[fix](sleep) sleep with character const make be crash #37681
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 |
---|---|---|
|
@@ -62,31 +62,26 @@ class FunctionSleep : public IFunction { | |
size_t get_number_of_arguments() const override { return 1; } | ||
|
||
DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { | ||
if (arguments[0].get()->is_nullable()) { | ||
if (arguments[0]->is_nullable()) { | ||
return make_nullable(std::make_shared<DataTypeUInt8>()); | ||
} | ||
return std::make_shared<DataTypeUInt8>(); | ||
} | ||
|
||
bool use_default_implementation_for_nulls() const override { return false; } | ||
|
||
// Sleep function should not be executed during open stage, this will makes fragment prepare | ||
// waiting too long, so we do not use default impl. | ||
bool use_default_implementation_for_constants() const override { return false; } | ||
|
||
Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, | ||
size_t result, size_t input_rows_count) const override { | ||
ColumnPtr& argument_column = block.get_by_position(arguments[0]).column; | ||
const auto& argument_column = | ||
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 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. there are already lots of convert_to_full_column_if_const used, maybe next time, we refractor all these used is better. |
||
block.get_by_position(arguments[0]).column->convert_to_full_column_if_const(); | ||
|
||
auto res_column = ColumnUInt8::create(); | ||
|
||
if (is_column_const(*argument_column)) { | ||
Int64 seconds = argument_column->get_int(0); | ||
for (int i = 0; i < input_rows_count; i++) { | ||
std::this_thread::sleep_for(std::chrono::seconds(seconds)); | ||
res_column->insert(1); | ||
} | ||
|
||
block.replace_by_position(result, std::move(res_column)); | ||
} else if (auto* nullable_column = check_and_get_column<ColumnNullable>(*argument_column)) { | ||
if (auto* nullable_column = check_and_get_column<ColumnNullable>(*argument_column)) { | ||
auto null_map_column = ColumnUInt8::create(); | ||
|
||
auto nested_column = nullable_column->get_nested_column_ptr(); | ||
|
@@ -154,4 +149,4 @@ void register_function_utility(SimpleFunctionFactory& factory) { | |
factory.register_function<FunctionVersion>(); | ||
} | ||
|
||
} // namespace doris::vectorized | ||
} // namespace doris::vectorized |
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.
Could you please add some comment to explain why we not using default_impl for const?
"Sleep function should not be executed during open stage, this will makes fragment prepare waiting too long, so we do not use default impl."
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.
done