Skip to content

Conversation

@AbhishekASLK
Copy link
Contributor

Docs:
Trino
Postgres

The following dialects do not support this:

SELECT CURRENT_CATALOG;
  • ClickHouse
  • MySQL
  • Oracle
  • MariaDB
  • SingleStore

✅ Tested on the platform

Copy link
Collaborator

@VaggelisD VaggelisD left a 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}
Copy link
Collaborator

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.

Comment on lines +130 to +132
def currentcatalog_sql(self, expression: exp.CurrentCatalog) -> str:
this = expression.this
return self.func("CURRENT_CATALOG", this) if this else "CURRENT_CATALOG"
Copy link
Collaborator

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::TRANSFORMS to be simply exp.CurrentCatalog: lambda *_: "CURRENT_CATALOG",
  • To cover Databricks (func case), we can add a generation in databricks.py::TRANSFORMS that instead returns CURRENT_CATALOG()

Lets do another pass to check that no other first class dialects allow CURRENT_CATALOG

Comment on lines +1683 to +1684
def test_current_catalog(self):
self.validate_identity("SELECT CURRENT_CATALOG")
Copy link
Collaborator

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

Comment on lines +163 to +164
def test_current_catalog(self):
self.validate_identity("SELECT CURRENT_CATALOG")
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants