SQL Logic Test is a suite of more than 7 million tests that test core aspects of SQL.
This project uses SqlLogicTests https://www.sqlite.org/sqllogictest/doc/trunk/about.wiki. for testing the database query engines. This is a suite of more than 7 million tests that are designed to be portable. They only test core aspects of SQL. For example, the tests only cover integers, strings, and floating point values, and do not test corner cases, such as overflows.
The tests in the SQL logic test suite are given as ".test" files. Each test file is a combination of SQL statements that set up the test by creating and populating tables, followed by a sequence of queries over the created tables.
Some SQL Logic Test queries are written multiple times, in different SQL dialects; the test scripts will only execute only the queries in the chosen dialect. In our implementation we use the Postgres dialect.
This project provides a standalone Main class with a main function, and it can be compiled into a standalone executable. The executable recognizes the following command-line arguments:
slt [options] files_or_directories_with_tests
Executes the SQL Logic Tests using a SQL execution engine
See https://www.sqlite.org/sqllogictest/doc/trunk/about.wiki
Options:
-h Show this help message and exit
-x Stop at the first encountered query error
-n Do not execute, just parse the test files
-e executor Executor to use
-b filename Load a list of buggy commands to skip from this file
-v Increase verbosity (can be repeated)
-u username Postgres user name
-p password Postgres password
Registered executors:
hsql
psql
none
Here is an example invocation:
slt -e hsql select1.test index
This invocation will run the tests through HSQLDB, and will execute
the test script select1.test
and all the test scripts in the index
directory.
If some statements or queries are expected to fail, they can be added to a file
which is supplied with the -b
flag. Each such statement/query must be on a separate line of the file
and must be spelled identically to the way the statement/query appears in the test file,
but with the newline characters removed.
The -x
flag will stop at the first query error encountered.
The program will run all queries in the specified files and at the end print a list of failures including an explanation for each failure. A query can fail either because it triggers an internal database, or because it produces incorrect results. All the queries have been validated with sqlite, so a failure is very likely to be a true bug in the tested engine.
The verbosity flag -v
controls both the logging messages printed while running
the tests, and the details about each encountered error, after the tests
have completed. The flag can be repeated to increase verbosity; meaninful
values are between 0 and 2.
You can achieve this using the following invocation:
slt -e none -v
This program parses SqlLogicTest files and delegates their execution to "test executors". We provide multiple executors:
This executor does not really run any tests. But it can still be used by the test loading mechanism to check that we correctly parse all SQL logic test files.
This executor parallels the standard ODBC executor from the SQLLogicTest suite, (which is written in C). It sends both the statements and queries to a database to be executed. The JDBC executor is an abstract Java class which can be subclassed to implement concrete executors.
This is an extension of the JDBC executor that uses the HSQLDB http://hsqldb.org/ embedded database.
This executor is an extension of the JDBC executor that uses Postgres <> as a database. Prior to using this executor one must create a Postgres database named "slt" and users with appropriate permissions to access the database.
New executors can be added by extending the SqlSLTTestExecutor
class.
Get sql-logic-Test from Maven central:
<dependency>
<groupId>net.hydromatic</groupId>
<artifactId>sql-logic-test</artifactId>
<version>0.3</version>
</dependency>
You need Java (8 or higher) and Git.
$ git clone git://github.com/hydromatic/sql-logic-test.git
$ cd sql-logic-test
$ ./mvnw compile
On Windows, the last line is
> mvnw install
On Java versions less than 11, you should add parameters
-Dcheckstyle.version=9.3
.
- License: MIT
- Author: Julian Hyde
- Blog: https://hydromatic.blogspot.com
- Project page: http://www.hydromatic.net/sql-logic-test
- API: http://www.hydromatic.net/sql-logic-test/apidocs
- Source code: https://github.com/hydromatic/sql-logic-test
- Developers list: dev at calcite.apache.org (archive, subscribe)
- Issues: https://github.com/hydromatic/sql-logic-test/issues
- Release notes and history
- HOWTO