akupchinskiy commented on PR #26201:
URL: https://github.com/apache/datafusion/pull/26201#issuecomment-6637180935
Another case this fixes: `DISTINCT ON` below a `UNION`. The rewrite makes
`a` nullable (`first_value` is always nullable) while the `Union` keeps the old
NOT NULL schema.
```sql
CREATE TABLE t (id BIGINT NOT NULL, a BIGINT NOT NULL, o BIGINT NOT NULL)
AS VALUES (1, 10, 1), (1, 11, 2), (2, 20, 1);
WITH d AS (SELECT DISTINCT ON (id) id, a FROM t ORDER BY id, o)
SELECT a FROM d UNION SELECT a FROM d;
```
On `main` (238ae32) it fails with `Internal error: Physical input schema
should be the same as the one converted from logical input schema. Differences:
field nullability at index 0 [a]: (physical) true vs (logical) false.`; on this
branch it returns `{10, 20}`. Might be worth a sqllogictest case, since it's
nullability rather than metadata.
--
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]