Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,12 @@ pub enum Statement {
unique: bool,
if_not_exists: bool,
},
// CubeStore extension.
CreatePartitionedIndex {
name: ObjectName,
columns: Vec<ColumnDef>,
if_not_exists: bool,
},
/// ALTER TABLE
AlterTable {
/// Table name
Expand Down Expand Up @@ -1276,6 +1282,19 @@ impl fmt::Display for Statement {
}
write!(f, "AS {}", statement)
}
Statement::CreatePartitionedIndex {
name,
columns,
if_not_exists,
} => {
write!(
f,
"CREATE PARTITIONED INDEX{} {}({})",
if *if_not_exists { " IF NOT EXISTS" } else { "" },
name,
display_comma_separated(&columns)
)
}
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1267,6 +1267,8 @@ impl<'a> Parser<'a> {
self.parse_create_virtual_table()
} else if self.parse_keyword(Keyword::SCHEMA) {
self.parse_create_schema()
} else if self.parse_keywords(&[Keyword::PARTITIONED, Keyword::INDEX]) {
self.parse_create_partitioned_index()
} else {
self.expected("an object type after CREATE", self.peek_token())
}
Expand Down Expand Up @@ -1433,6 +1435,19 @@ impl<'a> Parser<'a> {
})
}

pub fn parse_create_partitioned_index(&mut self) -> Result<Statement, ParserError> {
let if_not_exists = self.parse_keywords(&[Keyword::IF, Keyword::NOT, Keyword::EXISTS]);
let name = self.parse_object_name()?;
self.expect_token(&Token::LParen)?;
let columns = self.parse_comma_separated(Parser::parse_column_def)?;
self.expect_token(&Token::RParen)?;
Ok(Statement::CreatePartitionedIndex {
name,
columns,
if_not_exists,
})
}

pub fn parse_create_index(&mut self, unique: bool) -> Result<Statement, ParserError> {
let if_not_exists = self.parse_keywords(&[Keyword::IF, Keyword::NOT, Keyword::EXISTS]);
let index_name = self.parse_object_name()?;
Expand Down