apache / apache/kyuubi

[Bug] The combination of Command and Aggregate operators causes colmun verification to fail

Open
#5,847 0 comments 1 reaction 0 assignees View on GitHub
kind:bug priority:major
Dominant language
Scala
Stars
2.4k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)

### Search before asking

- [X] I have searched in the [issues](https://github.com/apache/kyuubi/issues?q=is%3Aissue) and found no similar issues.

### Describe the bug

test code:
```
test("auth: Command and Aggregate operators causes colmun verification to fail") {
val db = "default"
val table = "src"
val col = "key"
val create = s"CREATE TABLE IF NOT EXISTS $db.$table ($col int, value int) USING $format"
val select = s"CACHE TABLE TEST AS SELECT key FROM $db.$table group by key"
withCleanTmpResources(Seq((s"$db.$table", "table"))) {
doAs("bob", sql(create))
doAs("kent", sql(select).collect())
}
}

```

![image](https://github.com/apache/kyuubi/assets/30170267/a80f96ae-2d4c-40b8-aef6-9ce23408aec4)

explain :
```
CacheTableAsSelect TEST, SELECT key FROM default.src group by key, false, true
+- Aggregate [key#17], [key#17]
+- SubqueryAlias spark_catalog.default.src
+- HiveTableRelation [`spark_catalog`.`default`.`src`, org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, Data Cols: [key#17, value#18], Partition Cols: []]
```

This paln did not generate **project** operator, causing PrivilegesBuilder's mergeProjection to merge all columns of HiveTableRelation.
![image](https://github.com/apache/kyuubi/assets/30170267/e54279e9-0708-489c-bac3-84dfac6dfc67)

### Affects Version(s)

master

### Kyuubi Server Log Output

_No response_

### Kyuubi Engine Log Output

_No response_

### Kyuubi Server Configurations

_No response_

### Kyuubi Engine Configurations

_No response_

### Additional context

_No response_

### Are you willing to submit PR?

- [X] Yes. I would be willing to submit a PR with guidance from the Kyuubi community to fix.
- [ ] No. I cannot submit a PR at this time.

Contributor guide

Open the contributing guide

Research direction

Start by running the test case from the issue and tracing PrivilegesBuilder.mergeProjection for the shown CacheTableAsSelect and Aggregate plan. Check how the HiveTableRelation columns are handled during verification; done when the reproduction no longer merges unselected columns and the test passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala, spark, sql
Domain
authorization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.