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: add SQL syntax support for alter, execute, describe, show, drop task #13344

Merged
merged 1 commit into from Oct 20, 2023

Conversation

ZhiHanZ
Copy link
Collaborator

@ZhiHanZ ZhiHanZ commented Oct 19, 2023

… task

I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/

Summary

  1. Support Alter Task Semantics

  2. Support Drop Task Semantics

  3. Support Execute Task Semantics

  4. Support Describe Task Semantics

  5. Support Show Task Semantics

  6. Add Unit Tests

Description

Alter Task Semantics

ALTER TASK [ IF EXISTS ] <name> RESUME | SUSPEND

ALTER TASK [ IF EXISTS ] <name> MODIFY AS <sql>

ALTER TASK [ IF EXISTS ] <name> SET
  [ WAREHOUSE = <string> ]
  [ SCHEDULE = '{ <number> MINUTE | USING CRON <expr> <time_zone> }' ]
  [ SUSPEND_TASK_AFTER_NUM_FAILURES = <num> ]
  [ COMMENT = <string> ]

ALTER TASK [ IF EXISTS ] <name> UNSET
  [ WAREHOUSE ]
Parameter Description
<name> The name of the task to be altered.
RESUME | SUSPEND These keywords are used to either resume or suspend the specified task.
MODIFY AS <sql> Modifies the SQL statement of the specified task to the new SQL statement provided.
SET This keyword is followed by one or more of the optional settings below, to modify the configuration of the specified task.
- WAREHOUSE = <string> Sets the warehouse for the specified task to the provided string value.
- SCHEDULE = '{ <number> MINUTE | USING CRON <expr> <time_zone> }' Sets the schedule for the specified task. You can specify an interval in minutes or a cron expression along with a timezone.
- SUSPEND_TASK_AFTER_NUM_FAILURES = <num> Sets the number of consecutive failures after which the task should be suspended, to the provided numeric value.
- COMMENT = <string> Sets the comment or description for the specified task to the provided string value. This is useful for documenting the purpose or behavior of the task.
UNSET This keyword is followed by one or more of the optional settings below, to remove the specified configurations from the task.
- [ WAREHOUSE ] Unsets the warehouse setting for the specified task, reverting it to the default or previous setting.

Examples

Certainly! Below are descriptions for the provided SQL commands in the expected format:


The following example resumes the task named MyTask1.

ALTER TASK MyTask1 RESUME

The following example suspends the task named MyTask1.

ALTER TASK MyTask1 SUSPEND

The following example modifies the settings of the task named MyTask1, setting a specific warehouse, a cron schedule, and a comment.

ALTER TASK MyTask1 SET WAREHOUSE= 'MyWarehouse' SCHEDULE = USING CRON '0 6 * * *' 'America/Los_Angeles' COMMENT = 'serverless + cron'

The following example modifies the settings of the task named MyTask1, setting a specific warehouse, an interval schedule, the number of failures after which to suspend the task, and a comment.

ALTER TASK MyTask1 SET WAREHOUSE= 'MyWarehouse' SCHEDULE = 13 MINUTE SUSPEND_TASK_AFTER_NUM_FAILURES = 10 COMMENT = 'serverless + cron'

The following example modifies the SQL statement of the task named MyTask2 to a new SQL statement.

ALTER TASK MyTask2 MODIFY AS SELECT CURRENT_VERSION()

Drop Task Semantics

DROP TASK [ IF EXISTS ] <name>
Parameter Description
[ IF EXISTS ] This optional clause prevents an error from occurring if the task does not exist.
<name> The name of the task to be dropped.

Examples


The following example drops the task named MyTask1 if it exists.

DROP TASK IF EXISTS MyTask1

Show Tasks Semantics

SHOW TASKS [ LIKE '<pattern>' ]
Parameter Description
[ LIKE '<pattern>' ] This optional clause filters the tasks to be shown based on a pattern matching the task names.

Examples


The following example shows all tasks with names that start with My.

SHOW TASKS LIKE 'My%'

Describe Task Semantics

DESC | DESCRIBE TASK <name>
Parameter Description
<name> The name of the task to be described.

Examples


The following example describes the task named MyTask1.

DESC TASK MyTask1

Execute Task Semantics

EXECUTE TASK <name>
Parameter Description
<name> The name of the task to be executed.

Examples


The following example executes the task named MyTask1.

EXECUTE TASK MyTask1


This change is Reviewable

@vercel
Copy link

vercel bot commented Oct 19, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
databend ⬜️ Ignored (Inspect) Visit Preview Oct 19, 2023 1:02pm

@github-actions github-actions bot added the pr-feature this PR introduces a new feature to the codebase label Oct 19, 2023
@BohuTANG BohuTANG merged commit 3f2e419 into datafuselabs:main Oct 20, 2023
62 checks passed
andylokandy pushed a commit to andylokandy/databend that referenced this pull request Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-feature this PR introduces a new feature to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants