jayzhan211 commented on issue #27457:
URL: https://github.com/apache/datafusion/issues/27457#issuecomment-7063842224
@cool9850311 (B), but its coverage check needs to compare expressions, not
count them. (A) undoes the speedup `TopKRepartition` (#20736) was added for.
At your branch's head, two shapes still keep `TopK(fetch=3)` on the
4-partition sort and return a wrong row in 10 of 10 runs:
| Window `PARTITION BY a, d` under | Returns | Expected |
|---|---|---|
| `ORDER BY a, a2`, where `a2` is `a AS a2` | `(a=1, d=2, b=5, rn=1)` | `rn
= 2` |
| `ORDER BY a, floor(d)` | `(a=1, d=1.3, b=5, rn=1)` | `rn = 2` |
Both orderings have two columns, but they tie rows from different window
partitions. Could you require every `PARTITION BY` expression to appear in the
merge's ordering, and add both queries to `window_limits.slt`?
<details>
<summary>Both reproducers</summary>
```sql
SET datafusion.execution.target_partitions = 4;
SET datafusion.execution.batch_size = 1;
SET datafusion.optimizer.repartition_file_scans = false;
-- whether the wrong row shows depends on which hash partition each group
lands in; these values hit it
CREATE TABLE t1 (a INT, d INT, b INT) AS VALUES (1, 2, 3), (1, 1, 1), (1, 1,
2), (1, 1, 3);
CREATE TABLE t2 (a INT, d INT, b INT) AS VALUES (1, 2, 5);
-- returns (1, 1, 2, 5, 1); the row (a=1, d=2, b=5) has rn = 2 in the full
result
SELECT a, a2, d, b, rn FROM (
SELECT a, a AS a2, d, b, row_number() OVER (PARTITION BY a, d ORDER BY b
ROWS UNBOUNDED PRECEDING) AS rn
FROM (SELECT * FROM t1 UNION ALL SELECT * FROM t2)
) ORDER BY a, a2 LIMIT 3;
CREATE TABLE f1 (a INT, d DOUBLE, b INT) AS VALUES (1, 1.3, 3), (1, 1.0, 1),
(1, 1.0, 2), (1, 1.0, 3);
CREATE TABLE f2 (a INT, d DOUBLE, b INT) AS VALUES (1, 1.3, 5);
-- returns (1, 1.3, 5, 1); the row (a=1, d=1.3, b=5) has rn = 2 in the full
result
SELECT a, d, b, rn FROM (
SELECT a, d, b, row_number() OVER (PARTITION BY a, d ORDER BY b ROWS
UNBOUNDED PRECEDING) AS rn
FROM (SELECT * FROM f1 UNION ALL SELECT * FROM f2)
) ORDER BY a, floor(d) LIMIT 3;
```
</details>
--
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]