Skip to content

Commit

Permalink
sleep function
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangstar333 committed Mar 8, 2024
1 parent ee0a348 commit 90568ef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 11 additions & 1 deletion be/src/vec/functions/function_utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,23 @@ class FunctionSleep : public IFunction {

bool use_default_implementation_for_nulls() const override { return false; }

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;

auto res_column = ColumnUInt8::create();

if (auto* nullable_column = check_and_get_column<ColumnNullable>(*argument_column)) {
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)) {
auto null_map_column = ColumnUInt8::create();

auto nested_column = nullable_column->get_nested_column_ptr();
Expand Down
3 changes: 1 addition & 2 deletions regression-test/suites/job_p0/test_base_insert_job.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ import java.time.format.DateTimeFormatter;
import java.time.Instant;
import java.time.ZoneId;

suite("test_base_insert_job", "nonConcurrent") {
suite("test_base_insert_job") {
def tableName = "t_test_BASE_inSert_job"
def jobName = "insert_recovery_test_base_insert_job"
def jobMixedName = "Insert_recovery_Test_base_insert_job"
sql """drop table if exists `${tableName}` force"""
sql """set experimental_enable_nereids_dml_with_pipeline=false;"""
sql """
DROP JOB IF EXISTS where jobname = '${jobName}'
"""
Expand Down

0 comments on commit 90568ef

Please sign in to comment.