-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
feat(discover) Add equation support to SnQL #29394
Conversation
- This allows the snql query builder to accept equations - Had to introduce some wonky importing here to avoid circular imports - Otherwise the idea was to pass the parsed equations to the query builder which can then resolve the functions and columns as needed
# TODO: currently returning "resolved_equations" for the json syntax | ||
# once we're converted to SnQL this should only return parsed_equations | ||
parsed_equations.append(parsed_equation) |
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: Move this below the resolved_equations.append(...)
because it is now splitting apart the corresponding comment.
result = Function(equation.operator, [lhs, rhs], alias) | ||
return result | ||
|
||
def _resolve_equation_side(self, side: OperationSideType) -> Union[SelectType, float]: |
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: I think this is called an operand.
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'll update in a follow up PR, cause I've used side
in a buuunch of places
src/sentry/search/events/fields.py
Outdated
def is_equation_column(self, column: SelectType) -> bool: | ||
return isinstance(column, CurriedFunction) and column.alias.startswith("equation[") |
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.
If I recall correctly, equations have to contain at least 1 operator, meaning a literal is not a valid equation right?
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.
Yep! A valid equation has to contain at least 1 operator 👍
builder which can then resolve the functions and columns as needed