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): support join USING #21916
base: master
Are you sure you want to change the base?
Conversation
🔍 Existing Issues For ReviewYour pull request is modifying functions with the following pre-existing issues: 📄 File: posthog/hogql/printer.py
📄 File: posthog/hogql/resolver.py (Click to Expand)
Did you find this useful? React with a 👍 or 👎 |
This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the |
Unstale please |
b28b30d
to
28595ed
Compare
@@ -514,6 +510,13 @@ posthog/hogql/test/test_resolver.py:0: error: Incompatible types in assignment ( | |||
posthog/hogql/test/test_resolver.py:0: error: "TestResolver" has no attribute "snapshot" [attr-defined] | |||
posthog/hogql/test/test_resolver.py:0: error: Incompatible types in assignment (expression has type "Expr", variable has type "SelectQuery") [assignment] | |||
posthog/hogql/test/test_resolver.py:0: error: "TestResolver" has no attribute "snapshot" [attr-defined] | |||
posthog/hogql/test/test_resolver.py:0: error: Item "None" of "JoinExpr | None" has no attribute "next_join" [union-attr] |
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.
IMO it doesn't make sense and will reduce readability if I asserted in tests that these fields are not None, but I could do it.
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.
Yup that's fine. I agree that additional asserts wouldn't help code quality.
posthog/hogql/resolver.py
Outdated
node = cast(ast.JoinExpr, clone_expr(node)) | ||
if node.constraint and node.constraint.constraint_type == "USING": | ||
# visit USING constraint before adding the table to avoid ambiguous names | ||
node.constraint = self.visit_join_constraint(node.constraint) |
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.
visit_join_constraint
instead of visit
to have correct types - visit returns Expr while visit_join_contraint returns JoinContraint
@thmsobrmlr PTAL! About the failing tests - it seems like e2e tests don't recompile the c++ parser. These tests fail with the following error
But they finish successfully for me locally. Maybe there's a way to fix this? |
@Twixes Any hints on what's going on here? |
Problem
#20660
Changes
Does this work well for both Cloud and self-hosted?
Yes
How did you test this code?
Automated tests