-
Notifications
You must be signed in to change notification settings - Fork 48
refactor: Create class for column ids and column refs #1022
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
Conversation
5106edf
to
5465fa2
Compare
5465fa2
to
7c8af85
Compare
bigframes/core/expression.py
Outdated
@@ -31,6 +32,10 @@ def const( | |||
return ScalarConstantExpression(value, dtype or dtypes.infer_literal_type(value)) | |||
|
|||
|
|||
def deref_name(name: str) -> DerefOp: |
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.
nit: maybe just "deref" ? Because name is already indicated as a parameter
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.
sounds good, done
bigframes/core/expression.py
Outdated
raise ValueError(f"Type of variable {self.id} has not been fixed.") | ||
|
||
def bind_refs( | ||
self, bindings: Mapping[ids.ColumnId, Expression], check_bind_all: bool = True |
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.
Maybe we can rename "check_bind_all" (default true) to "allow_partial_bindings" (default false) ? The latter feels more expressive to me.
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.
yeah, that is clearer. converted all instance of this arg name
bigframes/core/identifiers.py
Outdated
return self.name | ||
|
||
@property | ||
def local_normalize(self) -> ColumnId: |
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 verbs are usually used for method names. Since this is a property, maybe "normalized()" ?
Or we could just remove the "property" decorator and makes it a true method.
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.
chnaged to 'normalized'
bigframes/core/identifiers.py
Outdated
|
||
@property | ||
def local_normalize(self) -> ColumnId: | ||
"""For use in compiler only. Normalizes to ColumnId referring ot sql name.""" |
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 like a typo: "..referring to sql name"
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.
fixed
bigframes/core/compile/compiled.py
Outdated
if any( | ||
map( | ||
is_window, | ||
map( |
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 if expression looks super long. Shall we just use a plain-old for loop?
for col in predicate.column_references:
if (is_window(self._get_ibis_column(col.sql))):
return ....
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.
yeah, went a bit overzealous with the nested maps, converted into loop
bigframes/core/compile/compiled.py
Outdated
@@ -1069,7 +1091,15 @@ def _to_ibis_expr( | |||
return table | |||
|
|||
def filter(self, predicate: ex.Expression) -> OrderedIR: | |||
if any(map(is_window, map(self._get_ibis_column, predicate.unbound_variables))): | |||
if any( |
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.
Probably can be replaced by a simple for loop too...
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.
converted to loop
LGTM. I only have some style nits for your to consider. |
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes #<issue_number_goes_here> 🦕