This is an automated email from the ASF dual-hosted git repository.

iffyio pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git


The following commit(s) were added to refs/heads/main by this push:
     new 40d12b98 Add support for `CREATE SCHEMA WITH ( <properties> )` (#1877)
40d12b98 is described below

commit 40d12b98bd195eecf8f1b89dcfd9d163c96fd0af
Author: Yannick Utard <[email protected]>
AuthorDate: Tue Jun 10 06:50:10 2025 +0200

    Add support for `CREATE SCHEMA WITH ( <properties> )` (#1877)
---
 src/ast/mod.rs            | 13 +++++++++++++
 src/parser/mod.rs         |  7 +++++++
 tests/sqlparser_common.rs |  3 +++
 3 files changed, 23 insertions(+)

diff --git a/src/ast/mod.rs b/src/ast/mod.rs
index 6f47ae7f..a1d8ff6f 100644
--- a/src/ast/mod.rs
+++ b/src/ast/mod.rs
@@ -3725,6 +3725,14 @@ pub enum Statement {
         /// `<schema name> | AUTHORIZATION <schema authorization identifier>  
| <schema name>  AUTHORIZATION <schema authorization identifier>`
         schema_name: SchemaName,
         if_not_exists: bool,
+        /// Schema properties.
+        ///
+        /// ```sql
+        /// CREATE SCHEMA myschema WITH (key1='value1');
+        /// ```
+        ///
+        /// [Trino](https://trino.io/docs/current/sql/create-schema.html)
+        with: Option<Vec<SqlOption>>,
         /// Schema options.
         ///
         /// ```sql
@@ -5585,6 +5593,7 @@ impl fmt::Display for Statement {
             Statement::CreateSchema {
                 schema_name,
                 if_not_exists,
+                with,
                 options,
                 default_collate_spec,
             } => {
@@ -5599,6 +5608,10 @@ impl fmt::Display for Statement {
                     write!(f, " DEFAULT COLLATE {collate}")?;
                 }
 
+                if let Some(with) = with {
+                    write!(f, " WITH ({})", display_comma_separated(with))?;
+                }
+
                 if let Some(options) = options {
                     write!(f, " OPTIONS({})", 
display_comma_separated(options))?;
                 }
diff --git a/src/parser/mod.rs b/src/parser/mod.rs
index 9cef22ed..b582e793 100644
--- a/src/parser/mod.rs
+++ b/src/parser/mod.rs
@@ -4862,6 +4862,12 @@ impl<'a> Parser<'a> {
             None
         };
 
+        let with = if self.peek_keyword(Keyword::WITH) {
+            Some(self.parse_options(Keyword::WITH)?)
+        } else {
+            None
+        };
+
         let options = if self.peek_keyword(Keyword::OPTIONS) {
             Some(self.parse_options(Keyword::OPTIONS)?)
         } else {
@@ -4871,6 +4877,7 @@ impl<'a> Parser<'a> {
         Ok(Statement::CreateSchema {
             schema_name,
             if_not_exists,
+            with,
             options,
             default_collate_spec,
         })
diff --git a/tests/sqlparser_common.rs b/tests/sqlparser_common.rs
index 399fdb3d..abcadb45 100644
--- a/tests/sqlparser_common.rs
+++ b/tests/sqlparser_common.rs
@@ -4268,6 +4268,9 @@ fn parse_create_schema() {
     verified_stmt(r#"CREATE SCHEMA IF NOT EXISTS a OPTIONS(key1 = 'value1')"#);
     verified_stmt(r#"CREATE SCHEMA IF NOT EXISTS a OPTIONS()"#);
     verified_stmt(r#"CREATE SCHEMA IF NOT EXISTS a DEFAULT COLLATE 'und:ci' 
OPTIONS()"#);
+    verified_stmt(r#"CREATE SCHEMA a.b.c WITH (key1 = 'value1', key2 = 
'value2')"#);
+    verified_stmt(r#"CREATE SCHEMA IF NOT EXISTS a WITH (key1 = 'value1')"#);
+    verified_stmt(r#"CREATE SCHEMA IF NOT EXISTS a WITH ()"#);
 }
 
 #[test]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to