-
Notifications
You must be signed in to change notification settings - Fork 1k
feat(postgres,trino): added support for current_catalog #6492
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
base: main
Are you sure you want to change the base?
feat(postgres,trino): added support for current_catalog #6492
Conversation
VaggelisD
left a comment
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.
Thank you for the PR!
This is also supported on Databricks, lets ensure that we always check all the first-class dialects (Snowflake, BQ, Spark/DBX, DuckDB, Redshift etc), even at a documentation level if you don't have engine access.
|
|
||
|
|
||
| class CurrentCatalog(Func): | ||
| arg_types = {"this": 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.
CURRENT_CATALOG does not take an argument in any engine that supports it, right? So we can set arg_types = {}, as is the case with CurrentRegion too right below etc.
| def currentcatalog_sql(self, expression: exp.CurrentCatalog) -> str: | ||
| this = expression.this | ||
| return self.func("CURRENT_CATALOG", this) if this else "CURRENT_CATALOG" |
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.
Ditto, this is deadcode given that there'll never be args args so this will always be None.
We can do the following:
- To cover Trino and Postgres (no paren case), we can inline the generation in
generator.py::TRANSFORMSto be simplyexp.CurrentCatalog: lambda *_: "CURRENT_CATALOG", - To cover Databricks (func case), we can add a generation in
databricks.py::TRANSFORMSthat instead returnsCURRENT_CATALOG()
Lets do another pass to check that no other first class dialects allow CURRENT_CATALOG
| def test_current_catalog(self): | ||
| self.validate_identity("SELECT CURRENT_CATALOG") |
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.
We don't really need a new function entry for such tests, lets move it to test_postgres
| def test_current_catalog(self): | ||
| self.validate_identity("SELECT CURRENT_CATALOG") |
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.
Ditto, lets move it to test_trino
Docs:
Trino
Postgres
The following dialects do not support this:
✅ Tested on the platform