Nagato-Yuzuru commented on PR #24206:
URL: https://github.com/apache/datafusion/pull/24206#issuecomment-5233387934
The old query plan can lead to this sort error
In datafusion-cli
```
DataFusion CLI v54.1.0
>set datafusion.execution.target_partitions = 1;
-- Materialize the data through SQL so this repro is self-contained.
COPY (SELECT * FROM (VALUES
(1, CAST(NULL AS INT)),
(2, 10),
(3, 1),
(CAST(NULL AS INT), 0)
) AS t(inc_col, desc_col))
TO '/tmp/nulls_demo.csv' STORED AS CSV;
CREATE EXTERNAL TABLE demo (
inc_col INTEGER,
desc_col INTEGER
)
STORED AS CSV
WITH ORDER (inc_col ASC) -- ASC defaults to NULLS LAST -> nulls at the
end
WITH ORDER (desc_col DESC) -- DESC defaults to NULLS FIRST -> nulls at the
start
LOCATION '/tmp/nulls_demo.csv'
OPTIONS ('format.has_header' 'true');
-- Both columns really do match their declared orderings.
SELECT * FROM demo;
SELECT CAST((inc_col > desc_col) AS integer) AS c FROM demo ORDER BY c;
```
Get
```
+---------+----------+
| inc_col | desc_col |
+---------+----------+
| 1 | NULL | inc_col: 1, 2, 3, NULL -> ASC NULLS LAST ✓
| 2 | 10 | desc_col: NULL, 10, 1, 0 -> DESC NULLS FIRST ✓
| 3 | 1 |
| NULL | 0 |
+---------+----------+
+------+
| c |
+------+
| NULL |
| 0 |
| 1 |
| NULL |
+------+
```
Order C was silently violated
--
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]