Skip to content

Conversation

@Somtom
Copy link
Collaborator

@Somtom Somtom commented Jan 19, 2024

Problem Context

We currently cannot mock CTEs which creates issues with dbt ephemeral models.
Being able to mock CTEs also allows us to create even more granular unit tests

What changed

Added functionality to mock CTEs

Take an example:
Now you can mock only cte_1 without the need of mocking some_table and another_table:

        @table_meta(table_ref="cte_1")
        class Cte1Mock(BaseTableMock):
            pass

        query = """
        WITH cte_1 AS (
            SELECT * 
            FROM some_table
           LEFT JOIN another_table USING(id)
        )

        SELECT * FROM cte_1
        """

@Somtom Somtom requested a review from mcnick January 19, 2024 16:18
@Somtom Somtom changed the base branch from main to v6-release January 19, 2024 16:19
@Somtom Somtom merged commit 4fbd039 into v6-release Jan 22, 2024
@Somtom Somtom deleted the allow-cte-mocks branch January 22, 2024 11:22
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.

3 participants