HIVE-28541: Incorrectly treating materialized CTE as Table when privi…
What changes were proposed in this pull request?
https://issues.apache.org/jira/browse/HIVE-28541
- check
isMaterializedTable()before adding elements intoCollection<ReadEntity> - add materialized CTE's real
ReadEntityinto parent'sinputs
Why are the changes needed?
it is a bug, which caused an exception when I used hive.optimize.cte.materialize.threshold
Does this PR introduce any user-facing change?
No
Is the change a dependency upgrade?
No
How was this patch tested?
It is hard to test with simple units. I tested and deployed it in my production environment.
Quality Gate passed
Issues
7 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Feel free to reach out on the [email protected] list if the patch is in need of reviews.
The problem statement is obvious. I'm reviewing and finding an excellent way to test it...
@shuaiqig I guess we can test it using the integration test like this. Could you add some test cases? I guess we want 4 test cases as it is a security related feature.
- Positive test with CBO. If the user has access to the source table, they can read the source table and materialized CTEs
- Positive test without CBO
- Negative test with CBO. If the user doesn't have access to the source table, they fail to run the query
- Negative test without CBO
--! qt:dataset:src
set hive.security.authorization.manager=org.apache.hadoop.hive.ql.security.authorization.DefaultHiveAuthorizationProvider;
create table src_auth_test_cte_materialization as select * from src;
set hive.security.authorization.enabled=true;
grant select on table src_auth_test_cte_materialization to user hive_test_user;
set hive.fetch.task.conversion=none;
set hive.optimize.cte.materialize.threshold=1;
explain
with x as (select count(*) from src_auth_test_cte_materialization) select * from x;
with x as (select count(*) from src_auth_test_cte_materialization) select * from x;
You can see some guidance here. Feedback is always welcome https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=27362107#HowToContribute-QueryUnitTest
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Feel free to reach out on the [email protected] list if the patch is in need of reviews.