[KYUUBI #5913][Bug] After resolve PVM should mark all nodes as checked

# 🔍 Description
## Issue References 🔗

This pull request fixes #5913

## Describe Your Solution 🔧

We meet a case that seem after `RuleEliminatePermanentViewMarker` apply and optimize the PVM's child plan, seems some case node's tag was missed, then also check the PVM's source table again when `OptimizeSubqueries`.

We should mark all node as checked for pvm's child and optimized child.
1. It's more stable
2. It's safe

## Types of changes 🔖

- [ ] 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 🧪

Manuel tested in our prod, but didn't reproduce it in the UT since the case is too complex SQL.
#### Behavior Without This Pull Request ⚰️

#### Behavior With This Pull Request 🎉

#### Related Unit Tests

---

# Checklists
## 📝 Author Self Checklist

- [x] My code follows the [style guidelines](https://kyuubi.readthedocs.io/en/master/contributing/code/style.html) of this project
- [x] I have performed a self-review
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html)

## 📝 Committer Pre-Merge Checklist

- [x] Pull request title is okay.
- [x] No license issues.
- [x] Milestone correctly set?
- [x] Test coverage is ok
- [x] Assignees are selected.
- [x] Minimum number of approvals
- [x] No changes are requested

**Be nice. Be informative.**

Closes #5915 from AngersZhuuuu/KYUUBI-5913.

Closes #5913

38c04bd70 [Angerszhuuuu] [KYUUBI #5913][Bug] After resolve PVM should mark all nodes as checke

Authored-by: Angerszhuuuu <angers.zhu@gmail.com>
Signed-off-by: Cheng Pan <chengpan@apache.org>
This commit is contained in:
Angerszhuuuu 2023-12-25 14:34:52 +08:00 committed by Cheng Pan
parent c290dae2ee
commit 62fb9cdfc2
No known key found for this signature in database
GPG Key ID: 8001952629BCC75D
2 changed files with 5 additions and 4 deletions

View File

@ -43,7 +43,7 @@ object Authorization {
val KYUUBI_AUTHZ_TAG = TreeNodeTag[Unit]("__KYUUBI_AUTHZ_TAG")
private def markAllNodesAuthChecked(plan: LogicalPlan): LogicalPlan = {
def markAllNodesAuthChecked(plan: LogicalPlan): LogicalPlan = {
plan.transformDown { case p =>
p.setTagValue(KYUUBI_AUTHZ_TAG, ())
p

View File

@ -37,7 +37,7 @@ case class RuleEliminatePermanentViewMarker(sparkSession: SparkSession) extends
}
// For each SubqueryExpression's PVM, we should mark as resolved to
// avoid check privilege of PVM's internal Subquery.
Authorization.markAuthChecked(ret)
Authorization.markAllNodesAuthChecked(ret)
ret
}
}
@ -52,8 +52,9 @@ case class RuleEliminatePermanentViewMarker(sparkSession: SparkSession) extends
}
}
if (matched) {
Authorization.markAuthChecked(eliminatedPVM)
sparkSession.sessionState.optimizer.execute(eliminatedPVM)
Authorization.markAllNodesAuthChecked(eliminatedPVM)
val optimized = sparkSession.sessionState.optimizer.execute(eliminatedPVM)
Authorization.markAllNodesAuthChecked(optimized)
} else {
eliminatedPVM
}