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/18 20:40:55 UTC
(datafusion-sqlparser-rs) branch fuzz-roundtrip-harness created (now d89e7e95)
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
at d89e7e95 Fuzz: Add parse -> Display -> re-parse roundtrip harness
This branch includes the following new commits:
new d89e7e95 Fuzz: Add parse -> Display -> re-parse roundtrip harness
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.
---------------------------------------------------------------------
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 d89e7e954ccb3f5b0a671a796e321fa96c59eae4
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..95cb3d65
--- /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