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 35835146 MySQL: Support comma-separated `CREATE TABLE` options (#1989)
35835146 is described below

commit 35835146020f0f4782fd4e5caf05aa8b7e17e7b6
Author: Michael Victor Zink <michae...@readyset.io>
AuthorDate: Tue Aug 5 01:30:42 2025 -0700

    MySQL: Support comma-separated `CREATE TABLE` options (#1989)
---
 src/dialect/mod.rs       | 2 +-
 src/parser/mod.rs        | 3 +++
 tests/sqlparser_mysql.rs | 7 +++++++
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/dialect/mod.rs b/src/dialect/mod.rs
index 5f333a93..6ca36478 100644
--- a/src/dialect/mod.rs
+++ b/src/dialect/mod.rs
@@ -590,7 +590,7 @@ pub trait Dialect: Debug + Any {
         false
     }
 
-    /// Returne true if the dialect supports specifying multiple options
+    /// Return true if the dialect supports specifying multiple options
     /// in a `CREATE TABLE` statement for the structure of the new table. For 
example:
     /// `CREATE TABLE t (a INT, b INT) AS SELECT 1 AS b, 2 AS a`
     fn supports_create_table_multi_schema_info_sources(&self) -> bool {
diff --git a/src/parser/mod.rs b/src/parser/mod.rs
index c3230a21..39571ba1 100644
--- a/src/parser/mod.rs
+++ b/src/parser/mod.rs
@@ -7708,6 +7708,9 @@ impl<'a> Parser<'a> {
 
         while let Some(option) = self.parse_plain_option()? {
             options.push(option);
+            // Some dialects support comma-separated options; it shouldn't 
introduce ambiguity to
+            // consume it for all dialects.
+            let _ = self.consume_token(&Token::Comma);
         }
 
         Ok(options)
diff --git a/tests/sqlparser_mysql.rs b/tests/sqlparser_mysql.rs
index 3ea0543f..cf4e24ad 100644
--- a/tests/sqlparser_mysql.rs
+++ b/tests/sqlparser_mysql.rs
@@ -1361,6 +1361,13 @@ fn parse_create_table_gencol() {
     mysql_and_generic().verified_stmt("CREATE TABLE t1 (a INT, b INT AS (a * 
2) STORED)");
 }
 
+#[test]
+fn parse_create_table_options_comma_separated() {
+    let sql = "CREATE TABLE t (x INT) DEFAULT CHARSET = utf8mb4, ENGINE = 
InnoDB , AUTO_INCREMENT 1 DATA DIRECTORY '/var/lib/mysql/data'";
+    let canonical = "CREATE TABLE t (x INT) DEFAULT CHARSET = utf8mb4 ENGINE = 
InnoDB AUTO_INCREMENT = 1 DATA DIRECTORY = '/var/lib/mysql/data'";
+    mysql_and_generic().one_statement_parses_to(sql, canonical);
+}
+
 #[test]
 fn parse_quote_identifiers() {
     let sql = "CREATE TABLE `PRIMARY` (`BEGIN` INT PRIMARY KEY)";


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@datafusion.apache.org
For additional commands, e-mail: commits-h...@datafusion.apache.org

Reply via email to