Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Union except and intersect #2845

Closed
saschahofmann opened this issue Jul 8, 2021 · 9 comments
Closed

Union except and intersect #2845

saschahofmann opened this issue Jul 8, 2021 · 9 comments

Comments

@saschahofmann
Copy link
Contributor

A lot (all?) backends support some kind of except/intersect UNION

E.g postgres https://www.postgresqltutorial.com/postgresql-union/
or bigquery https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#intersect

Does it make sense to implement these in the main repo? Do you have a feature freeze until the 2.0 release?

I could have a look at this myself if you agree this should go into ibis directly!

@datapythonista
Copy link
Contributor

Maybe not in the docs, but UNION is implemented in Ibis already.

@saschahofmann
Copy link
Contributor Author

Ahhh I see you implemented intersect and Except separately.! Yeah just discovered it in the code?

Sorry! I think this might be broken in Bigquery then but will test and write there separately

@datapythonista
Copy link
Contributor

Bigquery needs to be adapted to the last changes in Ibis, but other than that, that part should be working.

Should we close this issue, or is there anything else that is missing from what you requested here?

@saschahofmann
Copy link
Contributor Author

Yes sorry closing this. Needs to be addressed in BigQuery ibis-project/ibis-bigquery#87

@saschahofmann
Copy link
Contributor Author

saschahofmann commented Jul 8, 2021

Hey sorry,
I was just playing around with difference in bigquery and postgres. I can do things like this

table.difference(table2)

But if I try to create a projection like this

table.difference(table2).projection(['column1', 'column2']).compile()

I get a NotImplementedError: <class 'ibis.expr.operations.Difference'>

Originating from here https://github.com/ibis-project/ibis/blob/1.4.0/ibis/backends/base_sqlalchemy/compiler.py#L401

It works for Union any ideas how I can work around this e.g. with what if I want to run a filter on a difference query, @datapythonista ?

@saschahofmann
Copy link
Contributor Author

Note this is for ibis 1.4.0. since main looks very different this could be fixed there alread?

@datapythonista
Copy link
Contributor

Not so familiar with this part, from the code looks like it should be implemented, not sure what is missing. I don't think there has been any change in that part recently, other than moving code from one place to another. Happy to take PRs for this, before or after the release.

@saschahofmann
Copy link
Contributor Author

Ok I'll have a look

@saschahofmann
Copy link
Contributor Author

Will probably create a PR for this tomorrow just for completeness. I am monkey-patching 1.4.0 like this in our project right now

from ibis.backends.base_sqlalchemy import compiler

def _collect_Difference(self, expr, toplevel=False):
    if toplevel:
        raise NotImplementedError()


compiler.SelectBuilder._collect_Difference = _collect_Difference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants