You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by lu...@apache.org on 2026/09/19 05:42:30 UTC

(datafusion-sqlparser-rs) branch fuzz-roundtrip-harness updated (d89e7e95 -> 939f0067)

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

LucaCappelletti94 pushed a change to branch fuzz-roundtrip-harness
in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git


 discard d89e7e95 Fuzz: Add parse -> Display -> re-parse roundtrip harness
     new 939f0067 Fuzz: Add parse -> Display -> re-parse roundtrip harness

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (d89e7e95)
            \
             N -- N -- N   refs/heads/fuzz-roundtrip-harness (939f0067)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 fuzz/fuzz_targets/fuzz_parse_roundtrip.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


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


(datafusion-sqlparser-rs) 01/01: Fuzz: Add parse -> Display -> re-parse roundtrip harness

Posted by lu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

LucaCappelletti94 pushed a commit to branch fuzz-roundtrip-harness
in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git

commit 939f0067b88421f152774effea196ba8821bc848
Author: LucaCappelletti94 <ca...@gmail.com>
AuthorDate: Fri Sep 18 22:40:45 2026 +0200

    Fuzz: Add parse -> Display -> re-parse roundtrip harness
---
 docs/fuzzing.md                           |  4 +++
 fuzz/Cargo.toml                           |  7 ++++
 fuzz/fuzz_targets/fuzz_parse_roundtrip.rs | 59 +++++++++++++++++++++++++++++++
 3 files changed, 70 insertions(+)

diff --git a/docs/fuzzing.md b/docs/fuzzing.md
index 3d165510..5028f3eb 100644
--- a/docs/fuzzing.md
+++ b/docs/fuzzing.md
@@ -27,6 +27,10 @@ cd fuzz
 cargo +nightly fuzz run fuzz_parse_sql -- -max_total_time=600
 ```
 
+There are two targets. `fuzz_parse_sql` parses the input with every dialect.
+`fuzz_parse_roundtrip` additionally re-parses the SQL rendered by `Display` and fails when a
+rendered statement no longer parses.
+
 ClusterFuzzLite runs continuous fuzzing. Every pull request fuzzes for 10 minutes in
 `code-change` mode, a daily batch job grows the shared corpus stored on the
 `clusterfuzzlite` branch, and a daily prune compacts it.
diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml
index 4ee8c504..ed69281a 100644
--- a/fuzz/Cargo.toml
+++ b/fuzz/Cargo.toml
@@ -38,3 +38,10 @@ path = "fuzz_targets/fuzz_parse_sql.rs"
 test = false
 doc = false
 bench = false
+
+[[bin]]
+name = "fuzz_parse_roundtrip"
+path = "fuzz_targets/fuzz_parse_roundtrip.rs"
+test = false
+doc = false
+bench = false
diff --git a/fuzz/fuzz_targets/fuzz_parse_roundtrip.rs b/fuzz/fuzz_targets/fuzz_parse_roundtrip.rs
new file mode 100644
index 00000000..3488eb08
--- /dev/null
+++ b/fuzz/fuzz_targets/fuzz_parse_roundtrip.rs
@@ -0,0 +1,59 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#![no_main]
+
+use libfuzzer_sys::fuzz_target;
+use sqlparser::dialect::{
+    AnsiDialect, BigQueryDialect, ClickHouseDialect, DatabricksDialect, Dialect, DuckDbDialect,
+    GenericDialect, HiveDialect, MsSqlDialect, MySqlDialect, OracleDialect, PostgreSqlDialect,
+    RedshiftSqlDialect, SQLiteDialect, SnowflakeDialect,
+};
+use sqlparser::parser::Parser;
+
+fuzz_target!(|sql: &str| {
+    let dialects: [(&str, &dyn Dialect); 14] = [
+        ("ansi", &AnsiDialect {}),
+        ("bigquery", &BigQueryDialect {}),
+        ("clickhouse", &ClickHouseDialect {}),
+        ("databricks", &DatabricksDialect {}),
+        ("duckdb", &DuckDbDialect {}),
+        ("generic", &GenericDialect {}),
+        ("hive", &HiveDialect {}),
+        ("mssql", &MsSqlDialect {}),
+        ("mysql", &MySqlDialect {}),
+        ("oracle", &OracleDialect {}),
+        ("postgres", &PostgreSqlDialect {}),
+        ("redshift", &RedshiftSqlDialect {}),
+        ("sqlite", &SQLiteDialect {}),
+        ("snowflake", &SnowflakeDialect {}),
+    ];
+    for (name, dialect) in dialects {
+        let Ok(statements) = Parser::parse_sql(dialect, sql) else {
+            continue;
+        };
+        for statement in &statements {
+            let rendered = statement.to_string();
+            // SQL the AST renders must parse back. A failure is a Display bug
+            if let Err(err) = Parser::parse_sql(dialect, &rendered) {
+                panic!(
+                    "{name}: displayed SQL failed to re-parse\n  display: {rendered}\n  error: {err}"
+                );
+            }
+        }
+    }
+});


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