MohamedAbdeen21 commented on code in PR #2029:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/2029#discussion_r2379337635
##########
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:
We can, but it's just super confusing because there is the `USING` field and
another IndexOption::IndexType in the `index_options` field.
The point here is to mimic mysql behaviour of only keeping the second, not
preserve the input.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]