-
Notifications
You must be signed in to change notification settings - Fork 4.8k
HIVE-28280: SemanticException when querying VIEW with DISTINCT clause #6103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
51b5bc8 to
d399943
Compare
ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java
Outdated
Show resolved
Hide resolved
ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java
Outdated
Show resolved
Hide resolved
ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java
Outdated
Show resolved
Hide resolved
ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java
Outdated
Show resolved
Hide resolved
thomasrebele
left a comment
There was a problem hiding this 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.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveRelFieldTrimmer.java
Outdated
Show resolved
Hide resolved
thomasrebele
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
zabetak
left a comment
There was a problem hiding this 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.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/RelFieldTrimmer.java
Outdated
Show resolved
Hide resolved
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveRelFieldTrimmer.java
Outdated
Show resolved
Hide resolved
ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java
Outdated
Show resolved
Hide resolved
ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java
Outdated
Show resolved
Hide resolved
ql/src/test/queries/clientpositive/view_top_relnode_not_project_authorization.q
Outdated
Show resolved
Hide resolved
ql/src/test/queries/clientpositive/view_top_relnode_not_project_authorization.q
Show resolved
Hide resolved
| 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]) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.")
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveRelFieldTrimmer.java
Show resolved
Hide resolved
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveRelFieldTrimmer.java
Outdated
Show resolved
Hide resolved
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveRelFieldTrimmer.java
Outdated
Show resolved
Hide resolved
623cc6d to
ff6e6bd
Compare
|
|
Thanks for the PR @soumyakanti3578 and @thomasrebele for the review! |



What changes were proposed in this pull request?
Earlier we expected a view's logical plan to always have a
HiveProjectas its top node. But we can haveHiveSortLimittoo if the original view definition has a limit.We should support all
RelNodes and not justHiveProject.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?