7phs commented on code in PR #1454:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/1454#discussion_r1793354187
##########
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"))]
+ parameters:
Some(IdentityFormat::StartAndIncrement(
+ 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::StartAndIncrement(
+ IdentityParameters {
+ seed: Expr::Value(Value::Number(
+ bigdecimal::BigDecimal::from(100),
+ false,
+ )),
+ increment: Expr::Value(Value::Number(
+ bigdecimal::BigDecimal::from(1),
+ false,
+ )),
+ }
+ )),
+ order: Some(IdentityOrder::Order),
+ }))
+ }]
+ },
+ ]
+ );
+ }
+ _ => unreachable!(),
+ }
+}
+
+#[test]
+fn test_snowflake_create_table_with_collated_column() {
Review Comment:
I updated all existing tests with two variants of tested SQL - without and
with `WITH`.
Additionally I added one more test with several column options in SQL to
make sure that all these options are parsed together.
--
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]