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

[Bug] Semicolon breaks in create view #11328

Open
2 tasks done
ben-youngblut opened this issue Feb 19, 2025 · 0 comments
Open
2 tasks done

[Bug] Semicolon breaks in create view #11328

ben-youngblut opened this issue Feb 19, 2025 · 0 comments
Labels
bug Something isn't working triage

Comments

@ben-youngblut
Copy link

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

I have a complex view that has a string with an escaped '\' and then another string with a simicolon ';'.
It compiles fine and the created SQL looks fine, but when dbt run on that model it fails with the following error.

18:56:58  Running with dbt=1.9.2
18:56:58  Registered adapter: redshift=1.9.0
18:56:58  Unable to do partial parsing because saved manifest not found. Starting full parse.
18:56:59  Found 1 model, 502 macros
18:56:59  
18:56:59  Concurrency: 1 threads (target='dev')
18:56:59  
18:57:04  1 of 1 START sql view model public_public.temp ................................. [RUN]
18:57:05  1 of 1 ERROR creating sql view model public_public.temp ........................ [ERROR in 0.97s]
18:57:05  
18:57:05  Finished running 1 view model in 0 hours 0 minutes and 6.02 seconds (6.02s).
18:57:05  
18:57:05  Completed with 1 error, 0 partial successes, and 0 warnings:
18:57:05  
18:57:05    Database Error in model temp (models/example/temp.sql)
  unterminated quoted string at or near "'x;" in context "t NOT IN ('x;", at line 36, column 25
  compiled code at target/run/test/models/example/temp.sql

in the logs I can see that the query being sent ends at the semicolon... but if I take the code that is generated from the compile step and wrap it in the create view
create view "dwh"."public_public"."temp__dbt_tmp" as ( <OUTPUT> ) it runs fine in redshift... so I have to assume that dbt is not sending the full query to redshift.

Expected Behavior

Since the view compiles fine I just expected that the view should be created just fine.

Steps To Reproduce

  1. created brand new dbt env (installed dbt-code and dbt-redshift)
    then ran the dbt init command
    then copied the following temp.sql file into the models folder
    temp.sql
{{ config(materialized='view') }}

WITH x AS (
  SELECT
     CASE
        WHEN TRUE
        THEN NULL
     END AS x,
     CASE
        WHEN TRUE
        THEN NULL
     END AS y,
     CASE
        WHEN TRUE
        THEN NULL
     END AS z,
     CASE
        WHEN TRUE
        THEN ''
     END AS t
),
y AS (
  SELECT 
    (
        SELECT ''
        FROM x
        WHERE t NOT IN ('v\\')
    ) AS z,
    (
        SELECT ''
        FROM x
        WHERE t NOT IN ('x;x')
    ) AS d
  FROM x
)
SELECT *
FROM y
  1. nothing custom
dbt run  --select temp

Relevant log output

�[0m12:57:04.869019 [debug] [Thread-1 (]: Using redshift connection "model.test.temp"
�[0m12:57:04.869295 [debug] [Thread-1 (]: On model.test.temp: /* {"app": "dbt", "dbt_version": "1.9.2", "profile_name": "test", "target_name": "dev", "node_id": "model.test.temp"} */


  create view "dwh"."public_public"."temp__dbt_tmp" as (
    

WITH x AS (
  SELECT
     CASE
        WHEN TRUE
        THEN NULL
     END AS x,
     CASE
        WHEN TRUE
        THEN NULL
     END AS y,
     CASE
        WHEN TRUE
        THEN NULL
     END AS z,
     CASE
        WHEN TRUE
        THEN ''
     END AS t
),
y AS (
  SELECT 
    (
        SELECT ''
        FROM x
        WHERE t NOT IN ('v\\')
    ) AS z,
    (
        SELECT ''
        FROM x
        WHERE t NOT IN ('x;
�[0m12:57:04.970751 [debug] [Thread-1 (]: Redshift adapter: Redshift error: unterminated quoted string at or near "'x;" in context "t NOT IN ('x;", at line 36, column 25
�[0m12:57:04.971205 [debug] [Thread-1 (]: On model.test.temp: ROLLBACK

Environment

- OS:
- Python: 3.11.11
- dbt: 1.9.2

Which database adapter are you using with dbt?

redshift

Additional Context

No response

@ben-youngblut ben-youngblut added bug Something isn't working triage labels Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

No branches or pull requests

1 participant