|
| 1 | +### Overview |
| 2 | +This is Databend's [sqllogictest](https://www.sqlite.org/sqllogictest/doc/trunk/about.wiki) implementation. It uses [sqllogictest-rs](https://github.com/risinglightdb/sqllogictest-rs) to parse test files and run test cases. |
| 3 | + |
| 4 | +### Usage |
| 5 | +You can directly run the following commands under databend directory |
| 6 | + |
| 7 | +--- |
| 8 | +Run all tests under the three handlers(mysql, http, clickhouse) in turn. |
| 9 | +```shell |
| 10 | +cargo run -p sqllogictests |
| 11 | +``` |
| 12 | +--- |
| 13 | +Run all tests with specific handler. |
| 14 | +```shell |
| 15 | +cargo run -p sqllogictests -- --handlers <handler_name> |
| 16 | +``` |
| 17 | +--- |
| 18 | +Run tests under specific directory. |
| 19 | + |
| 20 | +```shell |
| 21 | +cargo run -p sqllogictests -- --run_dir <dir_name> |
| 22 | +``` |
| 23 | +--- |
| 24 | +Run tests under specific file. This is the most commonly used command because users do not need to run all tests at a time and only need to run their newly added test files or test files with changes |
| 25 | +```shell |
| 26 | +cargo run -p sqllogictests -- --run_file <file_name> |
| 27 | +``` |
| 28 | +--- |
| 29 | +For more information, run help command: |
| 30 | +```shell |
| 31 | +cargo run -p sqllogictests -- --help |
| 32 | +``` |
| 33 | + |
| 34 | +### sqllogictest |
| 35 | +Most records are either a statement or a query. A statement is an SQL command that is to be evaluated but from which we do not expect to get results (other than success or failure). A statement might be a CREATE TABLE or an INSERT or an UPDATE or a DROP INDEX. A query is an SQL command from which we expect to receive results. The result set might be empty. |
| 36 | + |
| 37 | +A statement record begins with one of the following two lines: |
| 38 | +``` |
| 39 | +statement ok |
| 40 | +statement error <error info> |
| 41 | +``` |
| 42 | +The SQL command to be evaluated is found on the second and all subsequent liens of the record. Only a single SQL command is allowed per statement. The SQL should not have a semicolon or other terminator at the end. |
| 43 | + |
| 44 | +A query record begins with a line of the following form: |
| 45 | +``` |
| 46 | +# comments |
| 47 | +query <type_string> <sort_mode> <label> |
| 48 | +<sql_query> |
| 49 | +---- |
| 50 | +<expected_result> |
| 51 | +``` |
| 52 | +The SQL for the query is found on second an subsequent lines of the record up to first line of the form "----" or until the end of the record. Lines following the "----" are expected results of the query, one value per line. If the "----" and/or the results are omitted, then the query is expected to return an empty set. |
| 53 | + |
| 54 | +For more information about arguments, such as <type_string>, <sort_mode>, <label> please refer to [sqllogictest](https://www.sqlite.org/sqllogictest/doc/trunk/about.wiki). |
| 55 | + |
0 commit comments