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

[CT-1725] [CT-1722] [CT-1721] [Bug] 1.4.0-b1 Bigquery Incremental Query breaks when ending in comment #6485

Closed
2 tasks done
thejens opened this issue Dec 23, 2022 · 2 comments
Labels
bug Something isn't working regression Team:Adapters Issues designated for the adapter area of the code
Milestone

Comments

@thejens
Copy link

thejens commented Dec 23, 2022

Is this a new bug in dbt-core?

  • I believe this is a new bug in dbt-core
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

In 1.4.0-b1 when running:

test_model.sql:

{{- config(materialized='incremental') -}}
SELECT
  '123' AS test
-- Test

The compiled query becomes:


        
    

    

    merge into `[REDACTED]` as DBT_INTERNAL_DEST
        using (SELECT
  '123' AS test
-- Test) as DBT_INTERNAL_SOURCE
        on (FALSE)

    

    when not matched then insert
        (`test`)
    values
        (`test`)


    

As you see, the --Test comment row also comments out parts of the merge statement, this happens with or without a trailing newline after the final comment

Expected Behavior

The newlines are persisted and the commend won't influence the wrapping merge statement

Steps To Reproduce

Create a .sql file ending with a comment, configure it to incremental, run twice to trigger an incremental run

Relevant log output

`Syntax error: Expected ")" but got keyword ON at [12:9]`

Environment

- OS: Debian GNU/Linux 11 (bullseye)
- Python: 3.11.1
- dbt: 1.4.0b1

Which database adapter are you using with dbt?

No response

Additional Context

No response

@thejens thejens added bug Something isn't working triage labels Dec 23, 2022
@github-actions github-actions bot changed the title [Bug] 1.4.0-b1 Bigquery Incremental Query breaks when ending in comment [CT-1721] [Bug] 1.4.0-b1 Bigquery Incremental Query breaks when ending in comment Dec 23, 2022
@dbeatty10 dbeatty10 transferred this issue from dbt-labs/dbt-core Dec 23, 2022
@github-actions github-actions bot changed the title [CT-1721] [Bug] 1.4.0-b1 Bigquery Incremental Query breaks when ending in comment [CT-1722] [CT-1721] [Bug] 1.4.0-b1 Bigquery Incremental Query breaks when ending in comment Dec 23, 2022
@dbeatty10
Copy link
Contributor

Thanks for reporting this @thejens !

This looks like an issue with Jinja whitespace Control. i.e., there's probably {%- instead of {% somewhere (and/or -%} instead of -%}).

I was able to reproduce the same thing as you in dbt-bigquery.

Suspected PRs

dbt-bigquery has had a few PRs recently related to incremental materializations, and I'm wondering if it might have been introduced in one of them:

The last one has an associated PR in dbt-core:

Originally assuming that the bug was introduced in dbt-bigquery, I moved the issue into that repo. But we haven't yet ruled out that the bug is in dbt-core, so I'll transfer the issue back for now.

How we should test for this

  • We should add a comment to the end of incremental models in integration tests to catch any regressions in the future

@dbeatty10 dbeatty10 transferred this issue from dbt-labs/dbt-bigquery Dec 23, 2022
@dbeatty10 dbeatty10 added the Team:Adapters Issues designated for the adapter area of the code label Dec 23, 2022
@github-actions github-actions bot changed the title [CT-1722] [CT-1721] [Bug] 1.4.0-b1 Bigquery Incremental Query breaks when ending in comment [CT-1725] [CT-1722] [CT-1721] [Bug] 1.4.0-b1 Bigquery Incremental Query breaks when ending in comment Dec 23, 2022
@dbeatty10 dbeatty10 removed the triage label Dec 23, 2022
@jtcohen6 jtcohen6 added this to the v1.4 milestone Jan 2, 2023
@leahwicz
Copy link
Contributor

Closed with this fix dbt-labs/dbt-bigquery#458

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working regression Team:Adapters Issues designated for the adapter area of the code
Projects
None yet
Development

No branches or pull requests

4 participants