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): really lazy tables #14927

Merged
merged 31 commits into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
cea1b4f
really lazy tables attempt 1
mariusandra Mar 25, 2023
4bda5f5
Merge branch 'master' into really-lazy-tables
mariusandra Mar 29, 2023
23b0ae6
lazy tables
mariusandra Mar 29, 2023
090fa40
can select if hogql
mariusandra Mar 29, 2023
0c31345
fix small test bugs
mariusandra Mar 29, 2023
81ffabd
more fixes
mariusandra Mar 29, 2023
20f0c10
Update query snapshots
github-actions[bot] Mar 29, 2023
14ca551
freeze time for a funnel
mariusandra Mar 30, 2023
43f3dae
dogfood
mariusandra Mar 30, 2023
3bd8645
fix more tests
mariusandra Mar 30, 2023
5332d13
move up
mariusandra Mar 30, 2023
7658fc1
fix last test
mariusandra Mar 30, 2023
96b35b9
few more fixes
mariusandra Mar 30, 2023
44cffb6
Merge branch 'master' into really-lazy-tables
mariusandra Mar 30, 2023
708dba2
dogfood
mariusandra Mar 30, 2023
627e4a7
few more fixes
mariusandra Mar 30, 2023
d13c383
don't overreach
mariusandra Mar 31, 2023
db35d1b
Update query snapshots
github-actions[bot] Mar 31, 2023
8143cf1
Merge branch 'master' into really-lazy-tables
mariusandra Apr 6, 2023
7123744
Merge branch 'master' into really-lazy-tables
mariusandra Apr 6, 2023
60bc435
Update query snapshots
github-actions[bot] Apr 6, 2023
4815bc6
Merge branch 'master' into really-lazy-tables
mariusandra Apr 6, 2023
7283dec
Update query snapshots
github-actions[bot] Apr 6, 2023
3568deb
Update UI snapshots for `chromium` (2)
github-actions[bot] Apr 6, 2023
06dc21e
Merge branch 'master' into really-lazy-tables
mariusandra Apr 6, 2023
ad87e61
Merge branch 'really-lazy-tables' of github.com:PostHog/posthog into …
mariusandra Apr 6, 2023
7d19306
Update UI snapshots for `chromium` (2)
github-actions[bot] Apr 6, 2023
4be7317
Merge branch 'master' into really-lazy-tables
mariusandra Apr 6, 2023
293a847
fix merge issues
mariusandra Apr 6, 2023
2c6ae82
Merge branch 'master' into really-lazy-tables
mariusandra Apr 6, 2023
f058242
Update query snapshots
github-actions[bot] Apr 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified frontend/public/blank-dashboard-hog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 17 additions & 5 deletions posthog/hogql/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
from posthog.hogql.database import (
DatabaseField,
FieldTraverser,
LazyTable,
LazyJoin,
StringJSONDatabaseField,
Table,
VirtualTable,
LazyTable,
)

# NOTE: when you add new AST fields or nodes, add them to the Visitor classes in visitor.py as well!
Expand Down Expand Up @@ -76,8 +77,10 @@ def get_child(self, name: str) -> Ref:
return AsteriskRef(table=self)
if self.has_child(name):
field = self.resolve_database_table().get_field(name)
if isinstance(field, LazyJoin):
return LazyJoinRef(table=self, field=name, lazy_join=field)
if isinstance(field, LazyTable):
return LazyTableRef(table=self, field=name, lazy_table=field)
return LazyTableRef(table=field)
if isinstance(field, FieldTraverser):
return FieldTraverserRef(table=self, chain=field.chain)
if isinstance(field, VirtualTable):
Expand All @@ -101,13 +104,20 @@ def resolve_database_table(self) -> Table:
return self.table_ref.table


class LazyTableRef(BaseTableRef):
class LazyJoinRef(BaseTableRef):
table: BaseTableRef
field: str
lazy_table: LazyTable
lazy_join: LazyJoin

def resolve_database_table(self) -> Table:
return self.lazy_join.join_table


class LazyTableRef(BaseTableRef):
table: LazyTable

def resolve_database_table(self) -> Table:
return self.lazy_table.table
return self.table


class VirtualTableRef(BaseTableRef):
Expand Down Expand Up @@ -328,6 +338,8 @@ class Call(Expr):


class JoinExpr(Expr):
ref: Optional[BaseTableRef | SelectQueryRef | SelectQueryAliasRef | SelectUnionQueryRef]

join_type: Optional[str] = None
table: Optional[Union["SelectQuery", "SelectUnionQuery", Field]] = None
alias: Optional[str] = None
Expand Down
Loading