-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
fix(hogql): correctly parse breakdown values with quotes for funnels #21101
Conversation
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! I'd actually suggest taking it a step further some other time before release, and moving as much python string interpolation in parse_expr
into placeholders as possible. This could avoid a bunch of random errors down the line.
Also some mypy troubles.
return [parse_expr(f"if(has({breakdown_values}, prop), prop, {other_aggregation}) as prop")] | ||
return [ | ||
parse_expr( | ||
f"if(has({{breakdown_values}}, prop), prop, {other_aggregation}) as prop", |
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.
The more things we can move to placeholders overall, the better. Could other_aggregation
also go? It's equally a constant. Same with possibly self._get_breakdown_prop()
above?
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.
Jup, I agree. Would be great to even have a lint rule warning about f-strings with parse_expr
.
For now I went over all usages of parse_expr
in funnels and checked that the interpolated strings work as expected e.g. there are a lot of places where some number is interpolated latest_{i}
and i
is validated via pydantic.
if normalize_url: | ||
regex = "[\\\\/?#]*$" | ||
expr = parse_expr( | ||
f"if( empty( replaceRegexpOne({{breakdown_value}}, '{regex}', '') ), '/', replaceRegexpOne({{breakdown_value}}, '{regex}', ''))", |
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.
regex
could also be passed in through a placeholder
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
Problem
Some HogQL funnel insights have been failing, as a breakdown value containing a single quote was parsed erroneously as
ast.Field
instead of the correctast.Constant
.Edit: checked all occurances of
parse_expr
in funnels and added similar fixes.Changes
Fixes it.
How did you test this code?
Added a test and verified with a local insight