apache / apache/datafusion

optimizer panic with certain query(`count(count(x))/y`)

Open
#17,166 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
9.3k
Forks
2.4k
Avg merge
3d 7h
Merged PRs (30d)
344

Description

### Describe the bug

This bug involve user defined node as leaf node and a slightly complex query, which will panic with `index out of bounds: the len is 2 but the index is 2` when trying to optimize this query.

this bug only appear in `datafusion="45.0.0"`, later version(>= 46.0.0) doesn't appear to have this bug, however I fail to found related fixes to it in changelog of 46.0.0, so put it in here just in case it isn't fully fixed.

### To Reproduce

Put lib.rs and Cargo.toml to a blank project and can reproduce this pnaic, backtrace also included

[backtrace.log](https://github.com/user-attachments/files/21751830/backtrace.log)
[lib.rs.txt](https://github.com/user-attachments/files/21751807/lib.rs.txt)
[Cargo.toml.txt](https://github.com/user-attachments/files/21751808/Cargo.toml.txt)

### Expected behavior

not panic

### Additional context

If this bug is clearly fixed in later version, could anyone point me to the pr that fix this? And feel free to close this issue in that case

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the panic from the attached lib.rs.txt and Cargo.toml.txt with DataFusion 45.0.0, then compare the behavior with version 46.0.0 and inspect the attached backtrace.log. Done means the query no longer panics, or the existing fix and related pull request are identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.