You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 7, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: optd-sqlplannertest/README.md
+50-16
Original file line number
Diff line number
Diff line change
@@ -1,20 +1,54 @@
1
-
# Usage
1
+
# SQL Planner Tests
2
2
3
-
## Update the test cases
3
+
These test cases use the [sqlplannertest](https://crates.io/crates/sqlplannertest) crate to execute SQL queries and inspect their output.
4
+
They do not check whether a plan is correct, and instead rely on a text-based diff of the query's output to determine whether something is different than the expected output.
4
5
5
-
```shell
6
-
cargo run -p optd-sqlplannertest --bin planner_test_apply
7
-
# or, supply a list of directories to scan from
8
-
cargo run -p optd-sqlplannertest --bin planner_test_apply -- subqueries
9
-
```
10
6
11
-
## Verify the test cases
7
+
## Execute Test Cases
12
8
13
9
```shell
14
10
cargo test -p optd-sqlplannertest
15
11
# or use nextest
16
12
cargo nextest run -p optd-sqlplannertest
17
13
```
14
+
## Add New Test Case
15
+
16
+
To add a SQL query tests, create a YAML file in a subdir in "tests".
17
+
Each file can contain multiple tests that are executed in sequential order from top to bottom.
| `sql` | List of SQL statements to execute separate by newlines |
36
+
| `tasks` | How to execute the SQL statements. See [Tasks](#tasks) below |
37
+
| `desc` | (Optional) Text description of what the test cases represents |
38
+
39
+
After adding the YAML file, you then need to use the update command to automatically create the matching SQL file that contains the expected output of the test cases.
40
+
41
+
## Regenerate Test Case Output
42
+
43
+
If you change the output of optd's `EXPLAIN` syntax, then you need to update all of the expected output files for each test cases.
44
+
The following commands will automatically update all of them for you. You should try to avoid this doing this often since if you introduce a bug, all the outputs will get overwritten and the tests will report false negatives.
45
+
46
+
```shell
47
+
# Update all test cases
48
+
cargo run -p optd-sqlplannertest --bin planner_test_apply
49
+
# or, supply a list of directories to update
50
+
cargo run -p optd-sqlplannertest --bin planner_test_apply -- subqueries
51
+
```
18
52
19
53
## Tasks
20
54
@@ -24,19 +58,19 @@ The `explain` and `execute` task will be run with datafusion's logical optimizer
0 commit comments