-
Notifications
You must be signed in to change notification settings - Fork 1.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(hogql): refactor macros and asterisks into "resolver" #15175
Conversation
4295ed8
to
2a85355
Compare
if len(node.chain) > 1: | ||
raise ResolverException(f"Cannot access fields on macro {macro.name} yet.") |
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.
This will be is already fixed in #15180
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.
Makes sense and looks good, there's just one thing I'm still not sure about: why we don't just use the standard "common table expression" for this? As this already is familiar in SQL world – definitely more than Lisp macros
That is a good question. We definitely could swap out the logic from "extract macros from WITH" to "embrace the WITH CTE-s". I initially embraced the macro approach since there were some ClickHouse limitations (e.g. no recursion) that I wanted to overcome. I'm willing to give this another look, and have added "Do we want to keep extracting macros from the WITH clause, or embrace CTE-s?" as a checkbox to tick. I'd leave that refactor for another PR though :). |
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.
Makes sense, let's get this in
Thanks! Very much related, when working on this - #15244 - any additional duplication of |
* master: feat(hogql): refactor macros and asterisks into "resolver" (#15175)
* master: (37 commits) fix: fix sprint planning issue template (#15271) fix: player skip buttons only ever showed right (#15269) chore: bump vm2 due to CVE (#15268) fix(person-query): don't query persons twice if we don't need to (#15265) fix(ch): stop running delete jobs while clickhouse is on an older version (#15239) chore(recordings): use cooperative-sticky rebalance strategy (#15260) fix: SESSION_RECORDING_BLOB_PROCESSING_TEAMS config handling (#15247) fix(flags): Some UX inconsistencies (#15255) fix: Recording share button (#15256) chore(deps): Update posthog-js to 1.54.0 (#15257) style(3000): Support keyboard navigation in sidebar (#15237) feat: Add support for opening bug report via URL (#15251) feat: Hedgebar (#14934) Fixed undefined default for window select (#15249) fix(data-exploration): prevent leave confirmation safeguard (#15250) chore: remove readonly setting defaults for hogql (#15246) feat(hogql): refactor macros and asterisks into "resolver" (#15175) feat(hogql): swap out toDateTime function (#15226) fix(insight-timeout-state): centralize query ID (#15240) Fix/forgot ingestion fixes (#15238) ...
Still draft
Problem
Expanding macros and
*
fields in a separate step from the resolver was causing maintainability issues. We had 3 stages in parallel:expand_macros
,resolve_types
,expand_asterisks
. For a good implementation, we'd need to call all 3 in parallel when adding something new in any of these steps --> new column added inexpand_asterisks
--> run all 3 again on the new node.Changes
expand_macros
,resolve_types
,expand_asterisks
) useCloningVisitor
, they're easy to merge.resolver.py
.transforms/asterisk.py
andtransforms/macros.py
intoresolver.py
, adapt as neededHow did you test this code?