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

compare_queries does not work on Dremio #84

Closed
igor-lobanov-maersk opened this issue Oct 18, 2023 · 3 comments
Closed

compare_queries does not work on Dremio #84

igor-lobanov-maersk opened this issue Oct 18, 2023 · 3 comments
Labels
bug Something isn't working Stale triage

Comments

@igor-lobanov-maersk
Copy link

igor-lobanov-maersk commented Oct 18, 2023

Describe the bug

compare_queries marco uses "count" as a field name in summary_stats CTE without escaping, which is not allowed in Dremio SQL.

Steps to reproduce

In Dremio environment, create the following model:

-- File regression_test.sql
{% set old_query %}
select 1 as a
union all
select 2 as a
{% endset %}


{% set new_query %}
select 1 as a
union all
select 2 as a
{% endset %}


{{
    audit_helper.compare_queries(
        a_query=old_query,
        b_query=new_query,
        primary_key="a"
    )
}}

Run audit model: dbt run -m regression_test

Expected results

Model runs.

Actual results

Model run fails, see log below.

Additional context

I can go into the compiled model file in "target" directory and manually quote "count" in summary_stats CTE and at the end where it is used. If I then copy and paste the SQL into Dremio console, it runs as works as intended.

Screenshots and log output

17:35:50  1 of 1 START sql view model regression_test .................................... [RUN]
17:35:50  1 of 1 ERROR creating sql view model regression_test ........................... [ERROR in 0.39s]
17:35:50  
17:35:50  Finished running 1 view model in 0 hours 0 minutes and 2.60 seconds (2.60s).
17:35:50  
17:35:50  Completed with 1 error and 0 warnings:
17:35:50  
17:35:50  Runtime Error in model regression_test (models/regression/regression_test.sql)
17:35:50    ERROR: Encountered "as count" at line 102, column 18.
17:35:50    Was expecting one of:
17:35:50        ")" ...
17:35:50        "ORDER" ...
17:35:50        "LIMIT" ...
17:35:50        "OFFSET" ...
17:35:50        "FETCH" ...
17:35:50        "FROM" ...
17:35:50        "," ...
17:35:50        "AS" <IDENTIFIER> ...
<skipped long list of options, clearly Dremio stumbles on "as count">
17:35:50  
17:35:50  Done. PASS=0 WARN=0 ERROR=1 SKIP=0 TOTAL=1

System information

packages:
  - package: dbt-labs/dbt_utils
    version: 1.1.1
  - package: dbt-labs/audit_helper
    version: 0.9.0

Which database are you using dbt with?
Dremio.

The output of dbt --version:

Core:
  - installed: 1.5.8
  - latest:    1.6.6 - Update available!

  Your version of dbt-core is out of date!
  You can find instructions for upgrading here:
  https://docs.getdbt.com/docs/installation

Plugins:
  - dremio: 1.5.0 - Up to date!

The operating system you're using:
Debian inside DevContainer via VSCode.

The output of python --version:
Python 3.11.6

Are you interested in contributing the fix?

PR provided.

@igor-lobanov-maersk igor-lobanov-maersk added bug Something isn't working triage labels Oct 18, 2023
igor-lobanov-maersk added a commit to igor-lobanov-maersk/dbt-audit-helper that referenced this issue Oct 18, 2023
Escaping "count" field using double quotes, which I believe is SQL standard.
@igor-lobanov-maersk
Copy link
Author

igor-lobanov-maersk commented Oct 26, 2023

I'm struggling with a fix that does not break all other supported SQL dialects. In #85 I tried using {{ adapter.quote('count') }}, but it fails Snowflake CI tests here: https://app.circleci.com/pipelines/github/dbt-labs/dbt-audit-helper/352/workflows/86a40594-8964-413c-bb92-4cc48212c4d2/jobs/346

Any help would be appreciated.

Copy link

This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days.

@github-actions github-actions bot added the Stale label Apr 24, 2024
Copy link

github-actions bot commented May 1, 2024

Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest. Just add a comment to notify the maintainers.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Stale triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant