Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dbt support #26

Merged
merged 1 commit into from
Dec 30, 2023
Merged

Add dbt support #26

merged 1 commit into from
Dec 30, 2023

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
3 checks passed
@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.

1 participant