my-ship-it opened a new issue, #1949:
URL: https://github.com/apache/cloudberry/issues/1949
### Apache Cloudberry version
main branch (recent build)
### What happened
With ORCA enabled, the backend crashes when a query filters on a set of
columns that is only partially covered by an extended statistics object
(`CREATE STATISTICS ... (dependencies)`). In the reproducer below the
statistics object covers `c0, c1` and the outer WHERE also references `c2`,
which is not covered.
With `optimizer = off` the query runs fine.
Found by SQLancer.
### What you think should happen instead
The query should run and return 0 rows (no row has `c1 = ''`). Cardinality
estimation must not assume every filtered column is present in the extended
statistics object.
### How to reproduce
```sql
CREATE TABLE t3 (c0 boolean, c1 text, c2 int) DISTRIBUTED BY (c0);
INSERT INTO t3 SELECT (g%2=0), 'x'||g, g FROM generate_series(1,100) g;
CREATE STATISTICS s0 (dependencies) ON c0, c1 FROM t3; -- covers c0, c1
only
ANALYZE t3;
SET optimizer = on;
SELECT * FROM (SELECT ALL t3.c0 AS t3c0, t3.c1 AS t3c1, t3.c2 AS t3c2
FROM t3
WHERE (t3.c0) IS TRUE
GROUP BY t3.c0, t3.c1, t3.c2
ORDER BY t3.c1) AS result
WHERE result.t3c0 = TRUE AND result.t3c1 = '' AND result.t3c2 > 0; -- c2
not covered by s0
-- backend crash
```
### Operating System
Linux
### Anything else
Found while running SQLancer against Cloudberry. See the related [DISCUSS]
thread on dev@ about adopting SQLancer for continuous testing.
### Are you willing to submit PR?
- [x] Yes, I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this project's [Code of
Conduct](https://www.apache.org/foundation/policies/conduct)
--
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]