-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix(modelling): Try any posthog table from modelling #31073
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
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.
PR Summary
This PR adds support for the numbers
table function in PostHog's modeling system by changing how table validation works in the modeling framework.
- Modified
get_or_create_query_parent_paths()
to check saved queries and warehouse tables first before falling back to PostHog tables - Changed PostHog table validation to use
get_table()
with exception handling instead of checking against a static list - Added a test case in
test_modeling.py
that verifiesnumbers(10)
is correctly identified as a parent table - Added
QueryError
import fromposthog.hogql.errors
to properly handle table resolution exceptions - Improved robustness by using the actual table resolution mechanism rather than static list checks
2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile
@@ -21,6 +21,7 @@ | |||
{"events"}, | |||
), | |||
("select 1", set()), | |||
("select * from numbers(10)", {"numbers"}), |
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 this may conflict with my earlier fix. But, by the way, this method will not fail on numbers
as it just extracts the names, doesn't actually check that the table exists (see my earlier fix which includes numbers
).
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.
Yeep - just resolved these
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.
Cool, but fyi, this test is not actually testing what this PR is fixing (as you can see by existing tests already covering numbers
)
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 i don't really understand how your test passed without my change 🤔
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.
Because the method in the test (get_parents_from_model_query
) is not checking that the tables are valid names, just resolving the names.
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.
Ah, I was looking at the wrong method 🤦 I'll fix
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 once conflicts are fixed
Problem
numbers
table functionChanges
Does this work well for both Cloud and self-hosted?
Yes
How did you test this code?
Added a test