Skip to content

Conversation

@yaooqinn
Copy link
Member

What changes were proposed in this pull request?

As we support multiple catalogs with DataSourceV2, we may need the CURRENT_CATALOG value expression from the SQL standard.

CURRENT_CATALOG is a general value specification in the SQL Standard, described as:

The value specified by CURRENT_CATALOG is the character string that represents the current default catalog name.

Why are the changes needed?

improve catalog v2 with ANSI SQL standard.

Does this PR introduce any user-facing change?

yes, add a new function current_catalog() to point the current active catalog

How was this patch tested?

add ut

@SparkQA
Copy link

SparkQA commented Dec 25, 2019

Test build #115761 has finished for PR 27006 at commit 180fe0a.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • case class CurrentCatalog() extends LeafExpression with Unevaluable
  • case class GetCurrentCatalog(catalogManager: CatalogManager) extends Rule[LogicalPlan]

@yaooqinn
Copy link
Member Author

retest this please

@SparkQA
Copy link

SparkQA commented Dec 25, 2019

Test build #115763 has finished for PR 27006 at commit 180fe0a.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • case class CurrentCatalog() extends LeafExpression with Unevaluable
  • case class GetCurrentCatalog(catalogManager: CatalogManager) extends Rule[LogicalPlan]

@HyukjinKwon
Copy link
Member

retest this please

@SparkQA
Copy link

SparkQA commented Dec 27, 2019

Test build #115840 has finished for PR 27006 at commit 180fe0a.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • case class CurrentCatalog() extends LeafExpression with Unevaluable
  • case class GetCurrentCatalog(catalogManager: CatalogManager) extends Rule[LogicalPlan]

@yaooqinn
Copy link
Member Author

retest this please, and thanks @HyukjinKwon

@SparkQA
Copy link

SparkQA commented Dec 27, 2019

Test build #115850 has finished for PR 27006 at commit 180fe0a.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • case class CurrentCatalog() extends LeafExpression with Unevaluable
  • case class GetCurrentCatalog(catalogManager: CatalogManager) extends Rule[LogicalPlan]

@SparkQA
Copy link

SparkQA commented Apr 27, 2020

Test build #121870 has finished for PR 27006 at commit 180fe0a.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • case class CurrentCatalog() extends LeafExpression with Unevaluable
  • case class GetCurrentCatalog(catalogManager: CatalogManager) extends Rule[LogicalPlan]

@HyukjinKwon
Copy link
Member

cc @cloud-fan FYI

@cloud-fan
Copy link
Contributor

retest this please

ReplaceExpressions,
ComputeCurrentTime,
GetCurrentDatabase(catalogManager),
GetCurrentCatalog(catalogManager),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we merge the above 2 rules into one?

@SparkQA
Copy link

SparkQA commented May 20, 2020

Test build #122878 has finished for PR 27006 at commit 180fe0a.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • case class CurrentCatalog() extends LeafExpression with Unevaluable
  • case class GetCurrentCatalog(catalogManager: CatalogManager) extends Rule[LogicalPlan]

@SparkQA
Copy link

SparkQA commented May 20, 2020

Test build #122889 has finished for PR 27006 at commit c7b82d5.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • case class GetCurrentDatabaseOrCatalog(catalogManager: CatalogManager) extends Rule[LogicalPlan]

> SELECT _FUNC_();
spark_catalog
""",
since = "3.0.0")
Copy link
Contributor

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

* 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] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetCurrentDatebaseAndCatalog


plan transformAllExpressions {
case CurrentDatabase() =>
val currentNamespace = catalogManager.currentNamespace.quoted
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's better to get the value before transformAllExpressions

val currentNamespace = catalogManager.currentNamespace.quoted
Literal.create(currentNamespace, StringType)
case CurrentCatalog() =>
val currentCatalog = catalogManager.currentCatalog.name()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

select typeof(array(1, 2)), typeof(map(1, 2)), typeof(named_struct('a', 1, 'b', 'spark'));

-- get current_catalog
select current_catalog();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have a sql testing file for current_database?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checked and not found

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about we add a current_database_catalog.sql and test both of them there?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am okay with it.

@SparkQA
Copy link

SparkQA commented May 22, 2020

Test build #122991 has finished for PR 27006 at commit 2c32f98.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • case class GetCurrentDatabaseAndCatalog(catalogManager: CatalogManager) extends Rule[LogicalPlan]

@cloud-fan
Copy link
Contributor

sorry it conflicts, can you fix it?

@SparkQA
Copy link

SparkQA commented May 22, 2020

Test build #122996 has finished for PR 27006 at commit fa520d1.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented May 22, 2020

Test build #123007 has finished for PR 27006 at commit f951b5e.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@yaooqinn
Copy link
Member Author

retest this please

1 similar comment
@yaooqinn
Copy link
Member Author

retest this please

@SparkQA
Copy link

SparkQA commented May 23, 2020

Test build #123024 has finished for PR 27006 at commit f951b5e.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@yaooqinn
Copy link
Member Author

retest this please

@SparkQA
Copy link

SparkQA commented May 23, 2020

Test build #123032 has finished for PR 27006 at commit f951b5e.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@cloud-fan
Copy link
Contributor

thanks, merging to master!

@cloud-fan cloud-fan closed this in 0df8dd6 May 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants