Skip to content

Commit 3a32c18

Browse files
authored
feat(sqlsmith): fuzz test support read Sqlite and Duckdb test (#17301)
1 parent 248ec52 commit 3a32c18

File tree

9 files changed

+361
-215
lines changed

9 files changed

+361
-215
lines changed

src/query/ast/src/parser/expr.rs

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,32 +1088,15 @@ pub fn expr_element(i: Input) -> IResult<WithSpan<ExprElement>> {
10881088
#function_name
10891089
~ "(" ~ #comma_separated_list1(subexpr(0)) ~ ")"
10901090
~ "(" ~ DISTINCT? ~ #comma_separated_list0(subexpr(0))? ~ ")"
1091-
~ #window_function
1091+
~ #window_function?
10921092
},
10931093
|(name, _, params, _, _, opt_distinct, opt_args, _, window)| ExprElement::FunctionCall {
10941094
func: FunctionCall {
10951095
distinct: opt_distinct.is_some(),
10961096
name,
10971097
args: opt_args.unwrap_or_default(),
10981098
params,
1099-
window: Some(window),
1100-
lambda: None,
1101-
},
1102-
},
1103-
);
1104-
let function_call_with_params = map(
1105-
rule! {
1106-
#function_name
1107-
~ "(" ~ #comma_separated_list1(subexpr(0)) ~ ")"
1108-
~ "(" ~ DISTINCT? ~ #comma_separated_list0(subexpr(0))? ~ ")"
1109-
},
1110-
|(name, _, params, _, _, opt_distinct, opt_args, _)| ExprElement::FunctionCall {
1111-
func: FunctionCall {
1112-
distinct: opt_distinct.is_some(),
1113-
name,
1114-
args: opt_args.unwrap_or_default(),
1115-
params,
1116-
window: None,
1099+
window,
11171100
lambda: None,
11181101
},
11191102
},
@@ -1406,7 +1389,6 @@ pub fn expr_element(i: Input) -> IResult<WithSpan<ExprElement>> {
14061389
| #function_call_with_lambda : "`function(..., x -> ...)`"
14071390
| #function_call_with_window : "`function(...) OVER ([ PARTITION BY <expr>, ... ] [ ORDER BY <expr>, ... ] [ <window frame> ])`"
14081391
| #function_call_with_params_window : "`function(...)(...) OVER ([ PARTITION BY <expr>, ... ] [ ORDER BY <expr>, ... ] [ <window frame> ])`"
1409-
| #function_call_with_params : "`function(...)(...)`"
14101392
| #function_call : "`function(...)`"
14111393
),
14121394
rule!(

src/tests/sqlsmith/src/bin/main.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ pub struct Args {
5252
/// The fuzz query test file path.
5353
#[clap(long, default_value = "")]
5454
fuzz_path: String,
55+
56+
/// The log path to write executed SQLs..
57+
#[clap(long, default_value = ".databend/sqlsmithlog")]
58+
log_path: String,
5559
}
5660

5761
#[tokio::main(flavor = "multi_thread", worker_threads = 5)]
@@ -69,6 +73,7 @@ async fn main() -> Result<()> {
6973
args.user.clone(),
7074
args.pass.clone(),
7175
args.db.clone(),
76+
args.log_path.clone(),
7277
args.count,
7378
None,
7479
args.timeout,

src/tests/sqlsmith/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ mod query_fuzzer;
1919
mod reducer;
2020
mod runner;
2121
mod sql_gen;
22+
mod util;
2223

2324
pub use runner::Runner;

0 commit comments

Comments
 (0)