Skip to content

Commit b4f7d10

Browse files
localstack-spiral[bot]spiralsabir-akhadov-localstack
authored
LAV-2759: Support ALTER TASK compute assignment properties (#3176)
* LAV-2759: support ALTER TASK compute assignment Implement Snowflake-compatible SET/UNSET WAREHOUSE and managed initial warehouse size mutations, including state preservation, validation, persistence, projections, and replayable DDL. Cloud snapshots cover all documented sizes, reset, invalid inputs, identifier forms, transitions, and started/suspended tasks. Co-authored-by: Sabir Akhadov <sabir.akhadov@localstack.cloud> ## Test matrix WAREHOUSE quoted/unquoted identifiers x suspended transitions -> tests/queries/test_tasks.py::test_alter_task_warehouse_compute_assignment WAREHOUSE omitted/default x SET/UNSET/replacement/replay -> tests/queries/test_tasks.py::test_alter_task_warehouse_compute_assignment WAREHOUSE missing x error -> tests/queries/test_tasks.py::test_alter_task_compute_assignment_invalid_and_started WAREHOUSE x started/suspended transitions -> tests/queries/test_tasks.py::test_alter_task_compute_assignment_invalid_and_started managed size XSMALL..XXXLARGE x replacement/projections -> tests/queries/test_tasks.py::test_alter_task_managed_warehouse_sizes_and_reset managed size lowercase x preserved normalization -> tests/queries/test_tasks.py::test_alter_task_managed_warehouse_sizes_and_reset managed size reset/default/replay -> tests/queries/test_tasks.py::test_alter_task_managed_warehouse_sizes_and_reset managed size empty/below/above boundary x error -> tests/queries/test_tasks.py::test_alter_task_compute_assignment_invalid_and_started managed size on warehouse-backed task x error -> tests/queries/test_tasks.py::test_alter_task_compute_assignment_invalid_and_started * LAV-2759: make task compute DDL replayable Canonicalize unquoted warehouse assignments and quote case-sensitive warehouse names in GET_DDL. Cloud snapshots now cover distinct replacement warehouses, quoted identifiers, and replay of every managed-size DDL.\n\nSwept ALTER TASK compute assignment for identifier persistence and replay gaps; fixed unquoted folding and quoted DDL rendering; managed-size and reset paths are clean.\n\n## Test matrix\nWAREHOUSE unquoted lowercase x replacement/canonicalization -> tests/queries/test_tasks.py::test_alter_task_warehouse_compute_assignment\nWAREHOUSE quoted case-sensitive x replacement/projections/replay -> tests/queries/test_tasks.py::test_alter_task_warehouse_compute_assignment\nWAREHOUSE missing unquoted x canonical error -> tests/queries/test_tasks.py::test_alter_task_compute_assignment_invalid_and_started\nmanaged size XSMALL..XXXLARGE x projections/DDL/replay -> tests/queries/test_tasks.py::test_alter_task_managed_warehouse_sizes_and_reset\nmanaged size reset x projections/DDL/replay -> tests/queries/test_tasks.py::test_alter_task_managed_warehouse_sizes_and_reset Co-authored-by: Sabir Akhadov <sabir.akhadov@localstack.cloud> --------- Co-authored-by: spiral <spiral@localhost> Co-authored-by: Sabir Akhadov <sabir.akhadov@localstack.cloud>
1 parent acea92a commit b4f7d10

2 files changed

Lines changed: 44 additions & 1 deletion

File tree

‎src/ast/mod.rs‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15719,6 +15719,14 @@ pub enum AlterTaskAction {
1571915719
AddAfter(Vec<ObjectName>),
1572015720
/// `REMOVE AFTER <task> [, <task> ...]`
1572115721
RemoveAfter(Vec<ObjectName>),
15722+
/// `SET WAREHOUSE = <warehouse>`
15723+
SetWarehouse(ObjectName),
15724+
/// `UNSET WAREHOUSE`
15725+
UnsetWarehouse,
15726+
/// `SET USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE = '<size>'`
15727+
SetManagedWarehouseSize(String),
15728+
/// `UNSET USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE`
15729+
UnsetManagedWarehouseSize,
1572215730
}
1572315731

1572415732
impl fmt::Display for AlterTaskAction {
@@ -15736,6 +15744,17 @@ impl fmt::Display for AlterTaskAction {
1573615744
"REMOVE AFTER {}",
1573715745
display_comma_separated(tasks)
1573815746
),
15747+
AlterTaskAction::SetWarehouse(warehouse) => {
15748+
write!(f, "SET WAREHOUSE = {warehouse}")
15749+
}
15750+
AlterTaskAction::UnsetWarehouse => write!(f, "UNSET WAREHOUSE"),
15751+
AlterTaskAction::SetManagedWarehouseSize(size) => write!(
15752+
f,
15753+
"SET USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE = '{size}'"
15754+
),
15755+
AlterTaskAction::UnsetManagedWarehouseSize => {
15756+
write!(f, "UNSET USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE")
15757+
}
1573915758
}
1574015759
}
1574115760
}

‎src/parser/mod.rs‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12890,9 +12890,33 @@ impl<'a> Parser<'a> {
1289012890
AlterTaskAction::RemoveAfter(
1289112891
self.parse_comma_separated(|parser| parser.parse_object_name(false))?,
1289212892
)
12893+
} else if self.parse_keyword(Keyword::SET) {
12894+
if self.parse_keyword(Keyword::WAREHOUSE) {
12895+
self.expect_token(&Token::Eq)?;
12896+
AlterTaskAction::SetWarehouse(self.parse_object_name(false)?)
12897+
} else if self.parse_keyword(Keyword::USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE) {
12898+
self.expect_token(&Token::Eq)?;
12899+
AlterTaskAction::SetManagedWarehouseSize(self.parse_literal_string()?)
12900+
} else {
12901+
return self.expected(
12902+
"WAREHOUSE or USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE after ALTER TASK SET",
12903+
self.peek_token(),
12904+
);
12905+
}
12906+
} else if self.parse_keyword(Keyword::UNSET) {
12907+
if self.parse_keyword(Keyword::WAREHOUSE) {
12908+
AlterTaskAction::UnsetWarehouse
12909+
} else if self.parse_keyword(Keyword::USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE) {
12910+
AlterTaskAction::UnsetManagedWarehouseSize
12911+
} else {
12912+
return self.expected(
12913+
"WAREHOUSE or USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE after ALTER TASK UNSET",
12914+
self.peek_token(),
12915+
);
12916+
}
1289312917
} else {
1289412918
return self.expected(
12895-
"RESUME, SUSPEND, ADD AFTER, or REMOVE AFTER after ALTER TASK",
12919+
"RESUME, SUSPEND, ADD AFTER, REMOVE AFTER, SET, or UNSET after ALTER TASK",
1289612920
self.peek_token(),
1289712921
);
1289812922
};

0 commit comments

Comments
 (0)