[ https://issues.apache.org/jira/browse/HIVE-9432?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14312674#comment-14312674 ]
Prasanth Jayachandran commented on HIVE-9432: --------------------------------------------- [~jcamachorodriguez] I think this is not the expected behavior. AFAIK, hasOrderBy() returns true if there are any ORDER BY in the entire query including the subqueries. But SortedDynPartitionOptimizer is only interested if there is an ORDER BY in the outermost query that injects data directly into the destination. From what I understand, SQL standard does not say we need to preserve the ordering of subqueries (Plz correct me if I am wrong). The test case is failing, because the column 'i' from the subquery gets appended to outer order by 't' because of hasOrderBy(). The earlier check using QB just checks if the outermost query has ORDER BY. > CBO (Calcite Return Path): Removing QB from ParseContext > -------------------------------------------------------- > > Key: HIVE-9432 > URL: https://issues.apache.org/jira/browse/HIVE-9432 > Project: Hive > Issue Type: Sub-task > Components: CBO > Reporter: Jesus Camacho Rodriguez > Assignee: Jesus Camacho Rodriguez > Fix For: 0.15.0 > > Attachments: HIVE-9432.01.patch, HIVE-9432.02.patch, > HIVE-9432.03.patch, HIVE-9432.patch > > -- This message was sent by Atlassian JIRA (v6.3.4#6332)