mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-31 03:07:20 +00:00
Adding MySQL table option {INDEX | KEY} to the CREATE TABLE definiton (partial). (#665)
Theoretically the behavior should be the same as CREATE INDEX, but we cannot make that assumption, so the parse is (almost) identical as the input. Breaking changes: - Now HASH and BTREE are KEYWORDS, and using them as names can result in errors. - Now 'KEY' and 'INDEX' column names start the parsing of a table constraint if unquoted for the Generic dialect. This results in possible conficts if canonical results are compared for all dialects if a column is named 'key' without quotes.
This commit is contained in:
parent
e3c936a6ce
commit
2aba3f8c91
6 changed files with 242 additions and 5 deletions
|
@ -2089,10 +2089,10 @@ fn parse_create_table_hive_array() {
|
|||
let dialects = TestedDialects {
|
||||
dialects: vec![Box::new(PostgreSqlDialect {}), Box::new(HiveDialect {})],
|
||||
};
|
||||
let sql = "CREATE TABLE IF NOT EXISTS something (key int, val array<int>)";
|
||||
let sql = "CREATE TABLE IF NOT EXISTS something (name int, val array<int>)";
|
||||
match dialects.one_statement_parses_to(
|
||||
sql,
|
||||
"CREATE TABLE IF NOT EXISTS something (key INT, val INT[])",
|
||||
"CREATE TABLE IF NOT EXISTS something (name INT, val INT[])",
|
||||
) {
|
||||
Statement::CreateTable {
|
||||
if_not_exists,
|
||||
|
@ -2106,7 +2106,7 @@ fn parse_create_table_hive_array() {
|
|||
columns,
|
||||
vec![
|
||||
ColumnDef {
|
||||
name: Ident::new("key"),
|
||||
name: Ident::new("name"),
|
||||
data_type: DataType::Int(None),
|
||||
collation: None,
|
||||
options: vec![],
|
||||
|
@ -2123,7 +2123,8 @@ fn parse_create_table_hive_array() {
|
|||
_ => unreachable!(),
|
||||
}
|
||||
|
||||
let res = parse_sql_statements("CREATE TABLE IF NOT EXISTS something (key int, val array<int)");
|
||||
let res =
|
||||
parse_sql_statements("CREATE TABLE IF NOT EXISTS something (name int, val array<int)");
|
||||
assert!(res
|
||||
.unwrap_err()
|
||||
.to_string()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue