dbt-labs / dbt-adapters

Apache License 2.0
17 stars 20 forks source link

[Bug] Fix scenarios where `--empty` flag pushes limit 0 into metadata queries #257

Closed mikealfare closed 2 weeks ago

mikealfare commented 2 weeks ago

resolves #213

Problem

We fixed dbt-snowflake when using --empty and running metadata queries.

Solution

Add the tests for that fix so other adapters can use it if necessary.

Implementation

  1. Merge this PR demonstrating that these tests work
  2. Move the bulk of this PR into dbt-tests-adapter (we`re here)
  3. Create a final PR that removes most of this and uses the dbt-tests-adapter tests

Checklist

github-actions[bot] commented 2 weeks ago

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

colin-rogers-dbt commented 2 weeks ago

Do we need to update this one too? https://github.com/dbt-labs/dbt-adapters/blob/bug/213-fix-empty-flag/dbt/include/global_project/macros/materializations/tests/where_subquery.sql#L9

mikealfare commented 2 weeks ago

Do we need to update this one too? https://github.com/dbt-labs/dbt-adapters/blob/bug/213-fix-empty-flag/dbt/include/global_project/macros/materializations/tests/where_subquery.sql#L9

I'm honestly not sure. Based on where this macro is, I assume it's used in the test materialization. However, I don't see where this macro is called. I looked in both dbt-adapters and dbt-snowflake and there's no reference outside of defining the macro. Either way, I think we'd want to limit the results here just like we would in other materializations. It also doesn't create invalid sql like it does in describe/show queries. I can add it if you feel otherwise, but I'm inclined to leave this as is.