[Bug] [AUTHZ] masked column cannot be used as a filter condition
- 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
There is a table named test_student_02, which contains data of students who are around 18 years old. The "age" column has been hashed for data masking. When using the following SQL query, no data can be retrieved.
```
var ds4 = spark.sql("select * from user02db.test_student_02 where age > 18");
ds4.explain(true);
```
```
'Project [*]
+- 'Filter ('age > 18)
+- 'UnresolvedRelation `user02db`.`test_student_02`
== Analyzed Logical Plan ==
id: int, name: string, sex: boolean, age: string, department: string
Project [id#18, name#19, sex#23, age#24, department#22]
+- Filter (cast(age#24 as int) > 18)
+- SubqueryAlias `user02db`.`test_student_02`
+- Filter (department#22 = IS)
+- RowFilterMarker
+- DataMaskingStage0Marker HiveTableRelation `user02db`.`test_student_02`, org.apache.hadoop.hive.ql.io.orc.OrcSerde, [id#18, name#19, sex#20, age#21, department#22]
+- Project [id#18, name#19, (0 = 0) AS sex#23, md5(cast(cast(age#21 as string) as binary)) AS age#24, department#22]
+- Relation[id#18,name#19,sex#20,age#21,department#22] orc
== Optimized Logical Plan ==
Project [id#18, name#19, true AS sex#23, md5(cast(cast(age#21 as string) as binary)) AS age#24, department#22]
+- Filter ((isnotnull(department#22) && (department#22 = IS)) && (cast(md5(cast(cast(age#21 as string) as binary)) as int) > 18))
+- Relation[id#18,name#19,sex#20,age#21,department#22] orc
```
### 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?
- [ ] 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
Research direction
Reproduce the SQL query and inspect the analyzed and optimized logical plans shown in the issue, focusing on how data masking rewrites the age column before filtering. Trace the masking and filter interaction in the relevant Spark/Kyuubi authorization path. Done means a condition on the masked age column returns the expected rows without breaking masking behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala, spark, sql
- Domain
- authorization, databases, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100