-
Notifications
You must be signed in to change notification settings - Fork 334
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: yihong0618 <[email protected]>
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
Signed-off-by: yihong0618 <[email protected]>
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.
Sorry for the late review. I'm not sure whether we should provide the sleep function, since this is mostly for test purpose.
// Sleep for the specified seconds TODO: use tokio::time::sleep when the scalars are async | ||
thread::sleep(Duration::from_secs_f64(secs)); |
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.
I'd suggest not to sleep in a scalar function. This pauses the runtime thread which is risky.
@@ -122,6 +123,9 @@ pub static FUNCTION_REGISTRY: Lazy<Arc<FunctionRegistry>> = Lazy::new(|| { | |||
// Vector related functions | |||
VectorFunction::register(&function_registry); | |||
|
|||
// Sleep function | |||
SleepFunction::register(&function_registry); |
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.
I'm hesitant about whether to provide a sleep function. We may only provide a sleep function under the admin statement if we really need this.
admin sleep(60);
If our final goal is to support kill query, the sleep function may not be the first thing we need to implement. We can implement a way to cancel a query first.
I hereby agree to the terms of the GreptimeDB CLA.
This patch is first part of #5072
to support sleep function to let the query sleep a time, then the kill query
ctrl +c
can easily to use.Some notes or need to disscuss
async
this patch follows itasync
it can usetokio
select now(); --ok
select * from now(); --not ok
Refer to a related PR or issue link (optional)
What's changed and what's your intention?
PR Checklist
Please convert it to a draft if some of the following conditions are not met.