This document describes all the procedures that developers need to know to contribute effectively to the Soda SQL codebase.
In directory scripts
there are a number of convenience scripts that also
serve as documentation for developer recipes. So you might want to check there
if you're looking for how to complete a particular procedure. They are typically
created on a mac and may not be compatible on other developer systems.
To get started you need a virtual environment. Use the following script
to (re)create a .venv
virtual environment in the root of the project.
scripts/recreate_venv.sh
Before pushing a commit, be sure to run the pre commit test suite. The test suite is (and should be) kept fast enough (<2 mins) so that it doesn't interrupt the developer flow too much. You can use the script
scripts/run_tests.sh
The pre commit test suite requires a local PostgreSQL database
running with certain user and database preconfigured. Use
scripts/start_postgres_container.sh
to start a docker container to
launch a correct PostgreSQL db with the right user and database.
Make sure that you you install dev-requirements
pip-compile dev-requiremnts.in
pip install -r dev-requiremnts.txt
Pushing a release is fully automated and only requires to bump the version using tbump
. For example to release 2.1.0b3, you can use the following command:
tbump 2.1.0b3
The warehouse dialect defines two things:
- dialect methods specific to the SQL dialect. This includes methods such as:
is_text
andis_number
for detecting the data typessql_tables_metadata_query
andsql_columns_metadata_query
for fetching metadataqualify_table_name
andqualify_column_name
for the table and column namesql_expr_
for some sql expressions
- warehouse connection that the connection engine creates with
create_connection
. The connection engine must be compatible with Python database API. The connection has two helper methods:is_connection_error
andis_authentication_error
.
For reference, see the base dialect class and the Postgres dialect.
Take the following steps to add a warehouse dialect:
- Create a docker container containing a warehouse. For example, this Docker compose contains the Docker container for the postgres warehouse.
- Add the warehouse
config
,suite
andfixture
to the warehouse testsconfig
: is thewarehouse.yml
configuration. Name the file<warehouse>_cfg.yml
. For example, the Postgres configuration ispostgres_cfg.yml
suite
: contains the setup for the warehouse test suite. Name the file<warehouse>_suite.py
. For example, the Postgres suite ispostgres_suite.py
fixture
: is the fixture for the warehouse tests. Name the file<warehouse_fixture.py
. For example, the Postgres fixture ispostgres_fixture.py
- Add the
fixture
to the general warehouse fixture. - Add the warehouse dialect under
packages
:setup.py
: setup to install the dialect.sodasql/dialects/<warehouse>_dialect.py
: the warehouse dialect. For example the postgres dialect.
- Add the dialect to dialect.py.