-
Notifications
You must be signed in to change notification settings - Fork 80
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
Fixed escaping SQL object names #836
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #836 +/- ##
==========================================
+ Coverage 85.61% 85.66% +0.05%
==========================================
Files 41 42 +1
Lines 5212 5232 +20
Branches 950 953 +3
==========================================
+ Hits 4462 4482 +20
Misses 536 536
Partials 214 214 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work!
Please consider testing unicode, kanji (Multi-language support, and embedded space chars).
assert "`a-b`.`c`.`d`" == cb.escape("a-b.c.d", False) | ||
assert "`a`.`b-c`.`d`" == cb.escape("a.b-c.d", False) | ||
assert "`a`.`b`.`c-d`" == cb.escape("a.b.c-d", False) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing!!!
Please consider testing unicode, kanji, embedded space characters.
This documentation isn't much help... https://docs.databricks.com/en/sql/language-manual/sql-ref-names.html#names
@@ -231,6 +233,28 @@ def _full_name(self) -> str: | |||
""" | |||
return f"{self._catalog}.{self._schema}.{self._table}" | |||
|
|||
@staticmethod |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create a function of it and call it escape_sql_identifier
, it doesn't really belong to this class, as it turns out from number of CrawlerBase.
prefixes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that makes sense, I was about to ask that. Where do we put functions? A new Python source in the root of the project? Or some utils
subdir?
I have a pattern like this: |
How would you handle this: |
5f3c84a
to
7ecd12a
Compare
Thanks. The patterns I'm working with only has dots in the table name, although I think we can escape all of them (maybe not in the test, but in the actual code). It's true that DB does not allow for dots, but other catalogs do; I'm facing this issue as I'm crawling an external hive metastore which allows for dots. Thank you! |
* Added `databricks labs ucx alias` command to create a view of tables from one schema/catalog in another schema/catalog ([#837](#837)). * Added `databricks labs ucx save-aws-iam-profiles` command to scan instance profiles identify AWS S3 access and save a CSV with permissions ([#817](#817)). * Added total view counts in the assessment dashboard ([#834](#834)). * Cleaned up `assess_jobs` and `assess_clusters` tasks in the `assessment` workflow to improve testing and reduce redundancy.([#825](#825)). * Added documentation for the assessment report ([#806](#806)). * Fixed escaping for SQL object names ([#836](#836)). Dependency updates: * Updated databricks-sdk requirement from ~=0.17.0 to ~=0.18.0 ([#832](#832)).
* Added `databricks labs ucx alias` command to create a view of tables from one schema/catalog in another schema/catalog ([#837](#837)). * Added `databricks labs ucx save-aws-iam-profiles` command to scan instance profiles identify AWS S3 access and save a CSV with permissions ([#817](#817)). * Added total view counts in the assessment dashboard ([#834](#834)). * Cleaned up `assess_jobs` and `assess_clusters` tasks in the `assessment` workflow to improve testing and reduce redundancy.([#825](#825)). * Added documentation for the assessment report ([#806](#806)). * Fixed escaping for SQL object names ([#836](#836)). Dependency updates: * Updated databricks-sdk requirement from ~=0.17.0 to ~=0.18.0 ([#832](#832)).
* Added `databricks labs ucx alias` command to create a view of tables from one schema/catalog in another schema/catalog ([#837](#837)). * Added `databricks labs ucx save-aws-iam-profiles` command to scan instance profiles identify AWS S3 access and save a CSV with permissions ([#817](#817)). * Added total view counts in the assessment dashboard ([#834](#834)). * Cleaned up `assess_jobs` and `assess_clusters` tasks in the `assessment` workflow to improve testing and reduce redundancy.([#825](#825)). * Added documentation for the assessment report ([#806](#806)). * Fixed escaping for SQL object names ([#836](#836)). Dependency updates: * Updated databricks-sdk requirement from ~=0.17.0 to ~=0.18.0 ([#832](#832)).
Changes
Implements handling of special characters in SQL names. Optionally escapes the catalog, schema, or table names with backticks for SQL queries.
Linked issues
Resolves #833
Tests