Git Product home page Git Product logo

Comments (6)

jonahgao avatar jonahgao commented on August 23, 2024 1

This should be a duplicate of #6543

from datafusion.

jayzhan211 avatar jayzhan211 commented on August 23, 2024 1

I think we can change expr from Debug to Display with this issue together. This todo is added in #11797

Expr::Unnest(Unnest { expr }) => {
    // TODO: use Display instead of Debug, there is non-unique expression name in projection issue.
    write!(f, "UNNEST({expr})")
}

from datafusion.

duongcongtoai avatar duongcongtoai commented on August 23, 2024

Although theoretically #6543 can solve this ticket, but i think the bug presented here comes from the internal implementation inside try_process_unnest function itself, and can be fixed within this function

CREATE TABLE unnest_table
AS VALUES
    ([1,2,3]);

query TT
explain select unnest(column1), unnest(column1) + 1 from unnest_table;
----
Current plan generated (which causes error)
logical_plan
01)Projection: unnest(unnest_table.column1), unnest(unnest_table.column1) + Int64(1)
02)--Unnest: lists[unnest(unnest_table.column1)] structs[]
03)----Projection: unnest_table.column1 AS unnest(unnest_table.column1), unnest_table.column1 AS unnest(unnest_table.column1)
04)------TableScan: unnest_table projection=[column1]

Better plan generated
logical_plan
01)Projection: unnest(unnest_table.column1), unnest(unnest_table.column1) + Int64(1)
02)--Unnest: lists[unnest(unnest_table.column1)] structs[]
03)----Projection: unnest_table.column1 AS unnest(unnest_table.column1)
04)------TableScan: unnest_table projection=[column1]

We also avoid unnecessary columns generated in the intermediate projection step

from datafusion.

duongcongtoai avatar duongcongtoai commented on August 23, 2024

let plan = LogicalPlanBuilder::from(intermediate_plan)

At this line, before create new projection nodes, we can deduplicate intermediate unnest expr within inner_projection_exprs

from datafusion.

duongcongtoai avatar duongcongtoai commented on August 23, 2024

take

from datafusion.

duongcongtoai avatar duongcongtoai commented on August 23, 2024

I also found a different error for the following queries:

select unnest(column1) + unnest(column1) from unnest_table;
External error: query failed: DataFusion error: Schema error: No field named unnest_table.column1. Valid fields are "unnest(unnest_table.column1)".

from datafusion.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.