Skip to main content

sqltest: easy testing ETL sqls

Project description

sqltest

The sqltest framework makes it easy to write test cases for testing complicated ETL processing logic. What you need to do is prepare your source & target dataset with CSV format or Excel format, and also prepare your ETL SQL.

  • We only support CSV source dataset format currently, but we plan to implement more formats. e.g Excel
  • And also, we are planing to support more SQL engines, e.g. Spark, Flink.

An example of ETL sql test:

class TestExcelDataSource(TestCase):
    def test_excel_data_source_demo(self):
        environments = {
            'env': 'dev',
            'target_data_path': f'{PROJECT_PATH}/tests/data/tables'
        }

        reader = ExcelDatasetReader(
            data_path=f'{PROJECT_PATH}/tests/data/cases/spark_etl_sql_test_excel_demo/spark_etl_demo.xlsx')
        sql_file_path = f'{PROJECT_PATH}/tests/data/cases/spark_etl_sql_test_excel_demo/spark_etl_demo.sql'

        engine = SparkEngine(SPARK, environments)
        engine.run(reader, sql_file_path)
        engine.verify_target_dataset()

    @excel_reader(data_path=f'{PROJECT_PATH}/tests/data/cases/spark_etl_sql_test_excel_demo/spark_etl_demo.xlsx')
    @spark_engine(spark=SPARK,
                  sql_path=f'{PROJECT_PATH}/tests/data/cases/spark_etl_sql_test_excel_demo/spark_etl_demo.sql',
                  env={'env': 'dev', 'target_data_path': f'{PROJECT_PATH}/tests/data/tables'})
    def test_excel_with_decorate(self, reader: DatasetReader, engine: SqlEngine):
        engine.verify_target_dataset()

    @spark_engine(spark=SPARK,
                  sql_path=f'{PROJECT_PATH}/tests/data/cases/spark_etl_sql_test_excel_demo/spark_etl_demo.sql',
                  reader=ExcelDatasetReader(
                      f'{PROJECT_PATH}/tests/data/cases/spark_etl_sql_test_excel_demo/spark_etl_demo.xlsx'),
                  env={'env': 'dev', 'target_data_path': f'{PROJECT_PATH}/tests/data/tables'})
    def test_excel_with_engine_decorate(self, engine: SqlEngine):
        engine.verify_target_dataset()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sqltest-0.0.8.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sqltest-0.0.8-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file sqltest-0.0.8.tar.gz.

File metadata

  • Download URL: sqltest-0.0.8.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.3

File hashes

Hashes for sqltest-0.0.8.tar.gz
Algorithm Hash digest
SHA256 bd5d660aa8269a0db44ea2b8cb4ad65d449cac08636fb75bb4d19c8cca153c0f
MD5 c5aebc6b4a86410e8ebe671002b418b9
BLAKE2b-256 272f62244cb61a048bbf8d9ab68ad4ef492d5477b071115aab635c22df4bd722

See more details on using hashes here.

File details

Details for the file sqltest-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: sqltest-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.3

File hashes

Hashes for sqltest-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 9cdbaf0cf39106a1a3aae02f3f29c80392de6adfb6f4958aa6e3e8a59dbf6ab2
MD5 84d3a7298027832485f1cf5af1a55984
BLAKE2b-256 1797eab264566e27f6d310aeff9bcb8f6775abbc5499b1540a3d7d5d742362d1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page