7phs commented on code in PR #1454: URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1454#discussion_r1793352226
########## tests/sqlparser_snowflake.rs: ########## @@ -525,6 +525,307 @@ fn test_snowflake_single_line_tokenize() { assert_eq!(expected, tokens); } +#[test] +fn test_snowflake_create_table_with_autoincrement_columns() { + let sql = concat!( + "CREATE TABLE my_table (", + "a INT AUTOINCREMENT ORDER, ", + "b INT AUTOINCREMENT(100, 1) NOORDER, ", + "c INT IDENTITY, ", + "d INT IDENTITY START 100 INCREMENT 1 ORDER", + ")" + ); + // it is a snowflake specific options (AUTOINCREMENT/IDENTITY) + match snowflake().verified_stmt(sql) { + Statement::CreateTable(CreateTable { columns, .. }) => { + assert_eq!( + columns, + vec![ + ColumnDef { + name: "a".into(), + data_type: DataType::Int(None), + collation: None, + options: vec![ColumnOptionDef { + name: None, + option: ColumnOption::Identity(Identity::Autoincrement( + IdentityProperty { + parameters: None, + order: Some(IdentityOrder::Order), + } + )) + }] + }, + ColumnDef { + name: "b".into(), + data_type: DataType::Int(None), + collation: None, + options: vec![ColumnOptionDef { + name: None, + option: ColumnOption::Identity(Identity::Autoincrement( + IdentityProperty { + #[cfg(not(feature = "bigdecimal"))] + parameters: Some(IdentityFormat::FunctionCall( + IdentityParameters { + seed: Expr::Value(Value::Number( + "100".to_string(), + false + )), + increment: Expr::Value(Value::Number( + "1".to_string(), + false + )), + } + )), + #[cfg(feature = "bigdecimal")] + parameters: Some(IdentityFormat::FunctionCall( + IdentityParameters { + seed: Expr::Value(Value::Number( + bigdecimal::BigDecimal::from(100), + false, + )), + increment: Expr::Value(Value::Number( + bigdecimal::BigDecimal::from(1), + false, + )), + } + )), + order: Some(IdentityOrder::Noorder), + } + )) + }] + }, + ColumnDef { + name: "c".into(), + data_type: DataType::Int(None), + collation: None, + options: vec![ColumnOptionDef { + name: None, + option: ColumnOption::Identity(Identity::Identity(IdentityProperty { + parameters: None, + order: None, + })) + }] + }, + ColumnDef { + name: "d".into(), + data_type: DataType::Int(None), + collation: None, + options: vec![ColumnOptionDef { + name: None, + option: ColumnOption::Identity(Identity::Identity(IdentityProperty { + #[cfg(not(feature = "bigdecimal"))] Review Comment: Applied for tests of `snowflake` and `ms sql` -- 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: dev-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@datafusion.apache.org For additional commands, e-mail: dev-h...@datafusion.apache.org