Git Product home page Git Product logo

Comments (11)

ahirner avatar ahirner commented on July 23, 2024 2

I confirm that 1b396c4 fixes our more involved case in practice.

from arrow-datafusion.

duongcongtoai avatar duongcongtoai commented on July 23, 2024 1

I think this is related #10660

from arrow-datafusion.

ahirner avatar ahirner commented on July 23, 2024 1

Thanks for the pointers @duongcongtoai
I think the recursive and max_depth options can be a special workaround, but introduce a good amount of complexity. Fixing the push down makes single unnest composable in general.

from arrow-datafusion.

ahirner avatar ahirner commented on July 23, 2024 1

alternative query

Yes. The problem is that one can't move the filter to the inner query (views) or one shouldn't have to with other common sql constructs (sub queries, ctes).

from arrow-datafusion.

jayzhan211 avatar jayzhan211 commented on July 23, 2024 1

I think we can rewrite Unnest plan in push down filter

from arrow-datafusion.

ahirner avatar ahirner commented on July 23, 2024 1

Thanks for the swift action.

I just found out this second, that the change introduces a new issue when filtering on an unnested struct column (Optimizer rule 'common_sub_expression_eliminate' failed). Sorry for being late.

I'll file a new issue. The reproducer is less trivial as here.

from arrow-datafusion.

alamb avatar alamb commented on July 23, 2024 1

I confirm that 1b396c4 fixes our more involved case in practice.

Thank you @jayzhan211 for the quick response

from arrow-datafusion.

jayzhan211 avatar jayzhan211 commented on July 23, 2024

For this kind of query select unnest(unnest([[1],[1,2],[1,2,3]]));, I think we can follow what Duckdb does.

Unnest with recursive, and max_depth

select unnest([[1],[1,2],[1,2,3]], recursive := true);
or select unnest([[1],[1,2],[1,2,3]], max_depth := 2);

from arrow-datafusion.

jayzhan211 avatar jayzhan211 commented on July 23, 2024

@ahirner
I found an alternative query is to move filter into the query

select "unnest(v.column2)" from (select unnest(column2), column1 from v where column1=2);

query TT
explain select "unnest(v.column2)" from (select unnest(column2), column1 from v where column1=2);
----
logical_plan
01)Projection: unnest(v.column2)
02)--Unnest: lists[unnest(v.column2)] structs[]
03)----Projection: v.column2 AS unnest(v.column2), v.column1
04)------Filter: v.column1 = Int64(2)
05)--------TableScan: v projection=[column1, column2]
physical_plan
01)ProjectionExec: expr=[unnest(v.column2)@0 as unnest(v.column2)]
02)--UnnestExec
03)----RepartitionExec: partitioning=RoundRobinBatch(4), input_partitions=1
04)------ProjectionExec: expr=[column2@1 as unnest(v.column2), column1@0 as column1]
05)--------CoalesceBatchesExec: target_batch_size=8192
06)----------FilterExec: column1@0 = 2
07)------------MemoryExec: partitions=1, partition_sizes=[1]

Given that, it might not be necessary to support pushing down outer filter

from arrow-datafusion.

alamb avatar alamb commented on July 23, 2024

PR to do so: #10974

from arrow-datafusion.

ahirner avatar ahirner commented on July 23, 2024

Added issue that's quite minimal but maybe not entirely minimal: #10990

from arrow-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.