Soda Core is a Python library and command-line interface (CLI) tool that enables you to scan the data in your data source to surface invalid, missing, or unexpected data.
Compatibility
Requirements
Install on MacOS, Linux
Install on Windows
Install using Docker
Upgrade
Install Soda Core Scientific
Use Soda Core to scan a variety of data sources.
| Amazon Athena Amazon Redshift Apache Spark DataFrames1 Apache Spark for Databricks SQL Azure Synapse ClickHouse Dask and Pandas1 Denodo Dremio DuckDB GCP Big Query IBM DB2 |
Local file using Dask1 MotherDuck MS Fabric MS SQL Server MySQL OracleDB PostgreSQL Snowflake Teradata Trino Vertica |
To use Soda Core, you must have installed the following on your system.
- Python 3.8 or greater. To check your existing version, use the CLI command:
python --versionorpython3 --versionIf you have not already installed Python, consider using pyenv to manage multiple versions of Python in your environment. - Pip 21.0 or greater. To check your existing version, use the CLI command:
pip --version
- Best practice dictates that you install the Soda Core CLI using a virtual environment. In your command-line interface tool, create a virtual environment in the
.venvdirectory using the commands below. Depending on your version of Python, you may need to replacepythonwithpython3in the first command.python -m venv .venv source .venv/bin/activate - Upgrade pip inside your new virtual environment.
pip install --upgrade pip
- Execute the following command, replacing
soda-core-postgreswith the install package that matches the type of data source you use to store data.pip install soda-core-postgres
| Data source | Install package |
|---|---|
| Amazon Athena | soda-core-athena |
| Amazon Redshift | soda-core-redshift |
| Apache Spark DataFrames (For use with [programmatic Soda scans]({% link soda-core/programmatic.md %}), only.) |
soda-core-spark-df |
| Azure Synapse (Experimental) | soda-core-sqlserver |
| ClickHouse (Experimental) | soda-core-mysql |
| Dask and Pandas (Experimental) | soda-core-pandas-dask |
| Databricks | soda-core-spark[databricks] |
| Denodo (Experimental) | soda-core-denodo |
| Dremio | soda-core-dremio |
| DuckDB (Experimental) | soda-core-duckdb |
| GCP Big Query | soda-core-bigquery |
| IBM DB2 | soda-core-db2 |
| Local file | Use Dask. |
| MotherDuck | soda-core-duckdb |
| MS Fabric | soda-core-fabric |
| MS SQL Server | soda-core-sqlserver |
| MySQL | soda-core-mysql |
| OracleDB | soda-core-oracle |
| PostgreSQL | soda-core-postgres |
| Snowflake | soda-core-snowflake |
| Teradata | soda-core-teradata |
| Trino | soda-core-trino |
| Vertica (Experimental) | soda-core-vertica |
To deactivate the virtual environment, use the following command:
deactivate- Best practice dictates that you install the Soda Core CLI using a virtual environment. In your command-line interface tool, create a virtual environment in the
.venvdirectory using the commands below. Depending on your version of Python, you may need to replacepythonwithpython3in the first command. Reference the virtualenv documentation for activating a Windows script.python -m venv .venv .venv\Scripts\activate
- Upgrade pip inside your new virtual environment.
pip install --upgrade pip
- Execute the following command, replacing
soda-core-postgreswith the install package that matches the type of data source you use to store data.pip install soda-core-postgres
| Data source | Install package |
|---|---|
| Amazon Athena | soda-core-athena |
| Amazon Redshift | soda-core-redshift |
| Apache Spark DataFrames (For use with [programmatic Soda scans]({% link soda-core/programmatic.md %}), only.) |
soda-core-spark-df |
| Azure Synapse (Experimental) | soda-core-sqlserver |
| ClickHouse (Experimental) | soda-core-mysql |
| Dask and Pandas (Experimental) | soda-core-pandas-dask |
| Databricks | soda-core-spark[databricks] |
| Denodo (Experimental) | soda-core-denodo |
| Dremio | soda-core-dremio |
| DuckDB (Experimental) | soda-core-duckdb |
| GCP Big Query | soda-core-bigquery |
| IBM DB2 | soda-core-db2 |
| Local file | Use Dask. |
| MotherDuck | soda-core-duckdb |
| MS Fabric | soda-core-fabric |
| MS SQL Server | soda-core-sqlserver |
| MySQL | soda-core-mysql |
| OracleDB | soda-core-oracle |
| PostgreSQL | soda-core-postgres |
| Snowflake | soda-core-snowflake |
| Teradata | soda-core-teradata |
| Trino | soda-core-trino |
| Vertica (Experimental) | soda-core-vertica |
To deactivate the virtual environment, use the following command:
deactivateReference the virtualenv documentation for activating a Windows script.
Use Soda's Docker image in which Soda Core Scientific is pre-installed.
- If you have not already done so, install Docker in your local environment.
- From Terminal, run the following command to pull the latest Soda Core's official Docker image.
docker pull sodadata/soda-core
- Verify the pull by running the following command.
Output:
docker run sodadata/soda-core --help
Usage: soda [OPTIONS] COMMAND [ARGS]... Soda Core CLI version 3.0.xxx Options: --help Show this message and exit. Commands: scan runs a scan update-dro updates a distribution reference file ```
When you run the Docker image on a non-Linux/amd64 platform, you may see the following warning from Docker, which you can ignore.
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requestedWhen you are ready to run a Soda scan, use the following command to run the scan via the docker image. Replace the placeholder values with your own file paths and names.
docker run -v /path/to/your_soda_directory:/sodacl sodadata/soda-core scan -d your_data_source -c /sodacl/your_configuration.yml /sodacl/your_checks.ymlOptionally, you can specify the version of Soda Core to use to execute the scan. This may be useful when you do not wish to use the latest released version of Soda Core to run your scans. The example scan command below specifies Soda Core version 3.0.0.
docker run -v /path/to/your_soda_directory:/sodacl sodadata/soda-core:v3.0.0 scan -d your_data_source -c /sodacl/your_configuration.yml /sodacl/your_checks.ymlWhat does the scan command do?
docker runensures that the docker engine runs a specific image.-vmounts your SodaCL files into the container. In other words, it makes the configuration.yml and checks.yml files in your local environment available to the docker container. The command example maps your local directory to/sodaclinside of the docker container.sodadata/soda-corerefers to the image thatdocker runmust use.scaninstructs Soda Core to execute a scan of your data.-dindicates the name of the data source to scan.-cspecifies the filepath and name of the configuration YAML file.
If you encounter the following error, follow the procedure below.
docker: Error response from daemon: Mounts denied:
The path /soda-core-test/files is not shared from the host and is not known to Docker.
You can configure shared paths from Docker -> Preferences... -> Resources -> File Sharing.
See https://docs.docker.com/desktop/mac for more info.You need to give Docker permission to acccess your configuration.yml and checks.yml files in your environment. To do so:
- Access your Docker Dashboard, then select Preferences (gear symbol).
- Select Resources, then follow the Docker instructions to add your Soda project directory -- the one you use to store your configuration.yml and checks.yml files -- to the list of directories that can be bind-mounted into Docker containers.
- Click Apply & Restart, then repeat steps above.
If you encounter the following error, double check the syntax of the scan command in step 4 above.
- Be sure to prepend
/sodacl/to both the configuration.yml filepath and the checks.yml filepath. - Be sure to mount your files into the container by including the
-voption. For example,-v /Users/MyName/soda_core_project:/sodacl.
Soda Core 3.0.xxx
Configuration path 'configuration.yml' does not exist
Path "checks.yml" does not exist
Scan summary:
No checks found, 0 checks evaluated.
2 errors.
Oops! 2 errors. 0 failures. 0 warnings. 0 pass.
ERRORS:
Configuration path 'configuration.yml' does not exist
Path "checks.yml" does not existTo upgrade your existing Soda Core tool to the latest version, use the following command, replacing soda-core-redshift with the install package that matches the type of data source you are using.
pip install soda-core-redshift -UInstall Soda Core Scientific to be able to use SodaCL distribution checks or anomaly score checks.
You have two installation options to choose from:
- Install Soda Core Scientific in a virtual environment (Recommended)
- Use Docker to run Soda Core with Soda Scientific
- Set up a virtual environment, as described above.
- Install Soda Core in your new virtual environment, as described above.
- Use the following command to install Soda Core Scientific.
pip install soda-core-scientific
Note that installing the Soda Core Scientific package also installs several scientific dependencies. Reference the soda-core-scientific setup file in the public GitHub repository for details.
If you have defined an anomaly score check and you use an M1 MacOS machine, you may get a Library not loaded: @rpath/libtbb.dylib error. This is a known issue in the MacOS community and is caused by issues during the installation of the prophet library. There currently are no official workarounds or releases to fix the problem, but the following adjustments may address the issue.
- Install
soda-core-scientificas per the virtual environment installation instructions and activate the virtual environment. - Use the following command to navigate to the directory in which the
stan_modelof theprophetpackage is installed in your virtual environment.For example, if you have created a python virtual environment in acd path_to_your_python_virtual_env/lib/pythonyour_version/site_packages/prophet/stan_model//venvsdirectory in your home directory and you use Python 3.9, you would use the following command.cd ~/venvs/soda-core-prophet11/lib/python3.9/site-packages/prophet/stan_model/
- Use the
lscommand to determine the version number ofcmndstanthatprophetinstalled. Thecmndstandirectory name includes the version number.ls cmdstan-2.26.1 prophet_model.bin
- Add the
rpathof thetbblibrary to yourprophetinstallation using the following command.Withinstall_name_tool -add_rpath @executable_path/cmdstanyour_cmdstan_version/stan/lib/stan_math/lib/tbb prophet_model.bin
cmdstanversion2.26.1, you would use the following command.install_name_tool -add_rpath @executable_path/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb prophet_model.bin