Support the ARRAY type of Snowflake (#699)

* Snowflake Array

* Use the array data type

* Try to fix build

* Try to fix build

* Change Array to option

* Remove unused import
This commit is contained in:
yuval-illumex 2022-11-04 16:25:25 +02:00 committed by GitHub
parent bbf32a9e81
commit 0f7e144890
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 52 additions and 21 deletions

View file

@ -24,7 +24,7 @@ use sqlparser::ast::SelectItem::UnnamedExpr;
use sqlparser::ast::*;
use sqlparser::dialect::{
AnsiDialect, BigQueryDialect, ClickHouseDialect, GenericDialect, HiveDialect, MsSqlDialect,
PostgreSqlDialect, SQLiteDialect, SnowflakeDialect,
MySqlDialect, PostgreSqlDialect, SQLiteDialect, SnowflakeDialect,
};
use sqlparser::keywords::ALL_KEYWORDS;
use sqlparser::parser::{Parser, ParserError};
@ -2099,7 +2099,7 @@ fn parse_create_table_hive_array() {
},
ColumnDef {
name: Ident::new("val"),
data_type: DataType::Array(Box::new(DataType::Int(None))),
data_type: DataType::Array(Some(Box::new(DataType::Int(None)))),
collation: None,
options: vec![],
},
@ -2109,12 +2109,20 @@ fn parse_create_table_hive_array() {
_ => unreachable!(),
}
let res =
parse_sql_statements("CREATE TABLE IF NOT EXISTS something (name int, val array<int)");
assert!(res
.unwrap_err()
.to_string()
.contains("Expected >, found: )"));
// SnowflakeDialect using array diffrent
let dialects = TestedDialects {
dialects: vec![
Box::new(PostgreSqlDialect {}),
Box::new(HiveDialect {}),
Box::new(MySqlDialect {}),
],
};
let sql = "CREATE TABLE IF NOT EXISTS something (name int, val array<int)";
assert_eq!(
dialects.parse_sql_statements(sql).unwrap_err(),
ParserError::ParserError("Expected >, found: )".to_string())
);
}
#[test]