You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/06/17 21:05:01 UTC
[GitHub] [spark] amaliujia opened a new pull request, #36904: [SPARK-39506] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
amaliujia opened a new pull request, #36904:
URL: https://github.com/apache/spark/pull/36904
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
4. Be sure to keep the PR description updated to reflect all changes.
5. Please write your PR title to summarize what this PR proposes.
6. If possible, provide a concise example to reproduce the issue for a faster review.
7. If you want to add a new configuration, please read the guideline first for naming configurations in
'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
8. If you want to add or modify an error type or message, please read the guideline first in
'core/src/main/resources/error/README.md'.
-->
### What changes were proposed in this pull request?
<!--
Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue.
If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
2. If you fix some SQL features, you can provide some references of other DBMSes.
3. If there is design documentation, please add the link.
4. If there is a discussion in the mailing list, please add the link.
-->
1. make CacheTable, isCached, UncacheTable be 3l namespace compatible.
2. add new API setCurrentCatalog, currentCatalog, listCatalogs which are useful for 3l namespace.
### Why are the changes needed?
<!--
Please clarify why the changes are needed. For instance,
1. If you propose a new API, clarify the use case for a new API.
3. If you fix a bug, you can clarify why it is a bug.
-->
This is a part of effort for 3l namespace work.
### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such as the documentation fix.
If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
If no, write 'No'.
-->
Yes. There are 3 new API added in this PR (setCurrentCatalog, currentCatalog, listCatalogs) and cacheTable, isCached, unCacheTable API will support 3l namespace.
### How was this patch tested?
<!--
If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why it was difficult to add.
If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
-->
UT
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on a diff in pull request #36904: [SPARK-39506][SQL] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #36904:
URL: https://github.com/apache/spark/pull/36904#discussion_r904481141
##########
sql/core/src/main/scala/org/apache/spark/sql/catalog/Catalog.scala:
##########
@@ -589,4 +589,25 @@ abstract class Catalog {
* @since 2.0.0
*/
def refreshByPath(path: String): Unit
+
+ /**
+ * Returns the current default catalog in this session.
+ *
+ * @since 3.4.0
+ */
+ def currentCatalog(): String
+
+ /**
+ * Sets the current default catalog in this session.
+ *
+ * @since 3.4.0
+ */
+ def setCurrentCatalog(catalogName: String): Unit
+
+ /**
+ * Returns a list of catalogs in this session.
Review Comment:
```suggestion
* Returns a list of catalogs available in this session.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] HyukjinKwon commented on a diff in pull request #36904: [SPARK-39506][SQL] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on code in PR #36904:
URL: https://github.com/apache/spark/pull/36904#discussion_r904453265
##########
sql/core/src/test/scala/org/apache/spark/sql/internal/CatalogSuite.scala:
##########
@@ -743,4 +722,30 @@ class CatalogSuite extends SharedSparkSession with AnalysisTest with BeforeAndAf
val catalogName2 = "catalog_not_exists"
assert(!spark.catalog.databaseExists(Array(catalogName2, dbName).mkString(".")))
}
+
+ test("three layer namespace compatibility - cache table, isCached and uncacheTable") {
Review Comment:
I would add a JIRA prefix here in the test title.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] HyukjinKwon commented on a diff in pull request #36904: [SPARK-39506][SQL] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on code in PR #36904:
URL: https://github.com/apache/spark/pull/36904#discussion_r904453265
##########
sql/core/src/test/scala/org/apache/spark/sql/internal/CatalogSuite.scala:
##########
@@ -743,4 +722,30 @@ class CatalogSuite extends SharedSparkSession with AnalysisTest with BeforeAndAf
val catalogName2 = "catalog_not_exists"
assert(!spark.catalog.databaseExists(Array(catalogName2, dbName).mkString(".")))
}
+
+ test("three layer namespace compatibility - cache table, isCached and uncacheTable") {
Review Comment:
I would add a JIRA prefix here in the test title. e.g., `"SPARK-39506: three ...`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on a diff in pull request #36904: [SPARK-39506][SQL] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #36904:
URL: https://github.com/apache/spark/pull/36904#discussion_r904460638
##########
sql/core/src/main/scala/org/apache/spark/sql/catalog/interface.scala:
##########
@@ -26,6 +26,22 @@ import org.apache.spark.sql.catalyst.DefinedByConstructorParams
// Note: all classes here are expected to be wrapped in Datasets and so must extend
// DefinedByConstructorParams for the catalog to be able to create encoders for them.
+/**
+ * A catalog in Spark, as returned by the `listCatalogs` method defined in [[Catalog]].
+ *
+ * @param name name of the catalog
+ * @since 3.2.0
+ */
+class CatalogMetadata(
+ val name: String)
Review Comment:
ah I see!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on a diff in pull request #36904: [SPARK-39506][SQL] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #36904:
URL: https://github.com/apache/spark/pull/36904#discussion_r903237659
##########
sql/core/src/main/scala/org/apache/spark/sql/catalog/interface.scala:
##########
@@ -26,6 +26,22 @@ import org.apache.spark.sql.catalyst.DefinedByConstructorParams
// Note: all classes here are expected to be wrapped in Datasets and so must extend
// DefinedByConstructorParams for the catalog to be able to create encoders for them.
+/**
+ * A catalog in Spark, as returned by the `listCatalogs` method defined in [[Catalog]].
+ *
+ * @param name name of the catalog
+ * @since 3.2.0
+ */
+class CatalogMetadata(
+ val name: String)
Review Comment:
ok let's keep it then, and add a `description` field so that it doesn't look so weird.
About the naming, how about just `Catalog`? to match `Database` and `Table` in this file.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on pull request #36904: [SPARK-39506][SQL] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on PR #36904:
URL: https://github.com/apache/spark/pull/36904#issuecomment-1165434596
The last commit only updates a comment, I'm merging it to master, thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] amaliujia commented on pull request #36904: [SPARK-39506][SQL] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
Posted by GitBox <gi...@apache.org>.
amaliujia commented on PR #36904:
URL: https://github.com/apache/spark/pull/36904#issuecomment-1165784876
@cloud-fan thank you!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] amaliujia commented on pull request #36904: [SPARK-39506][SQL] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
Posted by GitBox <gi...@apache.org>.
amaliujia commented on PR #36904:
URL: https://github.com/apache/spark/pull/36904#issuecomment-1163477190
Also I am seeing this
```
[info] spark-streaming-kinesis-asl: mimaPreviousArtifacts not set, not analyzing binary compatibility
[error] spark-sql: Failed binary compatibility check against org.apache.spark:spark-sql_2.12:3.2.0! Found 3 potential problems (filtered 602)
[error] * abstract method currentCatalog()java.lang.String in class org.apache.spark.sql.catalog.Catalog is present only in current version
[error] filter with: ProblemFilters.exclude[ReversedMissingMethodProblem]("org.apache.spark.sql.catalog.Catalog.currentCatalog")
[error] * abstract method setCurrentCatalog(java.lang.String)Unit in class org.apache.spark.sql.catalog.Catalog is present only in current version
[error] filter with: ProblemFilters.exclude[ReversedMissingMethodProblem]("org.apache.spark.sql.catalog.Catalog.setCurrentCatalog")
[error] * abstract method listCatalogs()org.apache.spark.sql.Dataset in class org.apache.spark.sql.catalog.Catalog is present only in current version
[error] filter with: ProblemFilters.exclude[ReversedMissingMethodProblem]("org.apache.spark.sql.catalog.Catalog.listCatalogs")
```
Any idea how to make the new API pass such API compatibility check?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan closed pull request #36904: [SPARK-39506][SQL] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
Posted by GitBox <gi...@apache.org>.
cloud-fan closed pull request #36904: [SPARK-39506][SQL] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
URL: https://github.com/apache/spark/pull/36904
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on a diff in pull request #36904: [SPARK-39506][SQL] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #36904:
URL: https://github.com/apache/spark/pull/36904#discussion_r904480555
##########
sql/core/src/main/scala/org/apache/spark/sql/catalog/Catalog.scala:
##########
@@ -589,4 +589,25 @@ abstract class Catalog {
* @since 2.0.0
*/
def refreshByPath(path: String): Unit
+
+ /**
+ * Returns the current default catalog in this session.
Review Comment:
```suggestion
* Returns the current catalog in this session.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] HyukjinKwon commented on a diff in pull request #36904: [SPARK-39506][SQL] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on code in PR #36904:
URL: https://github.com/apache/spark/pull/36904#discussion_r904452971
##########
sql/core/src/main/scala/org/apache/spark/sql/catalog/interface.scala:
##########
@@ -26,6 +26,24 @@ import org.apache.spark.sql.catalyst.DefinedByConstructorParams
// Note: all classes here are expected to be wrapped in Datasets and so must extend
// DefinedByConstructorParams for the catalog to be able to create encoders for them.
+/**
+ * A catalog in Spark, as returned by the `listCatalogs` method defined in [[Catalog]].
+ *
+ * @param name name of the catalog
+ * @since 3.4.0
+ */
+class CatalogMetadata(
Review Comment:
Would have to be a case class.
##########
sql/core/src/main/scala/org/apache/spark/sql/catalog/interface.scala:
##########
@@ -26,6 +26,24 @@ import org.apache.spark.sql.catalyst.DefinedByConstructorParams
// Note: all classes here are expected to be wrapped in Datasets and so must extend
// DefinedByConstructorParams for the catalog to be able to create encoders for them.
+/**
+ * A catalog in Spark, as returned by the `listCatalogs` method defined in [[Catalog]].
+ *
+ * @param name name of the catalog
Review Comment:
`description` is missing
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] amaliujia commented on a diff in pull request #36904: [SPARK-39506][SQL] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
Posted by GitBox <gi...@apache.org>.
amaliujia commented on code in PR #36904:
URL: https://github.com/apache/spark/pull/36904#discussion_r904112358
##########
sql/core/src/main/scala/org/apache/spark/sql/catalog/interface.scala:
##########
@@ -26,6 +26,22 @@ import org.apache.spark.sql.catalyst.DefinedByConstructorParams
// Note: all classes here are expected to be wrapped in Datasets and so must extend
// DefinedByConstructorParams for the catalog to be able to create encoders for them.
+/**
+ * A catalog in Spark, as returned by the `listCatalogs` method defined in [[Catalog]].
+ *
+ * @param name name of the catalog
+ * @since 3.2.0
+ */
+class CatalogMetadata(
+ val name: String)
Review Comment:
Sounds good for keeping the class and additionally adding a description field.
Regrading renaming to `Catalog`, it will have a naming conflict with https://github.com/apache/spark/blob/59eee98024dac42309f2e7196c7e68832317f284/sql/core/src/main/scala/org/apache/spark/sql/catalog/Catalog.scala#L33
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] amaliujia commented on a diff in pull request #36904: [SPARK-39506][SQL] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
Posted by GitBox <gi...@apache.org>.
amaliujia commented on code in PR #36904:
URL: https://github.com/apache/spark/pull/36904#discussion_r902896484
##########
sql/core/src/main/scala/org/apache/spark/sql/catalog/interface.scala:
##########
@@ -26,6 +26,22 @@ import org.apache.spark.sql.catalyst.DefinedByConstructorParams
// Note: all classes here are expected to be wrapped in Datasets and so must extend
// DefinedByConstructorParams for the catalog to be able to create encoders for them.
+/**
+ * A catalog in Spark, as returned by the `listCatalogs` method defined in [[Catalog]].
+ *
+ * @param name name of the catalog
+ * @since 3.2.0
+ */
+class CatalogMetadata(
+ val name: String)
Review Comment:
We might design the class like this
```
case class CatalogMetadata(
name: String,
description: String,
owner: Option[String] = None,
catalogType: Option[CatalogType] = None,
createdAt: Option[Long] = None,
createdBy: Option[String] = None,
updatedAt: Option[Long] = None,
updatedBy: Option[String] = None
)
```
However, I am not sure if there are extra information we can fetch for a catalog. Do you know if we have such rich metadata for a catalog in Spark?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on a diff in pull request #36904: [SPARK-39506][SQL] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #36904:
URL: https://github.com/apache/spark/pull/36904#discussion_r904480863
##########
sql/core/src/main/scala/org/apache/spark/sql/catalog/Catalog.scala:
##########
@@ -589,4 +589,25 @@ abstract class Catalog {
* @since 2.0.0
*/
def refreshByPath(path: String): Unit
+
+ /**
+ * Returns the current default catalog in this session.
+ *
+ * @since 3.4.0
+ */
+ def currentCatalog(): String
Review Comment:
Do we need backward compatibility here? This is an interface that Spark implements and users call. Adding a new method shouldn't break anything.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on a diff in pull request #36904: [SPARK-39506][SQL] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #36904:
URL: https://github.com/apache/spark/pull/36904#discussion_r902257445
##########
sql/core/src/main/scala/org/apache/spark/sql/catalog/interface.scala:
##########
@@ -26,6 +26,22 @@ import org.apache.spark.sql.catalyst.DefinedByConstructorParams
// Note: all classes here are expected to be wrapped in Datasets and so must extend
// DefinedByConstructorParams for the catalog to be able to create encoders for them.
+/**
+ * A catalog in Spark, as returned by the `listCatalogs` method defined in [[Catalog]].
+ *
+ * @param name name of the catalog
+ * @since 3.2.0
+ */
+class CatalogMetadata(
+ val name: String)
Review Comment:
if it's simply a string, shall we just let `listCatalogs` return `Dataset[String]`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] amaliujia commented on a diff in pull request #36904: [SPARK-39506][SQL] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
Posted by GitBox <gi...@apache.org>.
amaliujia commented on code in PR #36904:
URL: https://github.com/apache/spark/pull/36904#discussion_r905414289
##########
sql/core/src/main/scala/org/apache/spark/sql/catalog/Catalog.scala:
##########
@@ -589,4 +589,25 @@ abstract class Catalog {
* @since 2.0.0
*/
def refreshByPath(path: String): Unit
+
+ /**
+ * Returns the current default catalog in this session.
+ *
+ * @since 3.4.0
+ */
+ def currentCatalog(): String
+
+ /**
+ * Sets the current default catalog in this session.
+ *
+ * @since 3.4.0
+ */
+ def setCurrentCatalog(catalogName: String): Unit
+
+ /**
+ * Returns a list of catalogs in this session.
Review Comment:
done.
##########
sql/core/src/main/scala/org/apache/spark/sql/catalog/Catalog.scala:
##########
@@ -589,4 +589,25 @@ abstract class Catalog {
* @since 2.0.0
*/
def refreshByPath(path: String): Unit
+
+ /**
+ * Returns the current default catalog in this session.
+ *
+ * @since 3.4.0
+ */
+ def currentCatalog(): String
+
+ /**
+ * Sets the current default catalog in this session.
Review Comment:
done
##########
sql/core/src/test/scala/org/apache/spark/sql/internal/CatalogSuite.scala:
##########
@@ -743,4 +722,30 @@ class CatalogSuite extends SharedSparkSession with AnalysisTest with BeforeAndAf
val catalogName2 = "catalog_not_exists"
assert(!spark.catalog.databaseExists(Array(catalogName2, dbName).mkString(".")))
}
+
+ test("three layer namespace compatibility - cache table, isCached and uncacheTable") {
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on a diff in pull request #36904: [SPARK-39506][SQL] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #36904:
URL: https://github.com/apache/spark/pull/36904#discussion_r905933255
##########
sql/core/src/test/scala/org/apache/spark/sql/internal/CatalogSuite.scala:
##########
@@ -743,4 +722,31 @@ class CatalogSuite extends SharedSparkSession with AnalysisTest with BeforeAndAf
val catalogName2 = "catalog_not_exists"
assert(!spark.catalog.databaseExists(Array(catalogName2, dbName).mkString(".")))
}
+
+ test("SPARK-39506: three layer namespace compatibility - cache table, isCached and" +
+ "uncacheTable") {
+ val tableSchema = new StructType().add("i", "int")
+ createTable("my_table", "my_db", "testcat", classOf[FakeV2Provider].getName,
+ tableSchema, Map.empty[String, String], "")
+ createTable("my_table2", "my_db", "testcat", classOf[FakeV2Provider].getName,
+ tableSchema, Map.empty[String, String], "")
+
+ spark.catalog.cacheTable("testcat.my_db.my_table", StorageLevel.DISK_ONLY)
+ assert(spark.table("testcat.my_db.my_table").storageLevel == StorageLevel.DISK_ONLY)
+ assert(spark.catalog.isCached("testcat.my_db.my_table"))
+
+ spark.catalog.cacheTable("testcat.my_db.my_table2")
+ assert(spark.catalog.isCached("testcat.my_db.my_table2"))
+
+ spark.catalog.uncacheTable("testcat.my_db.my_table")
+ assert(!spark.catalog.isCached("testcat.my_db.my_table"))
+ }
+
+ test("SPARK-39506: test setCurrentCatalog, currentCatalog and listCatalogs") {
+ spark.catalog.setCurrentCatalog("testcat")
+ assert(spark.catalog.currentCatalog().equals("testcat"))
+ spark.catalog.setCurrentCatalog("spark_catalog")
+ assert(spark.catalog.currentCatalog().equals("spark_catalog"))
+ assert(spark.catalog.listCatalogs().collect().map(c => c.name).toSet == Set("testcat"))
Review Comment:
not related to this PR, but we should figure out why `spark_catalog` is missed here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] HyukjinKwon commented on a diff in pull request #36904: [SPARK-39506][SQL] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on code in PR #36904:
URL: https://github.com/apache/spark/pull/36904#discussion_r904452603
##########
sql/core/src/main/scala/org/apache/spark/sql/catalog/Catalog.scala:
##########
@@ -589,4 +589,25 @@ abstract class Catalog {
* @since 2.0.0
*/
def refreshByPath(path: String): Unit
+
+ /**
+ * Returns the current default catalog in this session.
+ *
+ * @since 3.4.0
+ */
+ def currentCatalog(): String
Review Comment:
Would need to 1. have a default implementation for backward compatibility, or 2. exclude this from binary compatibility check.
The real error is:
```
[error] spark-sql: Failed binary compatibility check against org.apache.spark:spark-sql_2.12:3.2.0! Found 3 potential problems (filtered 602)
[error] * abstract method currentCatalog()java.lang.String in class org.apache.spark.sql.catalog.Catalog is present only in current version
[error] filter with: ProblemFilters.exclude[ReversedMissingMethodProblem]("org.apache.spark.sql.catalog.Catalog.currentCatalog")
[error] * abstract method setCurrentCatalog(java.lang.String)Unit in class org.apache.spark.sql.catalog.Catalog is present only in current version
[error] filter with: ProblemFilters.exclude[ReversedMissingMethodProblem]("org.apache.spark.sql.catalog.Catalog.setCurrentCatalog")
[error] * abstract method listCatalogs()org.apache.spark.sql.Dataset in class org.apache.spark.sql.catalog.Catalog is present only in current version
[error] filter with: ProblemFilters.exclude[ReversedMissingMethodProblem]("org.apache.spark.sql.catalog.Catalog.listCatalogs")
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] amaliujia commented on a diff in pull request #36904: [SPARK-39506][SQL] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
Posted by GitBox <gi...@apache.org>.
amaliujia commented on code in PR #36904:
URL: https://github.com/apache/spark/pull/36904#discussion_r902899453
##########
sql/core/src/main/scala/org/apache/spark/sql/internal/CatalogImpl.scala:
##########
@@ -548,10 +548,20 @@ class CatalogImpl(sparkSession: SparkSession) extends Catalog {
* @since 2.0.0
*/
override def uncacheTable(tableName: String): Unit = {
- val tableIdent = sparkSession.sessionState.sqlParser.parseTableIdentifier(tableName)
- sessionCatalog.lookupTempView(tableIdent).map(uncacheView).getOrElse {
- sparkSession.sharedState.cacheManager.uncacheQuery(sparkSession.table(tableName),
- cascade = true)
+ // We first try to parse `tableName` to see if it is 2 part name. If so, then in HMS we check
+ // if it is a temp view and uncache the temp view from HMS, otherwise we uncache it from the
+ // cache manager.
+ // if `tableName` is not 2 part name, then we directly uncache it from the cache manager.
+ try {
+ val tableIdent = sparkSession.sessionState.sqlParser.parseTableIdentifier(tableName)
+ sessionCatalog.lookupTempView(tableIdent).map(uncacheView).getOrElse {
Review Comment:
I might change the logic here as well: just look up the view from SessionCatalog. If it does not exist, fall back to 3 part name logic.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #36904: [SPARK-39506][SQL] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on PR #36904:
URL: https://github.com/apache/spark/pull/36904#issuecomment-1159314195
Can one of the admins verify this patch?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] amaliujia commented on a diff in pull request #36904: [SPARK-39506][SQL] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
Posted by GitBox <gi...@apache.org>.
amaliujia commented on code in PR #36904:
URL: https://github.com/apache/spark/pull/36904#discussion_r905414575
##########
sql/core/src/main/scala/org/apache/spark/sql/catalog/interface.scala:
##########
@@ -26,6 +26,24 @@ import org.apache.spark.sql.catalyst.DefinedByConstructorParams
// Note: all classes here are expected to be wrapped in Datasets and so must extend
// DefinedByConstructorParams for the catalog to be able to create encoders for them.
+/**
+ * A catalog in Spark, as returned by the `listCatalogs` method defined in [[Catalog]].
+ *
+ * @param name name of the catalog
Review Comment:
added in the doc
##########
sql/core/src/main/scala/org/apache/spark/sql/catalog/Catalog.scala:
##########
@@ -589,4 +589,25 @@ abstract class Catalog {
* @since 2.0.0
*/
def refreshByPath(path: String): Unit
+
+ /**
+ * Returns the current default catalog in this session.
+ *
+ * @since 3.4.0
+ */
+ def currentCatalog(): String
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] HyukjinKwon commented on pull request #36904: [SPARK-39506][SQL] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on PR #36904:
URL: https://github.com/apache/spark/pull/36904#issuecomment-1163839514
Adding @zhengruifeng FYI
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] HyukjinKwon commented on a diff in pull request #36904: [SPARK-39506][SQL] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on code in PR #36904:
URL: https://github.com/apache/spark/pull/36904#discussion_r904485439
##########
sql/core/src/main/scala/org/apache/spark/sql/catalog/Catalog.scala:
##########
@@ -589,4 +589,25 @@ abstract class Catalog {
* @since 2.0.0
*/
def refreshByPath(path: String): Unit
+
+ /**
+ * Returns the current default catalog in this session.
+ *
+ * @since 3.4.0
+ */
+ def currentCatalog(): String
Review Comment:
Yeah, acutlaly not sure why it complains.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] amaliujia commented on a diff in pull request #36904: [SPARK-39506][SQL] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
Posted by GitBox <gi...@apache.org>.
amaliujia commented on code in PR #36904:
URL: https://github.com/apache/spark/pull/36904#discussion_r902896817
##########
sql/core/src/main/scala/org/apache/spark/sql/catalog/Catalog.scala:
##########
@@ -589,4 +589,25 @@ abstract class Catalog {
* @since 2.0.0
*/
def refreshByPath(path: String): Unit
+
+ /**
+ * Returns the current default catalog in this session.
+ *
+ * @since 3.2.0
Review Comment:
oops. Will update this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on a diff in pull request #36904: [SPARK-39506][SQL] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #36904:
URL: https://github.com/apache/spark/pull/36904#discussion_r904480952
##########
sql/core/src/main/scala/org/apache/spark/sql/catalog/Catalog.scala:
##########
@@ -589,4 +589,25 @@ abstract class Catalog {
* @since 2.0.0
*/
def refreshByPath(path: String): Unit
+
+ /**
+ * Returns the current default catalog in this session.
+ *
+ * @since 3.4.0
+ */
+ def currentCatalog(): String
+
+ /**
+ * Sets the current default catalog in this session.
Review Comment:
```suggestion
* Sets the current catalog in this session.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on a diff in pull request #36904: [SPARK-39506][SQL] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #36904:
URL: https://github.com/apache/spark/pull/36904#discussion_r904487769
##########
sql/core/src/main/scala/org/apache/spark/sql/catalog/Catalog.scala:
##########
@@ -589,4 +589,25 @@ abstract class Catalog {
* @since 2.0.0
*/
def refreshByPath(path: String): Unit
+
+ /**
+ * Returns the current default catalog in this session.
+ *
+ * @since 3.4.0
+ */
+ def currentCatalog(): String
Review Comment:
anyway, let's update the build file to make mima happy
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] amaliujia commented on a diff in pull request #36904: [SPARK-39506][SQL] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
Posted by GitBox <gi...@apache.org>.
amaliujia commented on code in PR #36904:
URL: https://github.com/apache/spark/pull/36904#discussion_r903172938
##########
sql/core/src/main/scala/org/apache/spark/sql/catalog/interface.scala:
##########
@@ -26,6 +26,22 @@ import org.apache.spark.sql.catalyst.DefinedByConstructorParams
// Note: all classes here are expected to be wrapped in Datasets and so must extend
// DefinedByConstructorParams for the catalog to be able to create encoders for them.
+/**
+ * A catalog in Spark, as returned by the `listCatalogs` method defined in [[Catalog]].
+ *
+ * @param name name of the catalog
+ * @since 3.2.0
+ */
+class CatalogMetadata(
+ val name: String)
Review Comment:
If Spark only knows the catalog name, then probably `Dataset[String]` would be fine.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on a diff in pull request #36904: [SPARK-39506][SQL] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #36904:
URL: https://github.com/apache/spark/pull/36904#discussion_r902247016
##########
sql/core/src/main/scala/org/apache/spark/sql/catalog/Catalog.scala:
##########
@@ -589,4 +589,25 @@ abstract class Catalog {
* @since 2.0.0
*/
def refreshByPath(path: String): Unit
+
+ /**
+ * Returns the current default catalog in this session.
+ *
+ * @since 3.2.0
Review Comment:
3.4.0
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] amaliujia commented on pull request #36904: [SPARK-39506] Make CacheTable, isCached, UncacheTable, setCurrentCatalog, currentCatalog, listCatalogs 3l namespace compatible
Posted by GitBox <gi...@apache.org>.
amaliujia commented on PR #36904:
URL: https://github.com/apache/spark/pull/36904#issuecomment-1159225890
R: @cloud-fan
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org