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.6.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.6-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sqltest-0.0.6.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.6.tar.gz
Algorithm Hash digest
SHA256 ecf3ed2c8b048b27901af16a43ef687a722aeaacfe2a0f60f4e8e30f62ab5e02
MD5 e52e56e2b7096ab3cabce90ec162b6e5
BLAKE2b-256 8a8a8a59e2a944036cb431de347ed86faa825743b924e5f4e3d8c64bfcf25d28

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sqltest-0.0.6-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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 f89e397e842b52d117eab86206eca9ec58ff6ee2d8bf62fc3e8cc1ac44bfcb64
MD5 0baf0c10d6fb43c5cb0bcb2b90c2d801
BLAKE2b-256 6234ac36ca3d3373f60e2036dd56e9ad5ebbd914e9b168d4af2ccbea484d71d9

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