-
Notifications
You must be signed in to change notification settings - Fork 14k
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
fix(sqla): make text clause escaping optional #17641
Conversation
Codecov Report
@@ Coverage Diff @@
## master #17641 +/- ##
==========================================
- Coverage 68.75% 68.56% -0.19%
==========================================
Files 1595 1595
Lines 65184 65191 +7
Branches 6945 6945
==========================================
- Hits 44814 44697 -117
- Misses 18488 18612 +124
Partials 1882 1882
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
(cherry picked from commit b2ffa26)
🏷️ 2021.46 |
@villebro do you know if this pr is planned to be included in the next releases?, without this pr, filters that use DateTime columns are failing using aws athena as backend. Thank you. |
@joaomsan Yes, absolutely, it will be included in the 1.5 release |
SUMMARY
A recent PR #17419 enabled global escaping of the colon character in queries, as the majority of SQLAlchemy dialects support escaping the colon character (see #17098 why this is needed). Escaping has been verified to work correctly on Postgres, MySql, MSSQL, Sqlite, BigQuery, Druid, Hive and Redshift, so it appears safe to assume escaping is supported on the majority of dialects. However, PyAthena does not, and adds the escape character to the final query, which breaks any query containing a colon character.
To support literal colons in queries, but fix the regression for Athena, this PR adds a flag
allows_escaped_colons
toBaseEngineSpec
, which defaults toTrue
, and is set toFalse
inPyAthenaSpec
. Relevant unit tests are added to theBaseEngineSpec
andAthenaEngineSpec
. In addition, all athena integration tests are converted to unit tests in pytest format.BEFORE
Currently adding a virtual table with the query
select '123:456' as test_str
and then adding a Custom SQL querytest_str = '123:456'
generates the following query on Athena (notice the backslash before the colon characters):For comparison, the same virtual table + filter produces the following on Postgres + all other tested databases:
TESTING INSTRUCTIONS
select '123:456' as test_str
referencing an Athena databasetest_str = '123:456'
ADDITIONAL INFORMATION