Coder Social home page Coder Social logo

Comments (8)

graciegoheen avatar graciegoheen commented on July 18, 2024 1

We're going to call this out as a known limitation for the 1.8 release. But this is something we will revisit for 1.9 as an outcome of dbt-labs/dbt-core#8499

from dbt-bigquery.

HarlanH avatar HarlanH commented on July 18, 2024

recursive_cte.zip

ZIP file includes two SQL files and a YML file.

from dbt-bigquery.

graciegoheen avatar graciegoheen commented on July 18, 2024

Hey - thanks so much for opening! Since this is currently broken, we're going to remove that callout from our docs site. But I will sync with our engineers to see how we can fix this.

  • We should investigate if we can remove the outer select * from ( entirely.
  • We should implement this fix for all adapters that support recursive SQL

from dbt-bigquery.

graciegoheen avatar graciegoheen commented on July 18, 2024

Just adding the reproducible example Harlan shared.

I have a model I want to unit test:

# models/recursive_cte.sql

WITH RECURSIVE
asdf AS (
    SELECT *
    FROM {{ ref('recursive_cte_given') }}
)

SELECT *
FROM asdf

I add a unit test:

unit_tests:
  - name: test_recursive_cte
    model: recursive_cte
    given:
      - input: ref('recursive_cte_given')
        format: csv
        rows: |
          x
          1
    expect:
      format: csv
      rows: |
        x
        1

from dbt-bigquery.

MichelleArk avatar MichelleArk commented on July 18, 2024

It looks like WITH RECURSIVE is supported for most of the dbt Labs supported adapters:

from dbt-bigquery.

MichelleArk avatar MichelleArk commented on July 18, 2024

For implementation:

I'm not sure if it's possible to remove the select * but maintain the where false limit 0 filter. If we don't have the where false limit 0 filter, obtaining the column schema of the tested model isn't possible without actually running the query which could be costly...

from dbt-bigquery.

MichelleArk avatar MichelleArk commented on July 18, 2024

Additionally, we also expect to be able to wrap the user-provided sql in a subquery when constructing the statement that unions actual and expected results for comparison here.

It seems that being able to wrap the user-provided SQL in a subquery is an assumption held by the unit testing framework in multiple places currently.

from dbt-bigquery.

MichelleArk avatar MichelleArk commented on July 18, 2024

It looks like the dbt-unit-testing package also experiences this limitation, which is unsurprising given the CTE-based approach: EqualExperts/dbt-unit-testing#198

I think the only way to solve this generally is to use a seed-based strategy for ephemeral models, similar to what we'd need for being able to test incremental model upsert/merge logic: dbt-labs/dbt-core#8499

from dbt-bigquery.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.