Skip to content

Commit 76eb998

Browse files
localstack-spiral[bot]spiralhovaesco
authored
LAV-3283: retry a selected task graph run group (#3664)
Parse the quoted group ID, route it through both task execution paths, and select the named root task group for retry. Match Cloud-captured not-found and in-progress errors, retain the selected group and advance its attempt. Co-authored-by: Przemek Denkiewicz <przemyslaw.denkiewicz@localstack.cloud> ## Test matrix bare EXECUTE TASK × success -> tests/queries/test_tasks.py::test_execute_task RETRY LAST × existing graph/error paths -> tests/queries/test_tasks.py::test_execute_task_retry_last_graph specific older group × failed child -> tests/queries/test_tasks.py::test_execute_task_retry_graph_run_group_older specific older group × succeeded root omitted -> tests/queries/test_tasks.py::test_execute_task_retry_graph_run_group_older specific older group × eligible descendant -> tests/queries/test_tasks.py::test_execute_task_retry_graph_run_group_older specific group × successful run -> tests/queries/test_tasks.py::test_execute_task_retry_graph_run_group_rejections specific group × in-progress run -> tests/queries/test_tasks.py::test_execute_task_retry_graph_run_group_in_progress specific group × another root task -> tests/queries/test_tasks.py::test_execute_task_retry_graph_run_group_rejections specific group × unknown UUID -> tests/queries/test_tasks.py::test_execute_task_retry_graph_run_group_rejections specific group × empty or malformed quoted ID -> tests/queries/test_tasks.py::test_execute_task_retry_graph_run_group_rejections specific group × changed graph -> tests/queries/test_tasks.py::test_execute_task_retry_graph_run_group_rejections specific group × canceled task -> uncovered: env-blocked; no constructible canceled task run in the current compat fixture, shared FAILED/CANCELED selector remains in place specific group × first-attempt 14-day boundary -> uncovered: env-blocked; neither Cloud account has an aged task run fixture. Verified the documented 14-day rule in the EXECUTE TASK resource entry; implementation compares the selected group earliest created_at to current_timestamp - interval 14 days. ## Deviations The hint says TASK_HISTORY projects a constant ATTEMPT_NUMBER. The current projection already reads th.attempt_number, so no projection change was needed. Co-authored-by: spiral <spiral@localhost> Co-authored-by: Przemek Denkiewicz <przemyslaw.denkiewicz@localstack.cloud>
1 parent a4db697 commit 76eb998

4 files changed

Lines changed: 24 additions & 10 deletions

File tree

‎src/ast/mod.rs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5388,14 +5388,16 @@ pub enum Statement {
53885388
action: AlterTaskAction,
53895389
},
53905390
/// ```sql
5391-
/// EXECUTE TASK <name> [RETRY LAST]
5391+
/// EXECUTE TASK <name> [RETRY LAST | RETRY GRAPH RUN GROUP '<id>']
53925392
/// ```
53935393
/// See <https://docs.snowflake.com/en/sql-reference/sql/execute-task>
53945394
ExecuteTask {
53955395
/// Task name.
53965396
name: ObjectName,
53975397
/// Retry the latest failed graph run.
53985398
retry_last: bool,
5399+
/// Retry a specific graph run group.
5400+
retry_graph_run_group: Option<String>,
53995401
},
54005402
/// ```sql
54015403
/// EXECUTE ALERT <name>
@@ -9010,10 +9012,12 @@ impl fmt::Display for Statement {
90109012
}
90119013
write!(f, " {name} {operation}")
90129014
}
9013-
Statement::ExecuteTask { name, retry_last } => {
9015+
Statement::ExecuteTask { name, retry_last, retry_graph_run_group } => {
90149016
write!(f, "EXECUTE TASK {name}")?;
90159017
if *retry_last {
90169018
write!(f, " RETRY LAST")?;
9019+
} else if let Some(group_id) = retry_graph_run_group {
9020+
write!(f, " RETRY GRAPH RUN GROUP '{}'", group_id.replace('\'', "''"))?;
90179021
}
90189022
Ok(())
90199023
}

‎src/keywords.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ define_keywords!(
517517
GRANT,
518518
GRANTED,
519519
GRANTS,
520+
GRAPH,
520521
GRAPHVIZ,
521522
GROUP,
522523
GROUPING,

‎src/parser/mod.rs‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22811,13 +22811,21 @@ impl<'a> Parser<'a> {
2281122811
// path can't accidentally consume `TASK`.
2281222812
if self.parse_keyword(Keyword::TASK) {
2281322813
let name = self.parse_object_name(false)?;
22814-
let retry_last = if self.parse_keyword(Keyword::RETRY) {
22815-
self.expect_keyword(Keyword::LAST)?;
22816-
true
22817-
} else {
22818-
false
22819-
};
22820-
return Ok(Statement::ExecuteTask { name, retry_last });
22814+
let mut retry_last = false;
22815+
let mut retry_graph_run_group = None;
22816+
if self.parse_keyword(Keyword::RETRY) {
22817+
if self.parse_keyword(Keyword::LAST) {
22818+
retry_last = true;
22819+
} else {
22820+
self.expect_keywords(&[Keyword::GRAPH, Keyword::RUN, Keyword::GROUP])?;
22821+
let token = self.next_token();
22822+
retry_graph_run_group = Some(match token.token {
22823+
Token::SingleQuotedString(value) => value,
22824+
_ => return self.expected("single-quoted graph run group ID", token),
22825+
});
22826+
}
22827+
}
22828+
return Ok(Statement::ExecuteTask { name, retry_last, retry_graph_run_group });
2282122829
}
2282222830

2282322831
// Snowflake `EXECUTE ALERT <name>` — same early-dispatch reasoning as

‎tests/sqlparser_snowflake.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8359,9 +8359,10 @@ fn test_alter_task_if_exists_suspend() {
83598359
fn test_execute_task() {
83608360
let sql = "EXECUTE TASK foo";
83618361
match snowflake().verified_stmt(sql) {
8362-
Statement::ExecuteTask { name, retry_last } => {
8362+
Statement::ExecuteTask { name, retry_last, retry_graph_run_group } => {
83638363
assert_eq!("foo", name.to_string());
83648364
assert!(!retry_last);
8365+
assert_eq!(retry_graph_run_group, None);
83658366
}
83668367
_ => unreachable!(),
83678368
}

0 commit comments

Comments
 (0)