-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-30352][SQL] DataSourceV2: Add CURRENT_CATALOG function #27006
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
Changes from 3 commits
180fe0a
dd9f417
c7b82d5
2c32f98
f4f8fbe
fa520d1
f951b5e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,15 +91,21 @@ object ComputeCurrentTime extends Rule[LogicalPlan] { | |
| } | ||
|
|
||
|
|
||
| /** Replaces the expression of CurrentDatabase with the current database name. */ | ||
| case class GetCurrentDatabase(catalogManager: CatalogManager) extends Rule[LogicalPlan] { | ||
| /** | ||
| * Replaces the expression of CurrentDatabase with the current database name. | ||
| * Replaces the expression of CurrentCatalog with the current catalog name. | ||
| */ | ||
| case class GetCurrentDatabaseOrCatalog(catalogManager: CatalogManager) extends Rule[LogicalPlan] { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| def apply(plan: LogicalPlan): LogicalPlan = { | ||
| import org.apache.spark.sql.connector.catalog.CatalogV2Implicits._ | ||
| val currentNamespace = catalogManager.currentNamespace.quoted | ||
|
|
||
| plan transformAllExpressions { | ||
| case CurrentDatabase() => | ||
| val currentNamespace = catalogManager.currentNamespace.quoted | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's better to get the value before |
||
| Literal.create(currentNamespace, StringType) | ||
| case CurrentCatalog() => | ||
| val currentCatalog = catalogManager.currentCatalog.name() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
| Literal.create(currentCatalog, StringType) | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,3 +8,6 @@ select typeof(cast(1.0 as float)), typeof(1.0D), typeof(1.2); | |
| select typeof(date '1986-05-23'), typeof(timestamp '1986-05-23'), typeof(interval '23 days'); | ||
| select typeof(x'ABCD'), typeof('SPARK'); | ||
| select typeof(array(1, 2)), typeof(map(1, 2)), typeof(named_struct('a', 1, 'b', 'spark')); | ||
|
|
||
| -- get current_catalog | ||
| select current_catalog(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we have a sql testing file for
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. checked and not found
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how about we add a
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am okay with it. |
||
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.
it's too late for 3.0 now. let's change it to
3.1.0