Skip to content

Panic when an invalid expression in GROUP BY clause (SQLancer) #12699

@2010YOUY01

Description

@2010YOUY01

Describe the bug

See the reproducer in datafusion-cli (compiled from the latest main, commit 0242767)

DataFusion CLI v42.0.0
> select 1 group by substr('' || false);

thread 'main' panicked at /Users/yongting/Desktop/code/my_datafusion/arrow-datafusion/datafusion/functions/src/unicode/substr.rs:113:74:
index out of bounds: the len is 1 but the index is 1
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This can also be triggered if substr is in WHERE clause

> select 1 where substr('' || false);
thread 'main' panicked at /Users/yongting/Desktop/code/my_datafusion/arrow-datafusion/datafusion/functions/src/unicode/substr.rs:113:74:
index out of bounds: the len is 1 but the index is 1
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

To Reproduce

No response

Expected behavior

substr() function expression is provided with invalid argument(it's not allowed to take only 1 argument), so the query should return the planning error

Additional context

Found by SQLancer #11030

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions