Skip to content

Commit

Permalink
feat(sqlsmith): fuzz test support read Sqlite and Duckdb test (#17301)
Browse files Browse the repository at this point in the history
  • Loading branch information
b41sh authored Jan 18, 2025
1 parent 248ec52 commit 3a32c18
Show file tree
Hide file tree
Showing 9 changed files with 361 additions and 215 deletions.
22 changes: 2 additions & 20 deletions src/query/ast/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1088,32 +1088,15 @@ pub fn expr_element(i: Input) -> IResult<WithSpan<ExprElement>> {
#function_name
~ "(" ~ #comma_separated_list1(subexpr(0)) ~ ")"
~ "(" ~ DISTINCT? ~ #comma_separated_list0(subexpr(0))? ~ ")"
~ #window_function
~ #window_function?
},
|(name, _, params, _, _, opt_distinct, opt_args, _, window)| ExprElement::FunctionCall {
func: FunctionCall {
distinct: opt_distinct.is_some(),
name,
args: opt_args.unwrap_or_default(),
params,
window: Some(window),
lambda: None,
},
},
);
let function_call_with_params = map(
rule! {
#function_name
~ "(" ~ #comma_separated_list1(subexpr(0)) ~ ")"
~ "(" ~ DISTINCT? ~ #comma_separated_list0(subexpr(0))? ~ ")"
},
|(name, _, params, _, _, opt_distinct, opt_args, _)| ExprElement::FunctionCall {
func: FunctionCall {
distinct: opt_distinct.is_some(),
name,
args: opt_args.unwrap_or_default(),
params,
window: None,
window,
lambda: None,
},
},
Expand Down Expand Up @@ -1406,7 +1389,6 @@ pub fn expr_element(i: Input) -> IResult<WithSpan<ExprElement>> {
| #function_call_with_lambda : "`function(..., x -> ...)`"
| #function_call_with_window : "`function(...) OVER ([ PARTITION BY <expr>, ... ] [ ORDER BY <expr>, ... ] [ <window frame> ])`"
| #function_call_with_params_window : "`function(...)(...) OVER ([ PARTITION BY <expr>, ... ] [ ORDER BY <expr>, ... ] [ <window frame> ])`"
| #function_call_with_params : "`function(...)(...)`"
| #function_call : "`function(...)`"
),
rule!(
Expand Down
5 changes: 5 additions & 0 deletions src/tests/sqlsmith/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ pub struct Args {
/// The fuzz query test file path.
#[clap(long, default_value = "")]
fuzz_path: String,

/// The log path to write executed SQLs..
#[clap(long, default_value = ".databend/sqlsmithlog")]
log_path: String,
}

#[tokio::main(flavor = "multi_thread", worker_threads = 5)]
Expand All @@ -69,6 +73,7 @@ async fn main() -> Result<()> {
args.user.clone(),
args.pass.clone(),
args.db.clone(),
args.log_path.clone(),
args.count,
None,
args.timeout,
Expand Down
1 change: 1 addition & 0 deletions src/tests/sqlsmith/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ mod query_fuzzer;
mod reducer;
mod runner;
mod sql_gen;
mod util;

pub use runner::Runner;
Loading

0 comments on commit 3a32c18

Please sign in to comment.