-
Notifications
You must be signed in to change notification settings - Fork 590
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
ENH: Scalar parameters #1075
ENH: Scalar parameters #1075
Conversation
87676c4
to
77eb251
Compare
923bd61
to
34c332a
Compare
9cdebaf
to
f60a101
Compare
|
this ready to merge? |
|
@wesm can you review when you get a chance? |
|
Looking |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good; main comments are around reducing the number of points of contact with the params object
ibis/expr/types.py
Outdated
|
|
||
| Returns | ||
| ------- | ||
| Expr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ScalarExpr?
ibis/impala/compiler.py
Outdated
|
|
||
| # ORDER BY and LIMIT | ||
| order_frag = self.format_postamble() | ||
| order_frag = self.format_postamble(params=params) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a lot of parameter "threading". Any reason to have this as an argument versus a self.params when the query is being compiled?
ibis/impala/ddl.py
Outdated
| @@ -774,7 +774,7 @@ def __init__(self, database, like=None, aggregate=False): | |||
| self.like = like | |||
| self.aggregate = aggregate | |||
|
|
|||
| def compile(self): | |||
| def compile(self, params=None): | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like these parameters should all be encapsulated in the DDL object, so passing params into ibis.impala.compiler.build_ast is all that's needed.
| @@ -87,6 +89,9 @@ def execute_with_scope(expr, scope, **kwargs): | |||
| if op in scope: | |||
| return scope[op] | |||
|
|
|||
| if context is None: | |||
| context = ctx.Summarize() | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might try to make a more clear name for "context". This is more of an aggregation style than anything
| def test_scalar_parameter(t, df, raw_value): | ||
| value = ibis.param(dt.double) | ||
| expr = t.float64_with_zeros == value | ||
| result = expr.execute(params={value: raw_value}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about named parameters (versus having to use the param object as a key)? Can be follow up work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can support both. I think we can implement the named version as a special case of unnamed. Implemented the dict API version first because it's more general since it doesn't care about the name of the value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense.
ibis/sql/alchemy.py
Outdated
| @@ -879,26 +880,26 @@ def __init__(self, *args, **kwargs): | |||
| self.exists = kwargs.pop('exists', False) | |||
| super(AlchemySelect, self).__init__(*args, **kwargs) | |||
|
|
|||
| def compile(self): | |||
| def compile(self, params=None): | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.params instead? It might be simpler to have
bound_ddl = ddl.with_params(new_params) then having the parameter threaded everywhere
|
@wesm I've refactored to pass params to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. thanks!
Closes #53