Skip to content

Commit

Permalink
fix(ci): add missing sqlsmith queries (#8214)
Browse files Browse the repository at this point in the history
* fix

* fix
  • Loading branch information
kwannoel authored Feb 28, 2023
1 parent 1cc3ad5 commit 42324a9
Show file tree
Hide file tree
Showing 204 changed files with 19,599 additions and 19,078 deletions.
3 changes: 3 additions & 0 deletions src/tests/sqlsmith/clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
disallowed-methods = [
{ path = "tokio_postgres::Client::query", reason = "Please use `simple_query` instead, extended `query` uses binary format, which has some outstanding issues." },
]
6 changes: 6 additions & 0 deletions src/tests/sqlsmith/scripts/gen_queries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,16 @@ generate_sqlsmith() {
--generate "$OUTDIR/$1"
}

# Check which queries failed
check_failing_queries() {
ls .risingwave/log | grep fuzz | sed -E 's/fuzzing\-([0-9]*).log/\1/'
}

main() {
cd $RW_HOME
build_madsim
generate_deterministic
check_failing_queries
cd -
}

Expand Down
8 changes: 4 additions & 4 deletions src/tests/sqlsmith/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub async fn run_pre_generated(client: &tokio_postgres::Client, outdir: &str) {
for statement in parse_sql(&queries) {
let sql = statement.to_string();
tracing::info!("Executing: {}", sql);
let response = client.query(&sql, &[]).await;
let response = client.simple_query(&sql).await;
if let Err(e) = response {
panic!("{}", format_fail_reason(&setup_sql, &sql, &e))
}
Expand Down Expand Up @@ -86,7 +86,7 @@ pub async fn generate(client: &tokio_postgres::Client, testdata: &str, count: us
let session_sql = test_session_variable(client, &mut rng).await;
let sql = sql_gen(&mut rng, tables.clone());
tracing::info!("Executing: {}", sql);
let response = client.query(sql.as_str(), &[]).await;
let response = client.simple_query(sql.as_str()).await;
let skipped =
validate_response(&setup_sql, &format!("{};\n{};", session_sql, sql), response);
if skipped == 0 {
Expand All @@ -101,7 +101,7 @@ pub async fn generate(client: &tokio_postgres::Client, testdata: &str, count: us
let session_sql = test_session_variable(client, &mut rng).await;
let (sql, table) = mview_sql_gen(&mut rng, tables.clone(), "stream_query");
tracing::info!("Executing: {}", sql);
let response = client.query(&sql, &[]).await;
let response = client.simple_query(&sql).await;
let skipped =
validate_response(&setup_sql, &format!("{};\n{};", session_sql, sql), response);
drop_mview_table(&table, client).await;
Expand Down Expand Up @@ -191,7 +191,7 @@ async fn populate_tables<R: Rng>(
let inserts = insert_sql_gen(rng, base_tables, row_count);
for insert in &inserts {
tracing::info!("[EXECUTING POPULATION]: {}", insert);
client.query(insert, &[]).await.unwrap();
client.simple_query(insert).await.unwrap();
}
inserts.into_iter().map(|i| format!("{};\n", i)).collect()
}
Expand Down
2 changes: 1 addition & 1 deletion src/tests/sqlsmith/src/sql_gen/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl<'a, R: Rng> SqlGenerator<'a, R> {
let ty = column.data_type;
let expr = self.gen_simple_scalar(&ty); // WORKAROUND
let in_subquery_expr = Expr::InSubquery {
expr: Box::new(expr),
expr: Box::new(Expr::Nested(Box::new(expr))),
subquery: Box::new(query),
negated: self.flip_coin(),
};
Expand Down
19 changes: 9 additions & 10 deletions src/tests/sqlsmith/tests/freeze/1/ddl.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ CREATE TABLE auction (id BIGINT, item_name CHARACTER VARYING, description CHARAC
CREATE TABLE bid (auction BIGINT, bidder BIGINT, price BIGINT, channel CHARACTER VARYING, url CHARACTER VARYING, date_time TIMESTAMP, extra CHARACTER VARYING);
CREATE TABLE alltypes1 (c1 BOOLEAN, c2 SMALLINT, c3 INT, c4 BIGINT, c5 REAL, c6 DOUBLE, c7 NUMERIC, c8 DATE, c9 CHARACTER VARYING, c10 TIME, c11 TIMESTAMP, c13 INTERVAL, c14 STRUCT<a INT>, c15 INT[], c16 CHARACTER VARYING[]);
CREATE TABLE alltypes2 (c1 BOOLEAN, c2 SMALLINT, c3 INT, c4 BIGINT, c5 REAL, c6 DOUBLE, c7 NUMERIC, c8 DATE, c9 CHARACTER VARYING, c10 TIME, c11 TIMESTAMP, c13 INTERVAL, c14 STRUCT<a INT>, c15 INT[], c16 CHARACTER VARYING[]);
CREATE MATERIALIZED VIEW m0 AS SELECT (sq_1.col_2 - CAST(true AS INT)) AS col_0, sq_1.col_1 AS col_1 FROM (SELECT ((((INT '296') - (SMALLINT '-32768')) | (INT '253')) / t_0.id) AS col_0, ((INT '-2147483648') + (t_0.initial_bid | ((- (SMALLINT '277')) # (INT '227')))) AS col_1, (773) AS col_2 FROM auction AS t_0 WHERE false GROUP BY t_0.initial_bid, t_0.description, t_0.item_name, t_0.date_time, t_0.id) AS sq_1 WHERE true GROUP BY sq_1.col_1, sq_1.col_2;
CREATE MATERIALIZED VIEW m1 AS SELECT CAST(NULL AS STRUCT<a INTERVAL, b NUMERIC>) AS col_0, (TRIM(TRAILING t_0.p_type FROM ('BrvccI19br'))) AS col_1, (CAST(CAST(t_0.p_size AS BOOLEAN) AS INT) + DATE '2022-01-02') AS col_2, true AS col_3 FROM part AS t_0 LEFT JOIN lineitem AS t_1 ON t_0.p_mfgr = t_1.l_returnflag WHERE false GROUP BY t_1.l_linestatus, t_1.l_suppkey, t_1.l_returnflag, t_1.l_shipinstruct, t_0.p_type, t_1.l_comment, t_0.p_retailprice, t_0.p_size, t_0.p_container HAVING true;
CREATE MATERIALIZED VIEW m2 AS SELECT (INT '0') AS col_0, tumble_0.c7 AS col_1, (414) AS col_2 FROM tumble(alltypes1, alltypes1.c11, INTERVAL '91') AS tumble_0 WHERE tumble_0.c1 GROUP BY tumble_0.c16, tumble_0.c14, tumble_0.c10, tumble_0.c5, tumble_0.c2, tumble_0.c7, tumble_0.c13;
CREATE MATERIALIZED VIEW m3 AS SELECT tumble_0.c1 AS col_0, tumble_0.c1 AS col_1, tumble_0.c1 AS col_2, true AS col_3 FROM tumble(alltypes2, alltypes2.c11, INTERVAL '48') AS tumble_0 WHERE tumble_0.c1 GROUP BY tumble_0.c1 HAVING ((832) = ((SMALLINT '981') - (INT '0')));
CREATE MATERIALIZED VIEW m4 AS SELECT t_2.bidder AS col_0 FROM bid AS t_2 WHERE true GROUP BY t_2.extra, t_2.price, t_2.bidder HAVING false;
CREATE MATERIALIZED VIEW m5 AS WITH with_0 AS (SELECT ((coalesce(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, sq_3.col_0)) & sq_3.col_0) AS col_0 FROM (WITH with_1 AS (SELECT (((INT '900') + DATE '2022-01-02') + (INTERVAL '-595892')) AS col_0, t_2.expires AS col_1, TIMESTAMP '2022-01-02 02:04:33' AS col_2 FROM auction AS t_2 WHERE (t_2.id = (FLOAT '275')) GROUP BY t_2.expires) SELECT (SMALLINT '487') AS col_0, (802) AS col_1 FROM with_1) AS sq_3 WHERE true GROUP BY sq_3.col_0 HAVING (false)) SELECT TIMESTAMP '2022-01-01 15:23:14' AS col_0, false AS col_1, (INT '518') AS col_2 FROM with_0;
CREATE MATERIALIZED VIEW m6 AS SELECT t_2.col_2 AS col_0, t_2.col_2 AS col_1, ((BIGINT '687') - ((SMALLINT '-16176') / t_2.col_2)) AS col_2, t_2.col_2 AS col_3 FROM m2 AS t_2 GROUP BY t_2.col_2 HAVING true;
CREATE MATERIALIZED VIEW m7 AS SELECT t_1.col_1 AS col_0, (substr(t_0.r_name, t_1.col_0)) AS col_1 FROM region AS t_0 RIGHT JOIN m2 AS t_1 ON t_0.r_regionkey = t_1.col_0 WHERE true GROUP BY t_1.col_1, t_1.col_0, t_0.r_name HAVING false;
CREATE MATERIALIZED VIEW m8 AS WITH with_0 AS (SELECT hop_1.c15 AS col_0 FROM hop(alltypes2, alltypes2.c11, INTERVAL '1', INTERVAL '53') AS hop_1 GROUP BY hop_1.c9, hop_1.c6, hop_1.c5, hop_1.c4, hop_1.c15, hop_1.c11) SELECT ((418) - (BIGINT '876')) AS col_0, (- (REAL '0')) AS col_1 FROM with_0;
CREATE MATERIALIZED VIEW m9 AS SELECT tumble_0.c15 AS col_0, (tumble_0.c5 > (BIGINT '6871269807316363457')) AS col_1 FROM tumble(alltypes2, alltypes2.c11, INTERVAL '5') AS tumble_0 WHERE tumble_0.c1 GROUP BY tumble_0.c2, tumble_0.c1, tumble_0.c15, tumble_0.c5, tumble_0.c14, tumble_0.c11, tumble_0.c8 HAVING tumble_0.c1;
CREATE MATERIALIZED VIEW m0 AS SELECT (BIGINT '103') AS col_0, CAST(true AS INT) AS col_1 FROM (SELECT (((SMALLINT '0') >> (SMALLINT '-3088')) % (BIGINT '193')) AS col_0, t_0.item_name AS col_1, ((INT '-2147483648') - ((SMALLINT '0') + ((t_0.initial_bid << (INT '-562773059')) + (INT '931')))) AS col_2 FROM auction AS t_0 WHERE false GROUP BY t_0.initial_bid, t_0.description, t_0.item_name, t_0.date_time, t_0.id) AS sq_1 WHERE false GROUP BY sq_1.col_2;
CREATE MATERIALIZED VIEW m1 AS SELECT 'LC0xE4F3so' AS col_0, hop_0.c10 AS col_1, hop_0.c16 AS col_2, hop_0.c10 AS col_3 FROM hop(alltypes2, alltypes2.c11, INTERVAL '3600', INTERVAL '241200') AS hop_0 WHERE hop_0.c1 GROUP BY hop_0.c7, hop_0.c15, hop_0.c13, hop_0.c16, hop_0.c14, hop_0.c1, hop_0.c10, hop_0.c9;
CREATE MATERIALIZED VIEW m2 AS SELECT t_0.c_nationkey AS col_0 FROM customer AS t_0 WHERE true GROUP BY t_0.c_phone, t_0.c_address, t_0.c_name, t_0.c_nationkey HAVING false;
CREATE MATERIALIZED VIEW m3 AS SELECT (CASE WHEN false THEN t_1.c9 WHEN true THEN t_1.c9 WHEN true THEN t_1.c9 ELSE t_1.c9 END) AS col_0, (INTERVAL '3600') AS col_1, true AS col_2 FROM person AS t_0 LEFT JOIN alltypes1 AS t_1 ON t_0.name = t_1.c9 WHERE CAST(t_1.c3 AS BOOLEAN) GROUP BY t_1.c9 HAVING false;
CREATE MATERIALIZED VIEW m5 AS SELECT (BIGINT '360') AS col_0, t_0.date_time AS col_1, t_0.date_time AS col_2 FROM person AS t_0 WHERE false GROUP BY t_0.state, t_0.name, t_0.date_time;
CREATE MATERIALIZED VIEW m6 AS WITH with_0 AS (WITH with_1 AS (SELECT TIME '02:05:32' AS col_0 FROM m0 AS t_2 WHERE false GROUP BY t_2.col_0) SELECT (SMALLINT '487') AS col_0, (802) AS col_1, '1O5tODgVcw' AS col_2, ARRAY[(INTERVAL '0'), (INTERVAL '0'), (INTERVAL '51373')] AS col_3 FROM with_1 WHERE true) SELECT true AS col_0, TIMESTAMP '2022-01-02 02:05:32' AS col_1, (INT '827') AS col_2 FROM with_0 WHERE true;
CREATE MATERIALIZED VIEW m7 AS SELECT (TIMESTAMP '2021-12-26 02:05:34') AS col_0, t_0.date_time AS col_1 FROM auction AS t_0 GROUP BY t_0.id, t_0.seller, t_0.date_time, t_0.item_name;
CREATE MATERIALIZED VIEW m8 AS SELECT t_2.p_brand AS col_0, (upper('fEikqCj5Ji')) AS col_1, (TRIM(BOTH t_2.p_brand FROM 'cqxHHondPm')) AS col_2, t_2.p_brand AS col_3 FROM part AS t_2 GROUP BY t_2.p_brand HAVING false;
CREATE MATERIALIZED VIEW m9 AS SELECT t_1.r_regionkey AS col_0, (INT '233') AS col_1 FROM partsupp AS t_0 RIGHT JOIN region AS t_1 ON t_0.ps_comment = t_1.r_comment GROUP BY t_0.ps_supplycost, t_1.r_regionkey HAVING true;
Loading

0 comments on commit 42324a9

Please sign in to comment.