You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been adding some integration tests to dbt-prql, and unfortunately it doesn't work with the dialects that use double-quotes.
That's because:
from in_process ={{ source('salesforce', 'in_process')}}
is first parsed to:
from "salesforce"."in_process"
...and then passed to the prql compiler. That's not valid PRQL. I had been expecting from in_process = {{ source('salesforce', 'in_process') }} to be passed to the prql compiler first — which is valid prql — and then for the compiled sql to be formatted by dbt1.
Some options for remedying it:
Ask people to use an s-string for these — i.e. s"{{ source('salesforce', 'in_process') }}" — and allow s-strings in from
Ask people to use backticks — i.e. `{{ source('salesforce', 'in_process') }}` — and adjust how we handle backticks such that `"foo"` compiles to "foo" rather than """foo""".
Currently we take the literal inside backticks, and then escape it, such that the DB receives the identifier within the backticks. That means it escapes the "s — as though we've called a column "foo", with the quotes.
I spent a lot of time trying to get dbt to pass the raw string to prql, and then parse the jinja after. But I couldn't manage a way, because we monkey patch into dbt's jinja, and jinja passes extensions an AST. Ofc if anyone has any ideas, then very open to exploring them.
The problem here is that DBT emits result of {{ }} as an SQL identifier, which is not the same as PRQL identifier.
Yes, well summarized
The ideal solution would be for DBT to emit a PRQL ident which would be salesforce.in_process.
I agree — though that would require a much bigger change. Either we need dbt to support PRQL (we're in discussions with them now), or we'd need to do very invasive monkeypatching, a whole extra level, and we're already quite extreme there...
Otherwise we could just not support postgres / redshift / snowflake until we're better integrated into dbt.. Maybe we work on increasing adoption in BQ first, before we sink more time into making it work with those.
If I remember correctly, we decided not to parse jinja expressions with PRQL and instead create a dbt plugin that would allow to run dbt first, resolve jinja expressions and only then run PRQL.
I've been adding some integration tests to dbt-prql, and unfortunately it doesn't work with the dialects that use double-quotes.
That's because:
is first parsed to:
...and then passed to the prql compiler. That's not valid PRQL. I had been expecting
from in_process = {{ source('salesforce', 'in_process') }}
to be passed to the prql compiler first — which is valid prql — and then for the compiled sql to be formatted by dbt1.Some options for remedying it:
s"{{ source('salesforce', 'in_process') }}"
— and allow s-strings infrom
`{{ source('salesforce', 'in_process') }}`
— and adjust how we handle backticks such that`"foo"`
compiles to"foo"
rather than"""foo"""
."
s — as though we've called a column"foo"
, with the quotes.I spent a lot of time trying to get dbt to pass the raw string to prql, and then parse the jinja after. But I couldn't manage a way, because we monkey patch into dbt's jinja, and jinja passes extensions an AST. Ofc if anyone has any ideas, then very open to exploring them.
Footnotes
With BQ, this is fine, since this is valid PRQL:
↩The text was updated successfully, but these errors were encountered: