Skip to content

Commit cd73989

Browse files
Task LAV-1783: GRANT/REVOKE privilege vocabulary — CREATE ALERT/TASK/VIEW/SHARE/AGENT/MCP SERVER, ON FUTURE TASKS IN, COMPUTE POOL (apache#2266)
Teach the grant grammar the schema-scoped CREATE privileges (ALERT, TASK, VIEW, AGENT, MCP SERVER), CREATE SHARE ON ACCOUNT, and the FUTURE TASKS object plural, and echo each verbatim through SHOW GRANTS. Account-scoped edges now report the account locator as `name` in SHOW GRANTS TO ROLE. GRANT/REVOKE ON COMPUTE POOL reproduces Snowflake's verbatim 002003/02000 rejection rather than recording a phantom grant. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent df7c35a commit cd73989

3 files changed

Lines changed: 28 additions & 0 deletions

File tree

src/ast/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10095,12 +10095,18 @@ impl fmt::Display for Action {
1009510095
pub enum ActionCreateObjectType {
1009610096
/// An account-level object.
1009710097
Account,
10098+
/// An agent object.
10099+
Agent,
10100+
/// An alert object.
10101+
Alert,
1009810102
/// An application object.
1009910103
Application,
1010010104
/// An application package object.
1010110105
ApplicationPackage,
1010210106
/// A compute pool object.
1010310107
ComputePool,
10108+
/// An MCP server object.
10109+
McpServer,
1010410110
/// A data exchange listing.
1010510111
DataExchangeListing,
1010610112
/// A class object identified by a qualified name, e.g.
@@ -10134,6 +10140,10 @@ pub enum ActionCreateObjectType {
1013410140
Share,
1013510141
/// A table object.
1013610142
Table,
10143+
/// A task object.
10144+
Task,
10145+
/// A view object.
10146+
View,
1013710147
/// A user object.
1013810148
User,
1013910149
/// A warehouse object.
@@ -10144,9 +10154,12 @@ impl fmt::Display for ActionCreateObjectType {
1014410154
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1014510155
match self {
1014610156
ActionCreateObjectType::Account => write!(f, "ACCOUNT"),
10157+
ActionCreateObjectType::Agent => write!(f, "AGENT"),
10158+
ActionCreateObjectType::Alert => write!(f, "ALERT"),
1014710159
ActionCreateObjectType::Application => write!(f, "APPLICATION"),
1014810160
ActionCreateObjectType::ApplicationPackage => write!(f, "APPLICATION PACKAGE"),
1014910161
ActionCreateObjectType::ComputePool => write!(f, "COMPUTE POOL"),
10162+
ActionCreateObjectType::McpServer => write!(f, "MCP SERVER"),
1015010163
ActionCreateObjectType::DataExchangeListing => write!(f, "DATA EXCHANGE LISTING"),
1015110164
ActionCreateObjectType::Class(name) => write!(f, "{name}"),
1015210165
ActionCreateObjectType::Database => write!(f, "DATABASE"),
@@ -10163,6 +10176,8 @@ impl fmt::Display for ActionCreateObjectType {
1016310176
ActionCreateObjectType::Schema => write!(f, "SCHEMA"),
1016410177
ActionCreateObjectType::Share => write!(f, "SHARE"),
1016510178
ActionCreateObjectType::Table => write!(f, "TABLE"),
10179+
ActionCreateObjectType::Task => write!(f, "TASK"),
10180+
ActionCreateObjectType::View => write!(f, "VIEW"),
1016610181
ActionCreateObjectType::User => write!(f, "USER"),
1016710182
ActionCreateObjectType::Warehouse => write!(f, "WAREHOUSE"),
1016810183
}

src/keywords.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ define_keywords!(
107107
ADMIN_PASSWORD,
108108
AFTER,
109109
AGAINST,
110+
AGENT,
110111
AGGREGATE,
111112
AGGREGATION,
112113
ALERT,
@@ -672,6 +673,7 @@ define_keywords!(
672673
MAX_DATA_EXTENSION_TIME_IN_DAYS,
673674
MAX_ROWS,
674675
MB,
676+
MCP,
675677
MEASURES,
676678
MEDIUMBLOB,
677679
MEDIUMINT,

src/parser/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19148,6 +19148,7 @@ impl<'a> Parser<'a> {
1914819148
("AGENTS", &["AGENTS"], "CORTEX_AGENT"),
1914919149
("MCP SERVERS", &["MCP", "SERVERS"], "CORTEX_AGENT_SERVER"),
1915019150
("SEMANTIC VIEWS", &["SEMANTIC", "VIEWS"], "SEMANTIC_VIEW"),
19151+
("TASKS", &["TASKS"], "TASK"),
1915119152
];
1915219153

1915319154
/// `ON {ALL|FUTURE} <plural-kind> IN {SCHEMA|DATABASE} <name>[, …]` for the
@@ -19378,6 +19379,8 @@ impl<'a> Parser<'a> {
1937819379
Some(ActionCreateObjectType::ApplicationPackage)
1937919380
} else if self.parse_keywords(&[Keyword::COMPUTE, Keyword::POOL]) {
1938019381
Some(ActionCreateObjectType::ComputePool)
19382+
} else if self.parse_keywords(&[Keyword::MCP, Keyword::SERVER]) {
19383+
Some(ActionCreateObjectType::McpServer)
1938119384
} else if self.parse_keywords(&[Keyword::DATA, Keyword::EXCHANGE, Keyword::LISTING]) {
1938219385
Some(ActionCreateObjectType::DataExchangeListing)
1938319386
} else if self.parse_keywords(&[Keyword::EXTERNAL, Keyword::VOLUME]) {
@@ -19396,6 +19399,10 @@ impl<'a> Parser<'a> {
1939619399
// Single-word object types
1939719400
else if self.parse_keyword(Keyword::ACCOUNT) {
1939819401
Some(ActionCreateObjectType::Account)
19402+
} else if self.parse_keyword(Keyword::AGENT) {
19403+
Some(ActionCreateObjectType::Agent)
19404+
} else if self.parse_keyword(Keyword::ALERT) {
19405+
Some(ActionCreateObjectType::Alert)
1939919406
} else if self.parse_keyword(Keyword::APPLICATION) {
1940019407
Some(ActionCreateObjectType::Application)
1940119408
} else if self.parse_keyword(Keyword::DATABASE) {
@@ -19414,6 +19421,10 @@ impl<'a> Parser<'a> {
1941419421
Some(ActionCreateObjectType::Share)
1941519422
} else if self.parse_keyword(Keyword::TABLE) {
1941619423
Some(ActionCreateObjectType::Table)
19424+
} else if self.parse_keyword(Keyword::TASK) {
19425+
Some(ActionCreateObjectType::Task)
19426+
} else if self.parse_keyword(Keyword::VIEW) {
19427+
Some(ActionCreateObjectType::View)
1941719428
} else if self.parse_keyword(Keyword::USER) {
1941819429
Some(ActionCreateObjectType::User)
1941919430
} else if self.parse_keyword(Keyword::WAREHOUSE) {

0 commit comments

Comments
 (0)