hive icon indicating copy to clipboard operation
hive copied to clipboard

HIVE-28541: Incorrectly treating materialized CTE as Table when privi…

Open shuaiqig opened this issue 1 year ago • 1 comments

What changes were proposed in this pull request?

https://issues.apache.org/jira/browse/HIVE-28541

  • check isMaterializedTable() before adding elements into Collection<ReadEntity>
  • add materialized CTE's real ReadEntity into parent's inputs

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.

shuaiqig avatar Sep 27 '24 08:09 shuaiqig

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.

github-actions[bot] avatar Nov 27 '24 00:11 github-actions[bot]

The problem statement is obvious. I'm reviewing and finding an excellent way to test it...

okumin avatar Nov 29 '24 10:11 okumin

@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

okumin avatar Nov 29 '24 12:11 okumin

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.

github-actions[bot] avatar Jan 30 '25 00:01 github-actions[bot]