iffyio commented on code in PR #2029: URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2029#discussion_r2379444720
########## tests/sqlparser_common.rs: ########## @@ -17246,3 +17246,46 @@ fn parse_invisible_column() { _ => panic!("Unexpected statement {stmt}"), } } + +#[test] +fn parse_create_index_different_using_positions() { + let sql = "CREATE INDEX idx_name USING BTREE ON table_name (col1)"; + let expected = "CREATE INDEX idx_name ON table_name USING BTREE (col1)"; + match all_dialects().one_statement_parses_to(sql, expected) { + Statement::CreateIndex(CreateIndex { + name, + table_name, + using, + columns, + unique, + .. + }) => { + assert_eq!(name.unwrap().to_string(), "idx_name"); + assert_eq!(table_name.to_string(), "table_name"); + assert_eq!(using, Some(IndexType::BTree)); + assert_eq!(columns.len(), 1); + assert!(!unique); + } + _ => unreachable!(), + } + + let sql = "CREATE INDEX idx_name USING BTREE ON table_name (col1) USING HASH"; + let expected = "CREATE INDEX idx_name ON table_name(col1) USING HASH"; Review Comment: hmm what's confusing do you mean with the first clause going into the `using` field and the second clause going into the `index_options` field? It feels like it'd be unusual for the parser to swallow some of its input, and in general we avoid mimicking server behavior in the parser, so its currently unclear to me what the rationale is -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org