Skip to content
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

feat: support sleep function #5448

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: ci and tests
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
yihong0618 committed Jan 24, 2025
commit aeb742e2901ffc3b8f961451c887d82d915d8bad
14 changes: 14 additions & 0 deletions src/common/function/src/scalars/sleep.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2023 Greptime Team
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use std::sync::Arc;
use std::time::Duration;
use std::{fmt, thread};
18 changes: 18 additions & 0 deletions tests/cases/standalone/common/function/sleep.result
Original file line number Diff line number Diff line change
@@ -20,3 +20,21 @@ select pg_sleep(0.1);
Error: 3000(PlanQuery), Failed to plan SQL: Error during planning: Invalid function 'pg_sleep'.
Did you mean 'sleep'?

-- SQLNESS PROTOCOL POSTGRES
select pg_sleep(0.5);

+---------------------+
| sleep(Float64(0.5)) |
+---------------------+
| 0 |
+---------------------+

-- SQLNESS PROTOCOL POSTGRES
select pg_sleep(2) as b;

+---+
| b |
+---+
| 2 |
+---+

4 changes: 2 additions & 2 deletions tests/cases/standalone/common/function/sleep.sql
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ select sleep(1) as a;
select pg_sleep(0.1);

-- SQLNESS PROTOCOL POSTGRES
select pg_sleep(0.5);
select pg_sleep(0.5);

-- SQLNESS PROTOCOL POSTGRES
select pg_sleep(2) as b;
select pg_sleep(2) as b;