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

(Enhancement) Use a sql query as an expression #1731

Closed
niviksha opened this Issue Mar 15, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@niviksha
Copy link

commented Mar 15, 2019

Is there a way for ibis to have an expression simply be a static, pre-existing SQL query? e.g. today, the primary workflow for ibis (in our omnisci/mapd backend) is to generate sql via the compilation path, and i get that the primary use case is as a deferred expression system, e.g. the typical flow is

conn = ibis.mapd.conn(....)
t = conn.table('tbl')
expr = t[t.colA > 50].group_by(t.colB).aggregate(t.count())...
output_df = expr.execute()

however, there are several cases where we find ourselves wanting a pre-existing SQL query to be the 'basis' of an expression - e.g.

query_str = 'select a, b, count(*) as ct from tbl where ... group by a,b having ...'
expr_query = expr_from_query_string(query) #(A 'pre-compiled' expression
expr2 = expr_query[(ct > 50) & (a == 'foo)] 

ideally should generate a query with a CTE for query_str i.e the above when compiled should return something like

WITH t0 as (
select a, b, count(*) as ct from tbl where ... group by a,b having ...'
) select * from t0 where t0.a == 'foo' and t0.ct > 50

@niviksha niviksha changed the title Can ibis use a sql query as an expression (Enhancement) Use a sql query as an expression Mar 17, 2019

@xmnlab

This comment has been minimized.

Copy link
Collaborator

commented Mar 18, 2019

not sure if it is what SQLClient.sql does. I am going to investigate that.

@xmnlab xmnlab self-assigned this Mar 18, 2019

cpcloud added a commit that referenced this issue Mar 22, 2019

[MAPD] Added SQL method for mapd backend
Resolves #1731
Author: Ivan Ogasawara <ivan.ogasawara@gmail.com>

Closes #1736 from xmnlab/add_client_sql_mapd and squashes the following commits:

968f1b9 [Ivan Ogasawara] Added sql method for mapd backend.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.