Skip to content

Conversation

@Somtom
Copy link
Collaborator

@Somtom Somtom commented Dec 29, 2023

Problem Context

Relates to #7

Currently it is not straight forward to use SQLMock with dbt. This PR should solve that by adding dbt support

What changed

Introduced new decorator classes:

  • dbt Model Support: The introduction of a dbt_model_meta decorator allows SQLMock to directly interface with dbt models. This decorator links SQLMock mock tables to specific dbt models, enabling the testing of dbt-generated SQL queries within the SQLMock framework.
@dbt_model_meta(model_name="your_dbt_model_name")
class YourDBTModelTable(BigQueryMockTable):
    # Define your table columns and other necessary attributes here
  • dbt Source Integration: A dbt_source_meta decorator was added to handle dbt sources. This is crucial for mocking raw data sources that are used in dbt projects, facilitating the testing of dbt transformations from these sources.
@dbt_source_meta(source_name="your_source_name", table_name="your_source_table")
class YourDBTSourceTable(BigQueryMockTable):
    # Define your table columns and other necessary attributes here
  • dbt Seed Handling: The addition of a dbt_seed_meta decorator enables SQLMock to integrate with dbt seed files. Seeds in dbt are static data sets, and this functionality allows for their representation and manipulation within SQLMock.
@dbt_seed_meta(seed_name="your_dbt_seed_name")
class YourDBTSeedTable(BigQueryMockTable):
    # Define your table columns and other necessary attributes here

Introduced a SQLMockConfig class that can be used to globally set the path to the dbt manifest file, e.g.:

SQLMockConfig.set_dbt_manifest_path("./tests/resources/dbt/dbt_manifest.json")

What to look for

Make sure to take a close look at:

  • The documentation -> is it understandable
  • Challenge the approach with the decorators. Can you think of something better?
  • Code quality and correctness

@Somtom Somtom self-assigned this Dec 29, 2023
@Somtom Somtom merged commit b1c923d into main Dec 30, 2023
@Somtom Somtom deleted the dbt-support branch December 30, 2023 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants