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

feat(hogql): Add paths query runner #19761

Merged
merged 23 commits into from
Jan 19, 2024
Merged

Conversation

webjunkie
Copy link
Contributor

Problem

We want to convert the paths query to HogQL as well. See #19641

Changes

  • add paths query runner

How did you test this code?

  • tbd

Copy link
Contributor

github-actions bot commented Jan 15, 2024

Size Change: +44 B (0%)

Total Size: 2 MB

ℹ️ View Unchanged
Filename Size Change
frontend/dist/toolbar.js 2 MB +44 B (0%)

compressed-size-action

@webjunkie webjunkie marked this pull request as ready for review January 18, 2024 08:21
@webjunkie
Copy link
Contributor Author

@mariusandra I was starting on the tests but got heavily sidetracked with Celery work. Maybe you can take a look at this here already, and we can merge it as first step?

Copy link
Collaborator

@mariusandra mariusandra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work porting this query. I think we can merge it in... after just one category of fixes: I'd remove as many f-string usages as possible in parse_expr calls, and replace them with placeholders. It's generally safer. f-strings might be "faster", and if you inject SQL inside a HogQL query... then it's the same as sending garbage under the "SQL" tab, so there's no extra danger. However there will eventually be someone who manages to get unescaped quotes or other bad symbols into here, causing the query to just fail.

@@ -431,6 +431,7 @@ const handleQuerySourceUpdateSideEffects = (
* Date range change side effects.
*/
if (
!isPathsQuery(currentState) && // TODO: Apply side logic more elegantly
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It added an interval even if there was none. And it's not supported by paths.

Comment on lines +467 to +473
if len(node.exprs) == 1:
return self.visit(node.exprs[0])
return f"and({', '.join([self.visit(expr) for expr in node.exprs])})"

def visit_or(self, node: ast.Or):
if len(node.exprs) == 1:
return self.visit(node.exprs[0])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌

posthog/hogql_queries/insights/paths_query_runner.py Outdated Show resolved Hide resolved
posthog/hogql_queries/insights/paths_query_runner.py Outdated Show resolved Hide resolved
posthog/hogql_queries/insights/paths_query_runner.py Outdated Show resolved Hide resolved
posthog/hogql_queries/insights/paths_query_runner.py Outdated Show resolved Hide resolved
@mariusandra
Copy link
Collaborator

Also, it's now a race between this PR and this one. I'm not sure which should go in first, and who should fix the other 😅

Copy link
Collaborator

@mariusandra mariusandra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@webjunkie webjunkie enabled auto-merge (squash) January 19, 2024 15:11
@webjunkie webjunkie merged commit eb93490 into master Jan 19, 2024
99 checks passed
@webjunkie webjunkie deleted the feature/hogql-paths-query branch January 19, 2024 15:25
Copy link

sentry-io bot commented Jan 22, 2024

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ CHQueryErrorQueryWasCancelled: Code: 394. /api/projects/{parent_lookup_team_id}/query/ View Issue

Did you find this useful? React with a 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants