mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-22 15:04:04 +00:00
Support specifying ASC/DESC in index columns (#249)
...by reusing `OrderByExpr` for `columns` in `Statement::CreateIndex`. This supports SQLite's indexed-column syntax https://www.sqlite.org/syntax/indexed-column.html MSSQL's (`ON <object> ( column [ ASC | DESC ] [ ,...n ] )`) https://docs.microsoft.com/en-us/sql/t-sql/statements/create-index-transact-sql?view=sql-server-ver15 And most of PostgreSQL syntax (except for opclass): `( { column_name | ( expression ) } [ COLLATE collation ] [ opclass ] [ ASC | DESC ] [ NULLS { FIRST | LAST } ] [, ...] )` https://www.postgresql.org/docs/12/sql-createindex.html
This commit is contained in:
parent
9e7e30282e
commit
4452f9bad1
3 changed files with 18 additions and 5 deletions
|
@ -1142,7 +1142,9 @@ impl Parser {
|
|||
let index_name = self.parse_object_name()?;
|
||||
self.expect_keyword(Keyword::ON)?;
|
||||
let table_name = self.parse_object_name()?;
|
||||
let columns = self.parse_parenthesized_column_list(Mandatory)?;
|
||||
self.expect_token(&Token::LParen)?;
|
||||
let columns = self.parse_comma_separated(Parser::parse_order_by_expr)?;
|
||||
self.expect_token(&Token::RParen)?;
|
||||
Ok(Statement::CreateIndex {
|
||||
name: index_name,
|
||||
table_name,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue