EnricoMi commented on PR #38356:
URL: https://github.com/apache/spark/pull/38356#issuecomment-1296803855

   The given example has `requiredOrdering` with `["p"]` and `outputOrdering` 
with `["p", "sort_col"]`. Therefore, `isOrderingMatched(requiredOrdering, 
outputOrdering)` should be `true`, but returns `false`.
   
   The reason is `requiredOrdering` with `["p"]` has `SortOrder.deteministic = 
false`, which makes `isOrderingMatched` (and `semanticEquals`) return `false`:
   
   
https://github.com/apache/spark/blob/90d31541fb0313d762cc36067060e6445c04a9b6/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Expression.scala#L262-L263
   
   Interestingly, after `isOrderingMatched` returns `false`, the `SortOrder` 
with `["p"]` in `requiredOrdering` has `deteministic = true`.
   
   Even with `deterministic = true`, `semanticEquals` returns `false` because 
`canonicalized == other.canonicalized` is `false`, just because the `exprId` 
differ in `id`, not `jvmId`:
   
https://github.com/apache/spark/blob/90d31541fb0313d762cc36067060e6445c04a9b6/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/namedExpressions.scala#L275-L280


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to