Skip to content

Optimizer rule scalar_subquery_to_join generates a different schema #6606

Closed

Description

@jonahgao

Describe the bug

Internal error: Optimizer rule 'scalar_subquery_to_join' failed, due to generate a different schema,

original schema: DFSchema { fields: [DFField { qualifier: None, field: Field { name: "t.a > AVG(t.a)", data_type: Boolean, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} } }], metadata: {} },

new schema : DFSchema { fields: [DFField { qualifier: None, field: Field { name: "t.a > __scalar_sq_1.__value", data_type: Boolean, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} } }], metadata: {} }.

This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker

To Reproduce

DataFusion CLI v26.0.0
❯ create table t(a int);
0 rows in set. Query took 0.005 seconds.

❯ select a > (select avg(a) from t) from t;
scalar_subquery_to_join
caused by
Internal error: Optimizer rule 'scalar_subquery_to_join' failed, due to generate a different schema, original schema: DFSchema { fields: [DFField { qualifier: None, field: Field { name: "t.a > AVG(t.a)", data_type: Boolean, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} } }], metadata: {} }, new schema: DFSchema { fields: [DFField { qualifier: None, field: Field { name: "t.a > __scalar_sq_1.__value", data_type: Boolean, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} } }], metadata: {} }. This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker

Expected behavior

No response

Additional context

No response

Activity

  1. mingmwang commented on Jun 12, 2023

    @mingmwang
    Contributor

    I will take a look

  2. parkma99 commented on Jun 12, 2023

    @parkma99
    Contributor

    I will take a look

    I think it's because the code L98 to L102 should check subquery is a scalar query or not.

  3. mingmwang commented on Jun 25, 2023

    @mingmwang
    Contributor

    @parkma99
    I think the issue is fixed after this PR #6457.
    I had verified and the error is gone.

  4. mingmwang commented on Jun 25, 2023

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

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