Skip to content

Commit 2516ad4

Browse files
committed
Syntax for PARTITIONED INDEX (CubeStore extension)
1 parent 4be9bcc commit 2516ad4

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

src/ast/mod.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2555,6 +2555,12 @@ pub enum Statement {
25552555
/// `CREATE INDEX`
25562556
/// ```
25572557
CreateIndex(CreateIndex),
2558+
// Cubestore extension.
2559+
CreatePartitionedIndex {
2560+
name: ObjectName,
2561+
columns: Vec<ColumnDef>,
2562+
if_not_exists: bool,
2563+
},
25582564
/// ```sql
25592565
/// CREATE ROLE
25602566
/// ```
@@ -5064,6 +5070,19 @@ impl fmt::Display for Statement {
50645070
}
50655071
Ok(())
50665072
}
5073+
Statement::CreatePartitionedIndex {
5074+
name,
5075+
columns,
5076+
if_not_exists,
5077+
} => {
5078+
write!(
5079+
f,
5080+
"CREATE PARTITIONED INDEX{} {}({})",
5081+
if *if_not_exists { " IF NOT EXISTS" } else { "" },
5082+
name,
5083+
display_comma_separated(&columns)
5084+
)
5085+
}
50675086
Statement::LISTEN { channel } => {
50685087
write!(f, "LISTEN {channel}")?;
50695088
Ok(())

src/ast/spans.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,12 @@ impl Spanned for Statement {
395395
.chain(module_args.iter().map(|i| i.span)),
396396
),
397397
Statement::CreateIndex(create_index) => create_index.span(),
398+
// Cubestore extension.
399+
Statement::CreatePartitionedIndex {
400+
name: _,
401+
columns: _,
402+
if_not_exists: _,
403+
} => Span::empty(), // Not implemented -- maybe if_not_exists being a naked bool is an issue.
398404
Statement::CreateRole { .. } => Span::empty(),
399405
Statement::CreateSecret { .. } => Span::empty(),
400406
Statement::AlterTable {

src/parser/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4209,6 +4209,8 @@ impl<'a> Parser<'a> {
42094209
self.parse_create_virtual_table()
42104210
} else if self.parse_keyword(Keyword::SCHEMA) {
42114211
self.parse_create_schema()
4212+
} else if self.parse_keywords(&[Keyword::PARTITIONED, Keyword::INDEX]) {
4213+
self.parse_create_partitioned_index()
42124214
} else if self.parse_keyword(Keyword::DATABASE) {
42134215
self.parse_create_database()
42144216
} else if self.parse_keyword(Keyword::ROLE) {
@@ -6130,6 +6132,19 @@ impl<'a> Parser<'a> {
61306132
Ok(Statement::Discard { object_type })
61316133
}
61326134

6135+
pub fn parse_create_partitioned_index(&mut self) -> Result<Statement, ParserError> {
6136+
let if_not_exists = self.parse_keywords(&[Keyword::IF, Keyword::NOT, Keyword::EXISTS]);
6137+
let name = self.parse_object_name(false)?;
6138+
self.expect_token(&Token::LParen)?;
6139+
let columns = self.parse_comma_separated(Parser::parse_column_def)?;
6140+
self.expect_token(&Token::RParen)?;
6141+
Ok(Statement::CreatePartitionedIndex {
6142+
name,
6143+
columns,
6144+
if_not_exists,
6145+
})
6146+
}
6147+
61336148
pub fn parse_create_index(&mut self, unique: bool) -> Result<Statement, ParserError> {
61346149
let concurrently = self.parse_keyword(Keyword::CONCURRENTLY);
61356150
let if_not_exists = self.parse_keywords(&[Keyword::IF, Keyword::NOT, Keyword::EXISTS]);

0 commit comments

Comments
 (0)