[ https://issues.apache.org/jira/browse/ARROW-16616?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17557141#comment-17557141 ]
Will Jones edited comment on ARROW-16616 at 6/21/22 9:56 PM: ------------------------------------------------------------- I'm a little cautious about the idea of {{Dataset.filter()}} returning a {{Dataset}}, since it mixes up the purpose of {{Dataset}} and {{Scanner}}. If it did, what would this return then? {code:python} ds.filter(ds.field("x") > 2).scan(filter=ds.field("y") < 3) {code} I think it might be better if {{Dataset.filter()}} returned a scanner with that filter. And then {{Scanner}} could also have {{filter()}} and {{project()}} methods to allow chaining. So you could do: {code:python} ( ds.filter(ds.field("x") > 2) .filter(ds.field("y") < 4) .project("x", "y", "z") .to_table() ) {code} What do you think of that? was (Author: willjones127): I'm a little cautious about the idea of {{Dataset.filter()}} returning a {{Dataset}}, since it mixes up the purpose of {{Dataset}} and {{Scanner}}. If it did, what would this return then? {code:python} ds.filter(ds.field("x") > 2).scan(filter=ds.field("y") < 3) {code} I think it might be better if {{Dataset.filter()}} returned a scanner with that filter. And then {{Scanner}} could also have {{filter()}} and {{project()}} methods to allow chaining. What do you think of that? > [Python] Allow lazy evaluation of filters in Dataset and add Datset.filter > method > --------------------------------------------------------------------------------- > > Key: ARROW-16616 > URL: https://issues.apache.org/jira/browse/ARROW-16616 > Project: Apache Arrow > Issue Type: Sub-task > Components: Python > Reporter: Alessandro Molina > Priority: Major > Labels: pull-request-available > Fix For: 9.0.0 > > Time Spent: 0.5h > Remaining Estimate: 0h > > To keep the {{Dataset}} api compatible with the {{Table}} one in terms of > analytics capabilities, we should add a {{Dataset.filter}} method. The > initial POC was based on {{_table_filter}} but that required materialising > all the {{Dataset}} content after filtering as it returned an > {{{}InMemoryDataset{}}}. > Given that {{Scanner}} can filter a dataset without actually materialising > the data until a final step happens, it would be good to have > {{Dataset.filter}} return some form of lazy dataset when the filter is only > stored aside and the Scanner is created when data is actually retrieved. > PS: Also update {{test_dataset_filter}} test to use the {{Dataset.filter}} > method -- This message was sent by Atlassian Jira (v8.20.7#820007)