mustafasrepo commented on PR #6160:
URL:
https://github.com/apache/arrow-datafusion/pull/6160#issuecomment-1529101017
> Thank you for this PR @mustafasrepo -- I skimmed this PR
>
> and one question I have is why add a new `ordering_equivalence_properties`
when DataFusion already has `equivalence_properties` which seems to be a more
general concept?
>
> It is confusing to me because the existence of
`ordering_equivalence_properties` imples that `equivalence_properties` doesn't
apply when ordering.
>
> If the existing `equivalence_properties` doesn't support ordering
aliasing, did you consider making it more general?
As far as I know `equivalence_properties` keeps track of the exactly same
columns such as in the form below.
| a | a_alias |
| -------- | ------- |
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
| 5 | 5 |
However, `ordering_equivalence_properties` keeps track of columns that can
describe global ordering of the schema, these columns are not necessarily same.
Hence they cannot be described in current `equivalence_properties` without
modification. Consider table,
| a | b |
| -------- | ------- |
| 1 | 9 |
| 2 | 8 |
| 3 | 7 |
| 5 | 5 |
both `a ASC` and `b DESC` can describe ordering of the current table. If we
were to run query
```sql
SELECT *
FROM table1
ORDER BY a
```
we do not have to add `SortExec` to final plan, since table is already
ordered by `a ASC`. Similarly, if we were to run query
```sql
SELECT *
FROM table1
ORDER BY b DESC
```
we do not have to add `SortExec` to final plan, since table is already
ordered by `b DESC`.
Ordering equivalence keeps track of these equalities and treats `a ASC`, and
`b DESC` as same requirement. Currently, as far as I am aware, with existing
APIs we cannot describe this functionality.
--
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]