-
Notifications
You must be signed in to change notification settings - Fork 505
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
Column names with spaces #782
Comments
Hey @RobbertDM, You can resolve this at your query's level by including more quotes:
The first set of quotes will be consumed by the Jinja parser but the second set will pass through correctly. |
Thanks @joellabes , that could work in some cases. Tbh it feels a bit like a workaround. When getting columns from
I would probably need to do something like
To map those columns to their quoted equivalent, right? If we could add that |
Something like Modifying To become |
Hey Joel,
|
hmm, i might be able to help out here. Might take a while thought. If its alright with you @joellabes , maybe you can assign this to me? |
Hi Guys, I am a newbie to DBT. @RobbertDM why can't we use dbt_utils.slugify on top of the column names which have spaces and replace them with underscore something like this Everyone please correct me If I am wrong. |
Hey @NagarajNune, say you indeed have a table with one column When executing on your database, the above would throw something along the lines of |
Yes, this is correct, but in our project normally we will replace all spaces and special characters in column names while reading them from database itself. Example: we will compile it in the following way
I have taken this a reference with respect to database structure we have in our current project in snowflake. |
In that case, indeed, |
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. |
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. |
Describe the bug
I have some column names with spaces in them.
I use
which compiles to
Which is not valid SQL for my database.
Steps to reproduce
Run
generate_surrogate_key
on a column name that contains spaces.Expected results
Working SQL
Actual results
SQL error
Screenshots and log output
System information
The contents of your
packages.yml
file:Which database are you using dbt with?
The output of
dbt --version
:Additional context
I think we can add some
"
quotes here, but I'm not sure if that would break other databases:https://github.com/dbt-labs/dbt-utils/blob/main/macros/sql/generate_surrogate_key.sql#L18
Maybe it's also a possibility to use
{{ adapter.quote(column) }}
Are you interested in contributing the fix?
Time limitations :(
The text was updated successfully, but these errors were encountered: