Skip to content

Commit 20f751b

Browse files
committed
Syntax for PARTITIONED INDEX (CubeStore extension)
1 parent 11a6e6f commit 20f751b

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/ast/mod.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2169,6 +2169,12 @@ pub enum Statement {
21692169
/// `CREATE INDEX`
21702170
/// ```
21712171
CreateIndex(CreateIndex),
2172+
// Cubestore extension.
2173+
CreatePartitionedIndex {
2174+
name: ObjectName,
2175+
columns: Vec<ColumnDef>,
2176+
if_not_exists: bool,
2177+
},
21722178
/// ```sql
21732179
/// CREATE ROLE
21742180
/// ```
@@ -4529,6 +4535,19 @@ impl fmt::Display for Statement {
45294535
}
45304536
Ok(())
45314537
}
4538+
Statement::CreatePartitionedIndex {
4539+
name,
4540+
columns,
4541+
if_not_exists,
4542+
} => {
4543+
write!(
4544+
f,
4545+
"CREATE PARTITIONED INDEX{} {}({})",
4546+
if *if_not_exists { " IF NOT EXISTS" } else { "" },
4547+
name,
4548+
display_comma_separated(&columns)
4549+
)
4550+
}
45324551
}
45334552
}
45344553
}

src/parser/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3554,6 +3554,8 @@ impl<'a> Parser<'a> {
35543554
self.parse_create_virtual_table()
35553555
} else if self.parse_keyword(Keyword::SCHEMA) {
35563556
self.parse_create_schema()
3557+
} else if self.parse_keywords(&[Keyword::PARTITIONED, Keyword::INDEX]) {
3558+
self.parse_create_partitioned_index()
35573559
} else if self.parse_keyword(Keyword::DATABASE) {
35583560
self.parse_create_database()
35593561
} else if self.parse_keyword(Keyword::ROLE) {
@@ -5288,6 +5290,19 @@ impl<'a> Parser<'a> {
52885290
Ok(Statement::Discard { object_type })
52895291
}
52905292

5293+
pub fn parse_create_partitioned_index(&mut self) -> Result<Statement, ParserError> {
5294+
let if_not_exists = self.parse_keywords(&[Keyword::IF, Keyword::NOT, Keyword::EXISTS]);
5295+
let name = self.parse_object_name(false)?;
5296+
self.expect_token(&Token::LParen)?;
5297+
let columns = self.parse_comma_separated(Parser::parse_column_def)?;
5298+
self.expect_token(&Token::RParen)?;
5299+
Ok(Statement::CreatePartitionedIndex {
5300+
name,
5301+
columns,
5302+
if_not_exists,
5303+
})
5304+
}
5305+
52915306
pub fn parse_create_index(&mut self, unique: bool) -> Result<Statement, ParserError> {
52925307
let concurrently = self.parse_keyword(Keyword::CONCURRENTLY);
52935308
let if_not_exists = self.parse_keywords(&[Keyword::IF, Keyword::NOT, Keyword::EXISTS]);

0 commit comments

Comments
 (0)