Uh oh!
There was an error while loading. Please reload this page.
[SPARK-51219][SQL] Fix ShowTablesExec.isTempView to work with non-V2SessionCatalog catalogs - #49959
Conversation
ostronaut
commented
Feb 14, 2025
Related issue in Delta: delta-io/delta#2610 |
There was a problem hiding this comment.
shall we only do it if the catalog name is spark_catalog? i.e. CatalogV2Utils.isSessionCatalog
There was a problem hiding this comment.
good point! refactored
1f95347 to
c1014b1Compareostronaut
commented
Feb 18, 2025
Hey @cloud-fan. Do you think we can merge this PR? |
cloud-fan
commented
Feb 18, 2025
thanks, merging ton master/4.0/3.5! |
…V2SessionCatalog` catalogs
### What changes were proposed in this pull request?
When non buildin catalog is configured (for example, `org.apache.spark.sql.delta.catalog.DeltaCatalog`) and there is a temp table in catalog, running catalog listTable will fail:
```scala
spark.conf.set("spark.sql.catalog.spark_catalog", "org.apache.spark.sql.delta.catalog.DeltaCatalog")
spark.range(0,2).createOrReplaceTempView("abc")
spark.catalog.listTables().show()
// org.apache.spark.sql.catalyst.parser.ParseException:
// [PARSE_EMPTY_STATEMENT] Syntax error, unexpected empty statement. SQLSTATE: 42617 (line 1, pos 0)
//
// == SQL ==
//
// ^^^
```
If default `V2SessionCatalog` catalog is in use, or there are no temp tables, the same command run without issues.
This behavior is due to `ShowTablesExec. isTempView ` method, where only for `V2SessionCatalog` catalogs dedicated `isTempView` is executed. This PR fixes that, by using `session.sessionState.catalog.isTempView` instead.
### Why are the changes needed?
To avoid unnecessary fails when a non-buildin v2 catalog is in use.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
New unit tests.
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes#49959 from ostronaut/features/fix-ShowTablesExec-isTempView.
Authored-by: Dima <dimanowq@gmail.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
(cherry picked from commit aa37f89)
Signed-off-by: Wenchen Fan <wenchen@databricks.com>…V2SessionCatalog` catalogs
When non buildin catalog is configured (for example, `org.apache.spark.sql.delta.catalog.DeltaCatalog`) and there is a temp table in catalog, running catalog listTable will fail:
```scala
spark.conf.set("spark.sql.catalog.spark_catalog", "org.apache.spark.sql.delta.catalog.DeltaCatalog")
spark.range(0,2).createOrReplaceTempView("abc")
spark.catalog.listTables().show()
// org.apache.spark.sql.catalyst.parser.ParseException:
// [PARSE_EMPTY_STATEMENT] Syntax error, unexpected empty statement. SQLSTATE: 42617 (line 1, pos 0)
//
// == SQL ==
//
// ^^^
```
If default `V2SessionCatalog` catalog is in use, or there are no temp tables, the same command run without issues.
This behavior is due to `ShowTablesExec. isTempView ` method, where only for `V2SessionCatalog` catalogs dedicated `isTempView` is executed. This PR fixes that, by using `session.sessionState.catalog.isTempView` instead.
To avoid unnecessary fails when a non-buildin v2 catalog is in use.
No.
New unit tests.
No.
Closes#49959 from ostronaut/features/fix-ShowTablesExec-isTempView.
Authored-by: Dima <dimanowq@gmail.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
(cherry picked from commit aa37f89)
Signed-off-by: Wenchen Fan <wenchen@databricks.com>melin
commented
Feb 19, 2025
| private def isTempView(ident: Identifier, catalog: TableCatalog): Boolean = { | ||
| if (CatalogV2Util.isSessionCatalog(catalog)) { | ||
| session.sessionState.catalog | ||
| .isTempView((ident.namespace() :+ ident.name()).toImmutableArraySeq) |
There was a problem hiding this comment.
I've took it from existing implementation in default V2 catalog, let me replace it to toArray?
There was a problem hiding this comment.
let's try and see if scala 2.12 is happy with it
There was a problem hiding this comment.
You can open a PR against branch 3.5, which use scala 2.12
There was a problem hiding this comment.
#50008. Lets see if default seq will be enough.
…V2SessionCatalog` catalogs
### What changes were proposed in this pull request?
When non buildin catalog is configured (for example, `org.apache.spark.sql.delta.catalog.DeltaCatalog`) and there is a temp table in catalog, running catalog listTable will fail:
```scala
spark.conf.set("spark.sql.catalog.spark_catalog", "org.apache.spark.sql.delta.catalog.DeltaCatalog")
spark.range(0,2).createOrReplaceTempView("abc")
spark.catalog.listTables().show()
// org.apache.spark.sql.catalyst.parser.ParseException:
// [PARSE_EMPTY_STATEMENT] Syntax error, unexpected empty statement. SQLSTATE: 42617 (line 1, pos 0)
//
// == SQL ==
//
// ^^^
```
If default `V2SessionCatalog` catalog is in use, or there are no temp tables, the same command run without issues.
This behavior is due to `ShowTablesExec. isTempView ` method, where only for `V2SessionCatalog` catalogs dedicated `isTempView` is executed. This PR fixes that, by using `session.sessionState.catalog.isTempView` instead.
### Why are the changes needed?
To avoid unnecessary fails when a non-buildin v2 catalog is in use.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
New unit tests.
### Was this patch authored or co-authored using generative AI tooling?
No.
Closesapache#49959 from ostronaut/features/fix-ShowTablesExec-isTempView.
Authored-by: Dima <dimanowq@gmail.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
(cherry picked from commit b300b84)
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
What changes were proposed in this pull request?
When non buildin catalog is configured (for example,
org.apache.spark.sql.delta.catalog.DeltaCatalog) and there is a temp table in catalog, running catalog listTable will fail:If default
V2SessionCatalogcatalog is in use, or there are no temp tables, the same command run without issues.This behavior is due to
ShowTablesExec. isTempViewmethod, where only forV2SessionCatalogcatalogs dedicatedisTempViewis executed. This PR fixes that, by usingsession.sessionState.catalog.isTempViewinstead.Why are the changes needed?
To avoid unnecessary fails when a non-buildin v2 catalog is in use.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
New unit tests.
Was this patch authored or co-authored using generative AI tooling?
No.