Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump sqllogictest to 0.9.0 #736

Merged
merged 3 commits into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update test files
Signed-off-by: xxchan <[email protected]>
  • Loading branch information
xxchan committed Dec 15, 2022
commit 676dcb89d995ce85feef3003b00bcb102799c2f9
18 changes: 17 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,15 @@ impl sqllogictest::AsyncDB for DatabaseWrapper {
async fn run(&mut self, sql: &str) -> Result<sqllogictest::DBOutput, Self::Error> {
use sqllogictest::{ColumnType, DBOutput};

let is_query_sql = {
let lower_sql = sql.trim_start().to_ascii_lowercase();
lower_sql.starts_with("select")
|| lower_sql.starts_with("values")
|| lower_sql.starts_with("show")
|| lower_sql.starts_with("with")
|| lower_sql.starts_with("describe")
};

info!("{}", sql);
let chunks = if self.enable_tracing {
let (root, collector) = Span::root("root");
Expand All @@ -283,7 +292,14 @@ impl sqllogictest::AsyncDB for DatabaseWrapper {
}

if chunks.is_empty() || chunks.iter().all(|c| c.data_chunks().is_empty()) {
return Ok(DBOutput::StatementComplete(0));
if is_query_sql {
return Ok(DBOutput::Rows {
types: vec![],
rows: vec![],
});
} else {
return Ok(DBOutput::StatementComplete(0));
}
}
let types = vec![ColumnType::Any; chunks[0].get_first_data_chunk().column_count()];
let rows = chunks
Expand Down
2 changes: 0 additions & 2 deletions tests/sql/aggregation.slt
Original file line number Diff line number Diff line change
Expand Up @@ -215,5 +215,3 @@ NULL

statement ok
DROP TABLE test;


2 changes: 1 addition & 1 deletion tests/sql/blob.slt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright 2018-2022 Stichting DuckDB Foundation
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Expand Down
1 change: 1 addition & 0 deletions tests/sql/delete.slt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ statement ok
delete from t

query III rowsort
select * from t
----
4 changes: 2 additions & 2 deletions tests/sql/distinct.slt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ SELECT DISTINCT sum(x) FROM test ORDER BY sum(x);
7


# ORDER BY items must appear in the select list
# ORDER BY items must appear in the select list
# if SELECT DISTINCT is specified
statement error
SELECT DISTINCT x FROM test ORDER BY y;
SELECT DISTINCT x FROM test ORDER BY y;
10 changes: 5 additions & 5 deletions tests/sql/filter.slt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ insert into t values (1, 1), (4, 6), (3, 2), (2, 1)
query I rowsort
select v1 from t where v1 > 2
----
4
3
4

query I
select v2 from t where 3 > v1
Expand Down Expand Up @@ -43,14 +43,14 @@ select v2 from t where (-7 < v1 or 9 <= v1) and (v1 = 3)
query I rowsort
select v2 from t where (-8 < v1 and v1 <= -7) or (v1 >= 1 and 2 > v1)
----
1
-7
1

query I rowsort
select v2 from t where ((v1 >= -8 and -4 >= v1) or (v1 >= 0 and 5 > v1)) and ((v1 > 0 and v1 <= 1) or (v1 > -8 and v1 < -6))
----
1
-7
1

query I rowsort
select v2 from t where (-7 < v1 or 9 <= v1) and (v2 = 3)
Expand All @@ -61,14 +61,14 @@ select v2 from t where (-7 < v1 or 9 <= v1) and (v2 = 3)
query I rowsort
select v2 from t where (-8 < v1 and v2 <= -7) or (v1 >= 1 and 2 > v2)
----
1
-7
1

query I rowsort
select v2 from t where ((v2 >= -8 and -4 >= v1) or (v1 >= 0 and 5 > v2)) and ((v2 > 0 and v1 <= 1) or (v1 > -8 and v2 < -6))
----
1
-7
1

statement ok
drop table t
24 changes: 12 additions & 12 deletions tests/sql/group_by.slt
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,30 @@ select v2 + count(*) from t group by v2 order by v1;
query II rowsort
select v2 + 1, sum(v1) from t group by v2 + 1
----
4 5
2 3
3 7
2 3
3 7
4 5

query III rowsort
select sum(v1), v2 + 1 as a, count(*) from t group by a
----
3 2 2
7 3 2
5 4 1
3 2 2
5 4 1
7 3 2

query III rowsort
select v2, v2 + 1, sum(v1) from t group by v2 + 1, v2
----
1 2 3
3 4 5
2 3 7
1 2 3
2 3 7
3 4 5

query III rowsort
select v2, v2 + 1, sum(v1) from t group by v2 + 1, v2 order by v2
----
1 2 3
3 4 5
2 3 7
1 2 3
2 3 7
3 4 5

query I rowsort
select v1 + 1 + count(*) from t group by v1 + 1
Expand Down
1 change: 0 additions & 1 deletion tests/sql/having.slt
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,3 @@ select y + 1 as i from test group by y + 1 having count(x) > 1 and y + 1 = 3 or

statement error
select count(x) from test group by count(x)

18 changes: 9 additions & 9 deletions tests/sql/insert.slt
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ insert into t values (NULL,NULL,NULL)
query III rowsort
select * from t
----
1 10 100
1 10 100
2 20 200
3 30 300
4 40 400
1 10 100
1 10 NULL
10 1 NULL
NULL NULL NULL
1 10 100
1 10 100
1 10 100
1 10 NULL
10 1 NULL
2 20 200
3 30 300
4 40 400
NULL NULL NULL
2 changes: 1 addition & 1 deletion tests/sql/insert_select_from.slt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ select * from b
1 10
2 20
3 30
4 40
4 40
2 changes: 1 addition & 1 deletion tests/sql/limit.slt
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ insert into t values (1, 1)

query I
select v1 from t limit 0
----
----
4 changes: 2 additions & 2 deletions tests/sql/select.slt
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ select sum(v1), sum(v2) from t
query IIII rowsort
select sum(v1), count(v3), min(v3), max(v1) from t group by v2, v2
----
6 2 3 4
4 2 2 3
4 2 2 3
6 2 3 4

# AggregateWithProjectionTest0

Expand Down
2 changes: 1 addition & 1 deletion tests/sql/where.slt
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ select v2 from t where v1 is not null;
4

statement ok
drop table t
drop table t
28 changes: 26 additions & 2 deletions tests/sqllogictest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use sqllogictest::{ColumnType, DBOutput};

type Result<T> = core::result::Result<T, Box<dyn std::error::Error>>;

#[derive(Clone, Copy)]
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum Engine {
Disk,
Mem,
Expand All @@ -37,6 +37,14 @@ pub async fn test(filename: impl AsRef<Path>, engine: Engine, v1: bool) -> Resul
let db = DatabaseWrapper(db);
let mut tester = sqllogictest::Runner::new(&db);
tester.enable_testdir();

// Uncomment the following lines to update the test files.
// if engine == Engine::Disk && !v1 {
// // Only use one engine to update to avoid conflicts.
// sqllogictest::update_test_file(filename, tester, "\t", sqllogictest::default_validator)
// .await?;
// }

tester.run_file_async(filename).await?;
db.0.shutdown().await?;
Ok(())
Expand All @@ -49,9 +57,25 @@ struct DatabaseWrapper(Database);
impl sqllogictest::AsyncDB for &DatabaseWrapper {
type Error = Error;
async fn run(&mut self, sql: &str) -> core::result::Result<DBOutput, Self::Error> {
let is_query_sql = {
let lower_sql = sql.trim_start().to_ascii_lowercase();
lower_sql.starts_with("select")
|| lower_sql.starts_with("values")
|| lower_sql.starts_with("show")
|| lower_sql.starts_with("with")
|| lower_sql.starts_with("describe")
};

let chunks = self.0.run(sql).await?;
if chunks.is_empty() || chunks.iter().all(|c| c.data_chunks().is_empty()) {
return Ok(DBOutput::StatementComplete(0));
if is_query_sql {
return Ok(DBOutput::Rows {
types: vec![],
rows: vec![],
});
} else {
return Ok(DBOutput::StatementComplete(0));
}
}
let types = vec![ColumnType::Any; chunks[0].get_first_data_chunk().column_count()];
let rows = chunks
Expand Down