calogica / dbt-expectations

Port(ish) of Great Expectations to dbt test macros
https://calogica.github.io/dbt-expectations/
Apache License 2.0
1.06k stars 128 forks source link

Escaping single quotes in column names #240

Closed RobbertDM closed 1 year ago

RobbertDM commented 1 year ago

There's probably other places where this applies I've had this problem with trino, not sure if this applies to different DBs (do other DBs even allow for column names to have single quotes?) If this needs to be supported, probably a good idea to include some crazy column names in the tests

clausherther commented 1 year ago

Thanks @RobbertDM for this PR. I'm not sure I've encountered this issue, not sure how one even goes about adding single quotes in a column name? Let me think about if this needs to be done anywhere else and if so, we'd need to add a test before merging. Is this a blocker for you?

RobbertDM commented 1 year ago

Yeah me neither, in Trino you can just alter table x add column "'" varchar and that'll work and result in a column name of '. A lot of tables on our platform have single quotes in them. For e.g. postgres you're not allowed to do that: https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS

Not a blocker at all, I think we're going to write our own tests anyways.

This PR is probably not even a good idea. People shouldn't name their columns with quotes in them 😂

clausherther commented 1 year ago

Ok, got it. Feel free to open an issue if this continues to be an issue for you.