Skip to content

Conversation

@soumyakanti3578
Copy link
Contributor

@soumyakanti3578 soumyakanti3578 commented Sep 25, 2025

What changes were proposed in this pull request?

Earlier we expected a view's logical plan to always have a HiveProject as its top node. But we can have HiveSortLimit too if the original view definition has a limit.

We should support all RelNodes and not just HiveProject.

Why are the changes needed?

We get an error as described in https://issues.apache.org/jira/browse/HIVE-28280, https://issues.apache.org/jira/browse/HIVE-21163

Does this PR introduce any user-facing change?

No

How was this patch tested?

mvn test -pl itests/qtest -Pitests -Dtest=TestMiniLlapCliDriver -Dtest.output.overwrite=true -Dqfile=view_top_relnode_not_project_authorization.q

Copy link
Contributor

@thomasrebele thomasrebele left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor suggestion to make the code more efficient. Otherwise LGTM.

Copy link
Contributor

@thomasrebele thomasrebele left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@zabetak zabetak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes LGTM! I left some minor questions & some nits. I wouldn't insist much on addressing the nits but it would be nice to have a new CI run since the last one was sometime ago and results may be obsolete by now so leaving those at your judgement.

Comment on lines +69 to +90
CBO PLAN:
HiveFilter(condition=[>($0, _UTF-16LE'a')])
HiveProject(username=[$0])
HiveSortLimit(fetch=[1])
HiveProject(username=[$0])
HiveFilter(condition=[>($1, 10)])
HiveTableScan(table=[[default, t1]], table:alias=[t1])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the order by id reflected in the plan. Is this normal? Does it really matter that is present in the view definition?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be by design, and can be controlled by:

    HIVE_REMOVE_ORDERBY_IN_SUBQUERY("hive.remove.orderby.in.subquery", true,
        "If set to true, order/sort by without limit in sub queries will be removed.")

@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 6, 2025

@zabetak zabetak merged commit d186aba into apache:master Nov 7, 2025
4 checks passed
@zabetak
Copy link
Member

zabetak commented Nov 7, 2025

Thanks for the PR @soumyakanti3578 and @thomasrebele for the review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants