-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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-2539] [Bug] CTE SQL Injection in Postgres #7521
Comments
Thanks for reporting this @LouisAuneau ! On first blush, the double Which version of |
Thanks for you quick reply. Exaclty, sqlparse 0.4.4 is installed. Should I downgrade to 0.4.3 as suggested in mentioned issue ? |
Sure thing @LouisAuneau 👍 Yep, could you downgrade to sqlparse==0.4.3 and let us how that goes? |
Looks it solved our issue! Thanks a lot for your support ! |
You're welcome @LouisAuneau ! |
Is this a new bug in dbt-core?
Current Behavior
We run models using dagster hosted in kubernetes (each run is therefore running in a fresh identical pod). Those model perform transformations on PostgreSQL tables.
Since upgrading to PostgreSQL 14 (from 11), our model runs fails with a Database Error around 10 to 20% of the time. I wasn't able to draw any correlation between the data that is transformed and the fails (our data mostly changes at daytime and the fails occur day and night).
The model structure looks like this:
The error seems to be related to the SQL injection and CTE. Indeed, when succeeding, the compiled SQL looks like this:
When failing, the compiled SQL looks like this:
And therefore I get a
Postgres error: syntax error at or near \"WITH\"\n
.To be very honest the only way I could reproduce was just to repeat the
dbt run
until it fails with adbt clean
in between each run.Expected Behavior
Always generate the main model CTE with the upstream ephemeral CTE.
Steps To Reproduce
Relevant log output
Environment
Which database adapter are you using with dbt?
postgres
Additional Context
No response
The text was updated successfully, but these errors were encountered: