This is an automated email from the ASF dual-hosted git repository.
chengpan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kyuubi.git
The following commit(s) were added to refs/heads/master by this push:
new d3a38533e [KYUUBI #5937] PVM cause cache table not work
d3a38533e is described below
commit d3a38533e504caad60068b1f0504ffc70458447a
Author: Angerszhuuuu <[email protected]>
AuthorDate: Thu Jan 18 13:47:38 2024 +0800
[KYUUBI #5937] PVM cause cache table not work
# :mag: Description
## Issue References ๐
This pull request fixes #5937
## Describe Your Solution ๐ง
If we cache a table with persist view in the query, since cache table use
analyzed plan, so in kyuubi authz we will use PVM to wrap the view, but cache
table use canonicalized plan, so we need to implement the `doCanonicalize()`
method to ignore the impact of PVM, or it will cache cached table can't be
matched.
## Types of changes :bookmark:
- [x] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
## Test Plan ๐งช
#### Behavior Without This Pull Request :coffin:
#### Behavior With This Pull Request :tada:
#### Related Unit Tests
---
# Checklist ๐
- [ ] This patch was not authored or co-authored using [Generative
Tooling](https://www.apache.org/legal/generative-tooling.html)
**Be nice. Be informative.**
Closes #5982 from AngersZhuuuu/KYUUBI-5937.
Closes #5937
e28275f32 [Angerszhuuuu] Update PermanentViewMarker.scala
c504103d2 [Angerszhuuuu] Update PermanentViewMarker.scala
19102ff53 [Angerszhuuuu] [KYUUBI-5937][Bug] PVM cause cache table not work
Authored-by: Angerszhuuuu <[email protected]>
Signed-off-by: Cheng Pan <[email protected]>
---
.../rule/permanentview/PermanentViewMarker.scala | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git
a/extensions/spark/kyuubi-spark-authz/src/main/scala/org/apache/kyuubi/plugin/spark/authz/rule/permanentview/PermanentViewMarker.scala
b/extensions/spark/kyuubi-spark-authz/src/main/scala/org/apache/kyuubi/plugin/spark/authz/rule/permanentview/PermanentViewMarker.scala
index fc52adc04..cb233b465 100644
---
a/extensions/spark/kyuubi-spark-authz/src/main/scala/org/apache/kyuubi/plugin/spark/authz/rule/permanentview/PermanentViewMarker.scala
+++
b/extensions/spark/kyuubi-spark-authz/src/main/scala/org/apache/kyuubi/plugin/spark/authz/rule/permanentview/PermanentViewMarker.scala
@@ -21,11 +21,14 @@ import
org.apache.spark.sql.catalyst.analysis.MultiInstanceRelation
import org.apache.spark.sql.catalyst.catalog.CatalogTable
import org.apache.spark.sql.catalyst.expressions.{Alias, Attribute, Cast}
import org.apache.spark.sql.catalyst.plans.QueryPlan
-import org.apache.spark.sql.catalyst.plans.logical.{LeafNode, LogicalPlan,
Project, Statistics}
+import org.apache.spark.sql.catalyst.plans.logical.{LeafNode, LogicalPlan,
Project, Statistics, View}
+import org.apache.spark.sql.catalyst.trees.TreeNodeTag
case class PermanentViewMarker(child: LogicalPlan, catalogTable: CatalogTable)
extends LeafNode with MultiInstanceRelation {
+ private val PVM_NEW_INSTANCE_TAG =
TreeNodeTag[Unit]("__PVM_NEW_INSTANCE_TAG")
+
override def output: Seq[Attribute] = child.output
override def argString(maxFields: Int): String = ""
@@ -38,6 +41,18 @@ case class PermanentViewMarker(child: LogicalPlan,
catalogTable: CatalogTable)
val projectList = child.output.map { case attr =>
Alias(Cast(attr, attr.dataType), attr.name)(explicitMetadata =
Some(attr.metadata))
}
- this.copy(child = Project(projectList, child), catalogTable = catalogTable)
+ val newProj = Project(projectList, child)
+ newProj.setTagValue(PVM_NEW_INSTANCE_TAG, ())
+
+ this.copy(child = newProj, catalogTable = catalogTable)
+ }
+
+ override def doCanonicalize(): LogicalPlan = {
+ child match {
+ case p @ Project(_, view: View) if
p.getTagValue(PVM_NEW_INSTANCE_TAG).contains(true) =>
+ view.canonicalized
+ case _ =>
+ child.canonicalized
+ }
}
}