SavingFrame commented on code in PR #57828:
URL: https://github.com/apache/airflow/pull/57828#discussion_r2493985159
##########
airflow-core/src/airflow/api_fastapi/common/parameters.py:
##########
@@ -251,11 +251,6 @@ def to_orm(self, select: Select) -> Select:
if column is None:
column = getattr(self.model, lstriped_orderby)
- # MySQL does not support `nullslast`, and True/False ordering
depends on the
- # database implementation.
- nullscheck = case((column.isnot(None), 0), else_=1)
-
- columns.append(nullscheck)
Review Comment:
Okay, i think then we need to discuss solution for this problem.
We want to show null always(both ASC and DESC) in the end, right?
In the postgres it won't work because index can't have null records in the
start index and in the end at the same time.
In the postgres [we are able to can
specify](https://www.postgresql.org/docs/current/indexes-ordering.html) where
to store nulls in the index. If we want to store nulls in the end, then when we
use ASC order it will be in the end, but if we use DESC order postgres should
reverse index and nulls will be in the end. If we want to store nulls in the
start, then vise versa.
So for example we can create index in the postgres
```sql
CREATE INDEX idx_dag_run_start_date ON dag_run (start_date NULLS FIRST);
```
so when we want to order by start_date ASC, then we get `null, 2020-01-01,
2020-01-02`, but on odering by start_date DESC we gonna get `2020-01-01,
2020-01-02, null`
If we do not want to specify nulls order in the index, then in postgres we
gonna get them in the end of index, but in the mysql in the start of index.
Anyway we can't use index and have nulls in the end always.
I assume we shouldn't use index anywhere, for example when we have dagruns
filtered by dags we can afford scan table, but when you need to get all dagruns
by all dags we can't scan table.
one of the solutions may be make this `nullscheck` optional and disable it
in "big" queries such as get all dagruns
--
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]