Skip to content

Panic in a query with NATURAL JOIN (SQLancer) #14015

Closed

Description

@2010YOUY01

Describe the bug

See reproducer in datafusion-cli (compiled from latest main, commit hash 3f4297f)

DataFusion CLI v44.0.0
> create table t1(v1 int, v2 int);
0 row(s) fetched.
Elapsed 0.021 seconds.

> select v1 from t1 as tt1 natural join t1 as tt2 group by v1 order by v2;
thread 'main' panicked at /Users/yongting/Code/datafusion/datafusion/expr/src/logical_plan/plan.rs:909:17:
assertion `left == right` failed
  left: 3
 right: 2
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

To Reproduce

No response

Expected behavior

column reference v2 in order by clause is invalid, the query should return an error instead like

> select v1 from t1 group by v1 order by v2;
Schema error: No field named t1.v2. Valid fields are t1.v1.

Additional context

Found by SQLancer #11030

Activity

  1. jonahgao commented on Jan 6, 2025

    @jonahgao
    Member

    Panic occurred in add_missing_columns. Might be related to #10326

    I plan to investigate it further, thank you @2010YOUY01 for reporting it.

  2. self-assigned this
    on Jan 6, 2025
  3. alamb commented on Jan 6, 2025

    @alamb
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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