Skip to content

Commit e6e90af

Browse files
committed
Syntax for PARTITIONED INDEX (CubeStore extension)
1 parent e436338 commit e6e90af

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/ast/mod.rs

+19
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,12 @@ pub enum Statement {
651651
unique: bool,
652652
if_not_exists: bool,
653653
},
654+
// CubeStore extension.
655+
CreatePartitionedIndex {
656+
name: ObjectName,
657+
columns: Vec<ColumnDef>,
658+
if_not_exists: bool,
659+
},
654660
/// ALTER TABLE
655661
AlterTable {
656662
/// Table name
@@ -1276,6 +1282,19 @@ impl fmt::Display for Statement {
12761282
}
12771283
write!(f, "AS {}", statement)
12781284
}
1285+
Statement::CreatePartitionedIndex {
1286+
name,
1287+
columns,
1288+
if_not_exists,
1289+
} => {
1290+
write!(
1291+
f,
1292+
"CREATE PARTITIONED INDEX{} {}({})",
1293+
if *if_not_exists { " IF NOT EXISTS" } else { "" },
1294+
name,
1295+
display_comma_separated(&columns)
1296+
)
1297+
}
12791298
}
12801299
}
12811300
}

src/parser.rs

+15
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,8 @@ impl<'a> Parser<'a> {
12671267
self.parse_create_virtual_table()
12681268
} else if self.parse_keyword(Keyword::SCHEMA) {
12691269
self.parse_create_schema()
1270+
} else if self.parse_keywords(&[Keyword::PARTITIONED, Keyword::INDEX]) {
1271+
self.parse_create_partitioned_index()
12701272
} else {
12711273
self.expected("an object type after CREATE", self.peek_token())
12721274
}
@@ -1433,6 +1435,19 @@ impl<'a> Parser<'a> {
14331435
})
14341436
}
14351437

1438+
pub fn parse_create_partitioned_index(&mut self) -> Result<Statement, ParserError> {
1439+
let if_not_exists = self.parse_keywords(&[Keyword::IF, Keyword::NOT, Keyword::EXISTS]);
1440+
let name = self.parse_object_name()?;
1441+
self.expect_token(&Token::LParen)?;
1442+
let columns = self.parse_comma_separated(Parser::parse_column_def)?;
1443+
self.expect_token(&Token::RParen)?;
1444+
Ok(Statement::CreatePartitionedIndex {
1445+
name,
1446+
columns,
1447+
if_not_exists,
1448+
})
1449+
}
1450+
14361451
pub fn parse_create_index(&mut self, unique: bool) -> Result<Statement, ParserError> {
14371452
let if_not_exists = self.parse_keywords(&[Keyword::IF, Keyword::NOT, Keyword::EXISTS]);
14381453
let index_name = self.parse_object_name()?;

0 commit comments

Comments
 (0)