From 7b0fde331c1343232d8e9ae8a78ff7468e49e330 Mon Sep 17 00:00:00 2001 From: Marius Andra Date: Mon, 20 Nov 2023 16:29:51 +0100 Subject: [PATCH 01/15] fix alias --- posthog/hogql/resolver.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/posthog/hogql/resolver.py b/posthog/hogql/resolver.py index f48320df01ee2..fd8875bffc5be 100644 --- a/posthog/hogql/resolver.py +++ b/posthog/hogql/resolver.py @@ -134,6 +134,8 @@ def visit_select_query(self, node: ast.SelectQuery): alias = new_expr.type.name elif isinstance(new_expr, ast.Alias): alias = new_expr.alias + else: + alias = None if alias: if isinstance(new_expr, ast.Alias) and new_expr.hidden: From 3b609803902b69e577baeeb130d64b20b71560b6 Mon Sep 17 00:00:00 2001 From: Marius Andra Date: Tue, 21 Nov 2023 15:22:23 +0100 Subject: [PATCH 02/15] progress --- posthog/hogql/ast.py | 10 +++- posthog/hogql/printer.py | 38 ++++++++++++- posthog/hogql/resolver.py | 57 ++++++++++--------- .../hogql/test/__snapshots__/test_query.ambr | 36 ++++++------ posthog/hogql/test/test_modifiers.py | 20 ++++--- posthog/hogql/test/test_query.py | 2 +- .../test/__snapshots__/test_lazy_tables.ambr | 12 ++-- .../__snapshots__/test_property_types.ambr | 10 ++-- 8 files changed, 115 insertions(+), 70 deletions(-) diff --git a/posthog/hogql/ast.py b/posthog/hogql/ast.py index 58f36d00b0adb..03533dbba0c0a 100644 --- a/posthog/hogql/ast.py +++ b/posthog/hogql/ast.py @@ -123,6 +123,8 @@ class SelectQueryType(Type): aliases: Dict[str, FieldAliasType] = field(default_factory=dict) # all types a select query exports columns: Dict[str, Type] = field(default_factory=dict) + # these column have an explicit alias and can't be overridden + columns_with_explicit_alias: Dict[str, bool] = field(default_factory=dict) # all from and join, tables and subqueries with aliases tables: Dict[str, TableOrSelectType] = field(default_factory=dict) ctes: Dict[str, CTE] = field(default_factory=dict) @@ -346,9 +348,11 @@ class LambdaArgumentType(Type): class Alias(Expr): alias: str expr: Expr - # Hidden aliases are created when HogQL invisibly renames fields, e.g "events.timestamp" gets turned into a - # "toDateTime(...) as timestamp". Unlike normal aliases, hidden aliases can be overriden. Visible aliases will throw - # if overridden, hidden ones will noop. Hidden aliases are shown if used as select columns in a subquery. + """ + Aliases are "hidden" if they're automatically created by HogQL when abstracting fields. + E.g. "events.timestamp" gets turned into a "toTimeZone(events.timestamp, 'UTC') AS timestamp". + Hidden aliases are printed only when printing the columns of a SELECT query in the ClickHouse dialect. + """ hidden: bool = False diff --git a/posthog/hogql/printer.py b/posthog/hogql/printer.py index 17c8f4118f01a..7f5121ec8fab7 100644 --- a/posthog/hogql/printer.py +++ b/posthog/hogql/printer.py @@ -229,11 +229,43 @@ def visit_select_query(self, node: ast.SelectQuery): else: where = ast.And(exprs=[extra_where, where]) else: - raise HogQLException(f"Invalid where of type {type(extra_where).__name__} returned by join_expr") + raise HogQLException( + f"Invalid where of type {type(extra_where).__name__} returned by join_expr", node=visited_join.where + ) next_join = next_join.next_join - columns = [self.visit(column) for column in node.select] if node.select else ["1"] + if node.select: + if self.dialect == "clickhouse": + # Gather all visible aliases. Make visible the last occurrence of each unique hidden alias. + visible_aliases = {} + for alias in reversed(node.select): + if isinstance(alias, ast.Alias): + if not visible_aliases.get(alias.alias, None) or not alias.hidden: + visible_aliases[alias.alias] = alias + + columns = [] + for column in node.select: + if isinstance(column, ast.Alias): + if visible_aliases.get(column.alias) == column: + if column.hidden: + if ( + isinstance(column.expr, ast.Field) + and isinstance(column.expr.type, ast.FieldType) + and column.expr.type.name == column.alias + ): + # Unhide if really the same name for the field and the alias + column = column.expr + else: + column = cast(ast.Alias, clone_expr(column)) + column.hidden = False + else: + column = column.expr + columns.append(self.visit(column)) + else: + columns = [self.visit(column) for column in node.select] + else: + columns = ["1"] window = ( ", ".join( [f"{self._print_identifier(name)} AS ({self.visit(expr)})" for name, expr in node.window_exprs.items()] @@ -1102,6 +1134,8 @@ def _is_nullable(self, node: ast.Expr) -> bool: return True elif isinstance(node.type, ast.FieldType): return node.type.is_nullable() + elif isinstance(node, ast.Alias): + return self._is_nullable(node.expr) # we don't know if it's nullable, so we assume it can be return True diff --git a/posthog/hogql/resolver.py b/posthog/hogql/resolver.py index fd8875bffc5be..fe9ab56585f7f 100644 --- a/posthog/hogql/resolver.py +++ b/posthog/hogql/resolver.py @@ -118,7 +118,6 @@ def visit_select_query(self, node: ast.SelectQuery): new_node.array_join_list = [self.visit(expr) for expr in node.array_join_list] # Visit all the "SELECT a,b,c" columns. Mark each for export in "columns". - hidden_aliases = {} for expr in node.select or []: new_expr = self.visit(expr) @@ -138,23 +137,18 @@ def visit_select_query(self, node: ast.SelectQuery): alias = None if alias: + # Remember the first visible or last hidden expr for each alias if isinstance(new_expr, ast.Alias) and new_expr.hidden: - hidden_aliases[alias] = new_expr + if alias not in node_type.columns or not node_type.columns_with_explicit_alias.get(alias, False): + node_type.columns[alias] = new_expr.type + node_type.columns_with_explicit_alias[alias] = False else: node_type.columns[alias] = new_expr.type + node_type.columns_with_explicit_alias[alias] = True # add the column to the new select query new_node.select.append(new_expr) - # this dict will contain the last used hidden alias with this name - for key, hidden_alias in hidden_aliases.items(): - # if no column took this alias, unhide it - if key not in node_type.columns: - node_type.columns[key] = hidden_alias.type - hidden_alias.hidden = False - if isinstance(hidden_alias.type, ast.FieldAliasType): - hidden_alias.type.hidden = False - # :TRICKY: Make sure to clone and visit _all_ SelectQuery nodes. new_node.where = self.visit(node.where) new_node.prewhere = self.visit(node.prewhere) @@ -483,11 +477,12 @@ def visit_field(self, node: ast.Field): type=ast.FieldAliasType(alias=node.type.name, type=node.type), ) elif isinstance(node.type, ast.PropertyType): + property_alias = "__".join(node.type.chain) return ast.Alias( - alias=node.type.chain[-1], + alias=property_alias, expr=node, hidden=True, - type=ast.FieldAliasType(alias=node.type.chain[-1], type=node.type), + type=ast.FieldAliasType(alias=property_alias, type=node.type), ) return node @@ -495,40 +490,48 @@ def visit_field(self, node: ast.Field): def visit_array_access(self, node: ast.ArrayAccess): node = super().visit_array_access(node) + array = node.array + while isinstance(array, ast.Alias): + array = array.expr + if ( - isinstance(node.array, ast.Field) + isinstance(array, ast.Field) and isinstance(node.property, ast.Constant) and (isinstance(node.property.value, str) or isinstance(node.property.value, int)) and ( - (isinstance(node.array.type, ast.PropertyType)) + (isinstance(array.type, ast.PropertyType)) or ( - isinstance(node.array.type, ast.FieldType) + isinstance(array.type, ast.FieldType) and isinstance( - node.array.type.resolve_database_field(), + array.type.resolve_database_field(), StringJSONDatabaseField, ) ) ) ): - node.array.chain.append(node.property.value) - node.array.type = node.array.type.get_child(node.property.value) - return node.array + array.chain.append(node.property.value) + array.type = array.type.get_child(node.property.value) + return array return node def visit_tuple_access(self, node: ast.TupleAccess): node = super().visit_tuple_access(node) - if isinstance(node.tuple, ast.Field) and ( - (isinstance(node.tuple.type, ast.PropertyType)) + tuple = node.tuple + while isinstance(tuple, ast.Alias): + tuple = tuple.expr + + if isinstance(tuple, ast.Field) and ( + (isinstance(tuple.type, ast.PropertyType)) or ( - isinstance(node.tuple.type, ast.FieldType) - and isinstance(node.tuple.type.resolve_database_field(), StringJSONDatabaseField) + isinstance(tuple.type, ast.FieldType) + and isinstance(tuple.type.resolve_database_field(), StringJSONDatabaseField) ) ): - node.tuple.chain.append(node.index) - node.tuple.type = node.tuple.type.get_child(node.index) - return node.tuple + tuple.chain.append(node.index) + tuple.type = tuple.type.get_child(node.index) + return tuple return node diff --git a/posthog/hogql/test/__snapshots__/test_query.ambr b/posthog/hogql/test/__snapshots__/test_query.ambr index 2f2faaf5bb33a..d656bc1eec6b2 100644 --- a/posthog/hogql/test/__snapshots__/test_query.ambr +++ b/posthog/hogql/test/__snapshots__/test_query.ambr @@ -52,7 +52,7 @@ # name: TestQuery.test_query_distinct ' - SELECT DISTINCT persons.properties___sneaky_mail + SELECT DISTINCT persons.properties___sneaky_mail AS sneaky_mail FROM ( SELECT person.id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, %(hogql_val_0)s), ''), 'null'), '^"|"$', '') AS properties___sneaky_mail, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, %(hogql_val_1)s), ''), 'null'), '^"|"$', '') AS properties___random_uuid FROM person @@ -71,7 +71,7 @@ # name: TestQuery.test_query_joins_events_e_pdi ' - SELECT e.event, toTimeZone(e.timestamp, %(hogql_val_0)s), e__pdi.distinct_id, e__pdi.person_id + SELECT e.event, toTimeZone(e.timestamp, %(hogql_val_0)s) AS timestamp, e__pdi.distinct_id, e__pdi.person_id FROM events AS e INNER JOIN ( SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id FROM person_distinct_id2 @@ -86,7 +86,7 @@ # name: TestQuery.test_query_joins_events_pdi ' - SELECT events.event, toTimeZone(events.timestamp, %(hogql_val_0)s), events__pdi.distinct_id, events__pdi.person_id + SELECT events.event, toTimeZone(events.timestamp, %(hogql_val_0)s) AS timestamp, events__pdi.distinct_id, events__pdi.person_id FROM events INNER JOIN ( SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id FROM person_distinct_id2 @@ -101,7 +101,7 @@ # name: TestQuery.test_query_joins_events_pdi_e_person_properties ' - SELECT e.event, toTimeZone(e.timestamp, %(hogql_val_1)s), e__pdi.distinct_id, e__pdi__person.properties___sneaky_mail + SELECT e.event, toTimeZone(e.timestamp, %(hogql_val_1)s) AS timestamp, e__pdi.distinct_id, e__pdi__person.properties___sneaky_mail AS sneaky_mail FROM events AS e INNER JOIN ( SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id FROM person_distinct_id2 @@ -125,7 +125,7 @@ # name: TestQuery.test_query_joins_events_pdi_person ' - SELECT events.event, toTimeZone(events.timestamp, %(hogql_val_0)s), events__pdi.distinct_id, events__pdi__person.id + SELECT events.event, toTimeZone(events.timestamp, %(hogql_val_0)s) AS timestamp, events__pdi.distinct_id, events__pdi__person.id FROM events INNER JOIN ( SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id FROM person_distinct_id2 @@ -146,7 +146,7 @@ # name: TestQuery.test_query_joins_events_pdi_person_properties ' - SELECT events.event, toTimeZone(events.timestamp, %(hogql_val_1)s), events__pdi.distinct_id, events__pdi__person.properties___sneaky_mail + SELECT events.event, toTimeZone(events.timestamp, %(hogql_val_1)s) AS timestamp, events__pdi.distinct_id, events__pdi__person.properties___sneaky_mail AS sneaky_mail FROM events INNER JOIN ( SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id FROM person_distinct_id2 @@ -170,7 +170,7 @@ # name: TestQuery.test_query_joins_events_person_properties ' - SELECT e.event, toTimeZone(e.timestamp, %(hogql_val_1)s), e__pdi__person.properties___sneaky_mail + SELECT e.event, toTimeZone(e.timestamp, %(hogql_val_1)s) AS timestamp, e__pdi__person.properties___sneaky_mail AS sneaky_mail FROM events AS e INNER JOIN ( SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id FROM person_distinct_id2 @@ -194,7 +194,7 @@ # name: TestQuery.test_query_joins_events_person_properties_in_aggregration ' - SELECT s__pdi__person.properties___sneaky_mail, count() + SELECT s__pdi__person.properties___sneaky_mail AS sneaky_mail, count() FROM events AS s INNER JOIN ( SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id FROM person_distinct_id2 @@ -219,7 +219,7 @@ # name: TestQuery.test_query_joins_pdi ' - SELECT e.event, toTimeZone(e.timestamp, %(hogql_val_0)s), pdi.person_id + SELECT e.event, toTimeZone(e.timestamp, %(hogql_val_0)s) AS timestamp, pdi.person_id FROM events AS e INNER JOIN ( SELECT person_distinct_id2.distinct_id, argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id FROM person_distinct_id2 @@ -234,7 +234,7 @@ # name: TestQuery.test_query_joins_pdi_person_properties ' - SELECT pdi.distinct_id, pdi__person.properties___sneaky_mail + SELECT pdi.distinct_id, pdi__person.properties___sneaky_mail AS sneaky_mail FROM person_distinct_id2 AS pdi INNER JOIN ( SELECT person.id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, %(hogql_val_0)s), ''), 'null'), '^"|"$', '') AS properties___sneaky_mail FROM person @@ -253,7 +253,7 @@ # name: TestQuery.test_query_joins_pdi_persons ' - SELECT pdi.distinct_id, toTimeZone(pdi__person.created_at, %(hogql_val_0)s) + SELECT pdi.distinct_id, toTimeZone(pdi__person.created_at, %(hogql_val_0)s) AS created_at FROM person_distinct_id2 AS pdi INNER JOIN ( SELECT argMax(person.created_at, person.version) AS created_at, person.id AS id FROM person @@ -269,7 +269,7 @@ # name: TestQuery.test_query_joins_simple ' - SELECT e.event, toTimeZone(e.timestamp, %(hogql_val_0)s), pdi.distinct_id, p.id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(p.properties, %(hogql_val_1)s), ''), 'null'), '^"|"$', '') + SELECT e.event, toTimeZone(e.timestamp, %(hogql_val_0)s) AS timestamp, pdi.distinct_id, p.id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(p.properties, %(hogql_val_1)s), ''), 'null'), '^"|"$', '') AS sneaky_mail FROM events AS e LEFT JOIN person_distinct_id2 AS pdi ON equals(pdi.distinct_id, e.distinct_id) LEFT JOIN person AS p ON equals(p.id, pdi.person_id) WHERE and(equals(p.team_id, 420), equals(pdi.team_id, 420), equals(e.team_id, 420)) LIMIT 100 @@ -293,7 +293,7 @@ # name: TestQuery.test_query_select_person_with_joins_without_poe ' - SELECT events.event, toTimeZone(events.timestamp, %(hogql_val_1)s), events__pdi__person.id, events__pdi__person.properties___sneaky_mail + SELECT events.event, toTimeZone(events.timestamp, %(hogql_val_1)s) AS timestamp, events__pdi__person.id, events__pdi__person.properties___sneaky_mail AS sneaky_mail FROM events INNER JOIN ( SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id FROM person_distinct_id2 @@ -317,7 +317,7 @@ # name: TestQuery.test_query_select_person_with_poe_without_joins ' - SELECT events.event, toTimeZone(events.timestamp, %(hogql_val_0)s), events.person_id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.person_properties, %(hogql_val_1)s), ''), 'null'), '^"|"$', '') + SELECT events.event, toTimeZone(events.timestamp, %(hogql_val_0)s) AS timestamp, events.person_id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.person_properties, %(hogql_val_1)s), ''), 'null'), '^"|"$', '') AS sneaky_mail FROM events WHERE equals(events.team_id, 420) LIMIT 10 @@ -327,7 +327,7 @@ # name: TestQuery.test_select_person_on_events ' - SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(s.person_properties, %(hogql_val_0)s), ''), 'null'), '^"|"$', ''), count() + SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(s.person_properties, %(hogql_val_0)s), ''), 'null'), '^"|"$', '') AS sneaky_mail, count() FROM events AS s WHERE equals(s.team_id, 420) GROUP BY replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(s.person_properties, %(hogql_val_1)s), ''), 'null'), '^"|"$', '') @@ -366,7 +366,7 @@ # name: TestQuery.test_tuple_access ' - SELECT col_a, arrayZip((sumMap(g.1, g.2) AS x).1, x.2) AS r + SELECT col_a, arrayZip((sumMap((g).1, (g).2) AS x).1, x.2) AS r FROM ( SELECT col_a, groupArray(tuple(col_b, col_c)) AS g FROM ( @@ -385,7 +385,7 @@ SELECT PIVOT_FUNCTION_2.col_a, PIVOT_FUNCTION_2.r FROM ( - SELECT PIVOT_FUNCTION_1.col_a, arrayZip((sumMap(PIVOT_FUNCTION_1.g.1, PIVOT_FUNCTION_1.g.2) AS x).1, x.2) AS r + SELECT PIVOT_FUNCTION_1.col_a, arrayZip((sumMap((PIVOT_FUNCTION_1.g).1, (PIVOT_FUNCTION_1.g).2) AS x).1, x.2) AS r FROM ( SELECT PIVOT_TABLE_COL_ABC.col_a, groupArray(tuple(PIVOT_TABLE_COL_ABC.col_b, PIVOT_TABLE_COL_ABC.col_c)) AS g FROM ( @@ -406,7 +406,7 @@ FROM ( SELECT PIVOT_FUNCTION_2.col_a, PIVOT_FUNCTION_2.r FROM ( - SELECT PIVOT_FUNCTION_1.col_a, arrayZip((sumMap(PIVOT_FUNCTION_1.g.1, PIVOT_FUNCTION_1.g.2) AS x).1, x.2) AS r + SELECT PIVOT_FUNCTION_1.col_a, arrayZip((sumMap((PIVOT_FUNCTION_1.g).1, (PIVOT_FUNCTION_1.g).2) AS x).1, x.2) AS r FROM ( SELECT PIVOT_TABLE_COL_ABC.col_a, groupArray(tuple(PIVOT_TABLE_COL_ABC.col_b, PIVOT_TABLE_COL_ABC.col_c)) AS g FROM ( diff --git a/posthog/hogql/test/test_modifiers.py b/posthog/hogql/test/test_modifiers.py index 4296213727f37..028f9dd455216 100644 --- a/posthog/hogql/test/test_modifiers.py +++ b/posthog/hogql/test/test_modifiers.py @@ -51,28 +51,28 @@ def test_modifiers_persons_on_events_mode_mapping(self): "events.event", "events__pdi__person.id", "events__pdi__person.properties", - "toTimeZone(events__pdi__person.created_at, %(hogql_val_0)s)", + "toTimeZone(events__pdi__person.created_at, %(hogql_val_0)s) AS created_at", ), ( PersonsOnEventsMode.v1_enabled, "events.event", "events.person_id", "events.person_properties", - "toTimeZone(events.person_created_at, %(hogql_val_0)s)", + "toTimeZone(events.person_created_at, %(hogql_val_0)s) AS created_at", ), ( PersonsOnEventsMode.v1_mixed, "events.event", "events__pdi.person_id", "events.person_properties", - "toTimeZone(events__pdi__person.created_at, %(hogql_val_0)s)", + "toTimeZone(events__pdi__person.created_at, %(hogql_val_0)s) AS created_at", ), ( PersonsOnEventsMode.v2_enabled, "events.event", "events.person_id", "events.person_properties", - "toTimeZone(events.person_created_at, %(hogql_val_0)s)", + "toTimeZone(events.person_created_at, %(hogql_val_0)s) AS created_at", ), ] @@ -159,21 +159,25 @@ def test_modifiers_materialization_mode(self): team=self.team, modifiers=HogQLQueryModifiers(materializationMode=MaterializationMode.auto), ) - assert "SELECT nullIf(nullIf(events.`mat_$browser`, ''), 'null') FROM events" in response.clickhouse + assert ( + "SELECT nullIf(nullIf(events.`mat_$browser`, ''), 'null') AS `$browser` FROM events" in response.clickhouse + ) response = execute_hogql_query( "SELECT properties.$browser FROM events", team=self.team, modifiers=HogQLQueryModifiers(materializationMode=MaterializationMode.legacy_null_as_null), ) - assert "SELECT nullIf(nullIf(events.`mat_$browser`, ''), 'null') FROM events" in response.clickhouse + assert ( + "SELECT nullIf(nullIf(events.`mat_$browser`, ''), 'null') AS `$browser` FROM events" in response.clickhouse + ) response = execute_hogql_query( "SELECT properties.$browser FROM events", team=self.team, modifiers=HogQLQueryModifiers(materializationMode=MaterializationMode.legacy_null_as_string), ) - assert "SELECT nullIf(events.`mat_$browser`, '') FROM events" in response.clickhouse + assert "SELECT nullIf(events.`mat_$browser`, '') AS `$browser` FROM events" in response.clickhouse response = execute_hogql_query( "SELECT properties.$browser FROM events", @@ -181,6 +185,6 @@ def test_modifiers_materialization_mode(self): modifiers=HogQLQueryModifiers(materializationMode=MaterializationMode.disabled), ) assert ( - "SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_0)s), ''), 'null'), '^\"|\"$', '') FROM events" + "SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_0)s), ''), 'null'), '^\"|\"$', '') AS `$browser` FROM events" in response.clickhouse ) diff --git a/posthog/hogql/test/test_query.py b/posthog/hogql/test/test_query.py index 235ef2d251ab1..67e3cd6c0e049 100644 --- a/posthog/hogql/test/test_query.py +++ b/posthog/hogql/test/test_query.py @@ -1043,7 +1043,7 @@ def test_property_access_with_arrays(self): self.assertEqual( response.clickhouse, f"SELECT " - f"replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_0)s), ''), 'null'), '^\"|\"$', ''), " + f"replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_0)s), ''), 'null'), '^\"|\"$', '') AS string, " f"replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_1)s, %(hogql_val_2)s), ''), 'null'), '^\"|\"$', ''), " f"replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_3)s, %(hogql_val_4)s), ''), 'null'), '^\"|\"$', ''), " f"replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_5)s, %(hogql_val_6)s, %(hogql_val_7)s), ''), 'null'), '^\"|\"$', ''), " diff --git a/posthog/hogql/transforms/test/__snapshots__/test_lazy_tables.ambr b/posthog/hogql/transforms/test/__snapshots__/test_lazy_tables.ambr index ecb6fc525b2a9..4afb16d85f3b5 100644 --- a/posthog/hogql/transforms/test/__snapshots__/test_lazy_tables.ambr +++ b/posthog/hogql/transforms/test/__snapshots__/test_lazy_tables.ambr @@ -1,7 +1,7 @@ # name: TestLazyJoins.test_resolve_lazy_table_as_select_table ' - SELECT persons.id, persons.properties___email, persons.`properties___$browser` + SELECT persons.id, persons.properties___email AS email, persons.`properties___$browser` AS `$browser` FROM ( SELECT argMax(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, %(hogql_val_0)s), ''), 'null'), '^"|"$', ''), person.version) AS properties___email, argMax(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, %(hogql_val_1)s), ''), 'null'), '^"|"$', ''), person.version) AS `properties___$browser`, person.id AS id FROM person @@ -15,7 +15,7 @@ # name: TestLazyJoins.test_resolve_lazy_table_as_table_in_join ' - SELECT events.event, events.distinct_id, events__pdi.person_id, persons.properties___email + SELECT events.event, events.distinct_id, events__pdi.person_id, persons.properties___email AS email FROM events INNER JOIN ( SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id FROM person_distinct_id2 @@ -49,7 +49,7 @@ # name: TestLazyJoins.test_resolve_lazy_tables_one_level_properties ' - SELECT person_distinct_ids__person.`properties___$browser` + SELECT person_distinct_ids__person.`properties___$browser` AS `$browser` FROM ( SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id FROM person_distinct_id2 @@ -68,7 +68,7 @@ # name: TestLazyJoins.test_resolve_lazy_tables_one_level_properties_deep ' - SELECT person_distinct_ids__person.`properties___$browser___in___json` + SELECT person_distinct_ids__person.`properties___$browser___in___json` AS `$browser__in__json` FROM ( SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id FROM person_distinct_id2 @@ -121,7 +121,7 @@ # name: TestLazyJoins.test_resolve_lazy_tables_two_levels_properties ' - SELECT events.event, events__pdi__person.`properties___$browser` + SELECT events.event, events__pdi__person.`properties___$browser` AS `$browser` FROM events INNER JOIN ( SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id FROM person_distinct_id2 @@ -141,7 +141,7 @@ # name: TestLazyJoins.test_resolve_lazy_tables_two_levels_properties_duplicate ' - SELECT events.event, events__pdi__person.properties, events__pdi__person.properties___name + SELECT events.event, events__pdi__person.properties, events__pdi__person.properties___name AS name FROM events INNER JOIN ( SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id FROM person_distinct_id2 diff --git a/posthog/hogql/transforms/test/__snapshots__/test_property_types.ambr b/posthog/hogql/transforms/test/__snapshots__/test_property_types.ambr index 5e449b22a6c40..7150d4e4f2363 100644 --- a/posthog/hogql/transforms/test/__snapshots__/test_property_types.ambr +++ b/posthog/hogql/transforms/test/__snapshots__/test_property_types.ambr @@ -21,7 +21,7 @@ # name: TestPropertyTypes.test_resolve_property_types_event ' - SELECT multiply(toFloat64OrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_0)s), ''), 'null'), '^"|"$', '')), toFloat64OrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_1)s), ''), 'null'), '^"|"$', ''))), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_2)s), ''), 'null'), '^"|"$', ''), %(hogql_val_3)s), 0) + SELECT multiply(toFloat64OrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_0)s), ''), 'null'), '^"|"$', '')), toFloat64OrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_1)s), ''), 'null'), '^"|"$', ''))), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_2)s), ''), 'null'), '^"|"$', ''), %(hogql_val_3)s), 0) AS bool FROM events WHERE equals(events.team_id, 420) LIMIT 10000 @@ -30,7 +30,7 @@ # name: TestPropertyTypes.test_resolve_property_types_event_person_poe_off ' - SELECT parseDateTime64BestEffortOrNull(events__pdi__person.properties___provided_timestamp, 6, %(hogql_val_1)s) + SELECT parseDateTime64BestEffortOrNull(events__pdi__person.properties___provided_timestamp, 6, %(hogql_val_1)s) AS provided_timestamp FROM events INNER JOIN ( SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id FROM person_distinct_id2 @@ -50,7 +50,7 @@ # name: TestPropertyTypes.test_resolve_property_types_event_person_poe_on ' - SELECT parseDateTime64BestEffortOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.person_properties, %(hogql_val_0)s), ''), 'null'), '^"|"$', ''), 6, %(hogql_val_1)s) + SELECT parseDateTime64BestEffortOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.person_properties, %(hogql_val_0)s), ''), 'null'), '^"|"$', ''), 6, %(hogql_val_1)s) AS provided_timestamp FROM events WHERE equals(events.team_id, 420) LIMIT 10000 @@ -59,7 +59,7 @@ # name: TestPropertyTypes.test_resolve_property_types_person ' - SELECT toFloat64OrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, %(hogql_val_0)s), ''), 'null'), '^"|"$', '')), parseDateTime64BestEffortOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, %(hogql_val_1)s), ''), 'null'), '^"|"$', ''), 6, %(hogql_val_2)s), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, %(hogql_val_3)s), ''), 'null'), '^"|"$', '') + SELECT toFloat64OrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, %(hogql_val_0)s), ''), 'null'), '^"|"$', '')) AS tickets, parseDateTime64BestEffortOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, %(hogql_val_1)s), ''), 'null'), '^"|"$', ''), 6, %(hogql_val_2)s) AS provided_timestamp, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, %(hogql_val_3)s), ''), 'null'), '^"|"$', '') AS `$initial_browser` FROM person WHERE equals(person.team_id, 420) LIMIT 10000 @@ -68,7 +68,7 @@ # name: TestPropertyTypes.test_resolve_property_types_person_raw ' - SELECT toFloat64OrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, %(hogql_val_0)s), ''), 'null'), '^"|"$', '')), parseDateTime64BestEffortOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, %(hogql_val_1)s), ''), 'null'), '^"|"$', ''), 6, %(hogql_val_2)s), replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, %(hogql_val_3)s), ''), 'null'), '^"|"$', '') + SELECT toFloat64OrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, %(hogql_val_0)s), ''), 'null'), '^"|"$', '')) AS tickets, parseDateTime64BestEffortOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, %(hogql_val_1)s), ''), 'null'), '^"|"$', ''), 6, %(hogql_val_2)s) AS provided_timestamp, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, %(hogql_val_3)s), ''), 'null'), '^"|"$', '') AS `$initial_browser` FROM person WHERE equals(person.team_id, 420) LIMIT 10000 From 62ff44c217178a8c9b394fed1bb0e7e2769bfef6 Mon Sep 17 00:00:00 2001 From: Marius Andra Date: Tue, 21 Nov 2023 15:47:10 +0100 Subject: [PATCH 03/15] fix few tests --- posthog/hogql/ast.py | 3 +++ posthog/hogql/resolver.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/posthog/hogql/ast.py b/posthog/hogql/ast.py index 03533dbba0c0a..ca497c62be9c9 100644 --- a/posthog/hogql/ast.py +++ b/posthog/hogql/ast.py @@ -38,6 +38,9 @@ def get_child(self, name: str) -> Type: def has_child(self, name: str) -> bool: return self.type.has_child(name) + def resolve_constant_type(self): + return self.type.resolve_constant_type() + @dataclass(kw_only=True) class BaseTableType(Type): diff --git a/posthog/hogql/resolver.py b/posthog/hogql/resolver.py index fe9ab56585f7f..a7d5a19385c1c 100644 --- a/posthog/hogql/resolver.py +++ b/posthog/hogql/resolver.py @@ -594,6 +594,8 @@ def visit_compare_operation(self, node: ast.CompareOperation): return node def _is_events_table(self, node: ast.Expr) -> bool: + while isinstance(node, ast.Alias): + node = node.expr if isinstance(node, ast.Field) and isinstance(node.type, ast.FieldType): if isinstance(node.type.table_type, ast.TableAliasType): return isinstance(node.type.table_type.table_type.table, EventsTable) @@ -602,6 +604,8 @@ def _is_events_table(self, node: ast.Expr) -> bool: return False def _is_s3_cluster(self, node: ast.Expr) -> bool: + while isinstance(node, ast.Alias): + node = node.expr if ( isinstance(node, ast.SelectQuery) and node.select_from From 5249cae6f7695a83406efb35a4368844f8007fd3 Mon Sep 17 00:00:00 2001 From: Marius Andra Date: Tue, 21 Nov 2023 15:49:31 +0100 Subject: [PATCH 04/15] fix another tests --- .../database/schema/test/test_event_sessions.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/posthog/hogql/database/schema/test/test_event_sessions.py b/posthog/hogql/database/schema/test/test_event_sessions.py index 268180a773e6c..95752668f3a2f 100644 --- a/posthog/hogql/database/schema/test/test_event_sessions.py +++ b/posthog/hogql/database/schema/test/test_event_sessions.py @@ -38,7 +38,7 @@ def test_with_simple_equality_clause(self): assert len(compare_operators) == 1 assert compare_operators[0] == ast.CompareOperation( - left=ast.Field(chain=["event"]), + left=ast.Alias(alias="event", hidden=True, expr=ast.Field(chain=["event"])), op=ast.CompareOperationOp.Eq, right=ast.Constant(value="$pageview"), ) @@ -56,7 +56,7 @@ def test_with_timestamps(self): assert len(compare_operators) == 1 assert compare_operators[0] == ast.CompareOperation( - left=ast.Field(chain=["timestamp"]), + left=ast.Alias(alias="timestamp", hidden=True, expr=ast.Field(chain=["timestamp"])), op=ast.CompareOperationOp.Gt, right=ast.Constant(value="2023-01-01"), ) @@ -74,7 +74,7 @@ def test_with_alias_table(self): assert len(compare_operators) == 1 assert compare_operators[0] == ast.CompareOperation( - left=ast.Field(chain=["event"]), + left=ast.Alias(alias="event", hidden=True, expr=ast.Field(chain=["event"])), op=ast.CompareOperationOp.Eq, right=ast.Constant(value="$pageview"), ) @@ -92,12 +92,12 @@ def test_with_multiple_clauses(self): assert len(compare_operators) == 2 assert compare_operators[0] == ast.CompareOperation( - left=ast.Field(chain=["event"]), + left=ast.Alias(alias="event", hidden=True, expr=ast.Field(chain=["event"])), op=ast.CompareOperationOp.Eq, right=ast.Constant(value="$pageview"), ) assert compare_operators[1] == ast.CompareOperation( - left=ast.Field(chain=["timestamp"]), + left=ast.Alias(alias="timestamp", hidden=True, expr=ast.Field(chain=["timestamp"])), op=ast.CompareOperationOp.Gt, right=ast.Constant(value="2023-01-01"), ) @@ -117,7 +117,7 @@ def test_with_join(self): assert len(compare_operators) == 1 assert compare_operators[0] == ast.CompareOperation( - left=ast.Field(chain=["event"]), + left=ast.Alias(alias="event", hidden=True, expr=ast.Field(chain=["event"])), op=ast.CompareOperationOp.Eq, right=ast.Constant(value="$pageview"), ) From 8577afcec8f4da3c8343e09c1ca5b5cce987dac2 Mon Sep 17 00:00:00 2001 From: Marius Andra Date: Tue, 21 Nov 2023 17:01:26 +0100 Subject: [PATCH 05/15] parser tests with snapshots --- posthog/hogql/ast.py | 7 +- posthog/hogql/resolver.py | 30 +- posthog/hogql/test/test_resolver.py | 993 ++-------------------------- posthog/hogql/test/utils.py | 47 ++ 4 files changed, 109 insertions(+), 968 deletions(-) diff --git a/posthog/hogql/ast.py b/posthog/hogql/ast.py index ca497c62be9c9..5b86e85d0c77c 100644 --- a/posthog/hogql/ast.py +++ b/posthog/hogql/ast.py @@ -41,6 +41,11 @@ def has_child(self, name: str) -> bool: def resolve_constant_type(self): return self.type.resolve_constant_type() + def resolve_database_field(self): + if isinstance(self.type, FieldType): + return self.type.resolve_database_field() + raise NotImplementedException("FieldAliasType.resolve_database_field not implemented") + @dataclass(kw_only=True) class BaseTableType(Type): @@ -126,8 +131,6 @@ class SelectQueryType(Type): aliases: Dict[str, FieldAliasType] = field(default_factory=dict) # all types a select query exports columns: Dict[str, Type] = field(default_factory=dict) - # these column have an explicit alias and can't be overridden - columns_with_explicit_alias: Dict[str, bool] = field(default_factory=dict) # all from and join, tables and subqueries with aliases tables: Dict[str, TableOrSelectType] = field(default_factory=dict) ctes: Dict[str, CTE] = field(default_factory=dict) diff --git a/posthog/hogql/resolver.py b/posthog/hogql/resolver.py index a7d5a19385c1c..a70eefa8ef9dd 100644 --- a/posthog/hogql/resolver.py +++ b/posthog/hogql/resolver.py @@ -118,15 +118,17 @@ def visit_select_query(self, node: ast.SelectQuery): new_node.array_join_list = [self.visit(expr) for expr in node.array_join_list] # Visit all the "SELECT a,b,c" columns. Mark each for export in "columns". + select_nodes = [] for expr in node.select or []: new_expr = self.visit(expr) - - # if it's an asterisk, carry on in a subroutine if isinstance(new_expr.type, ast.AsteriskType): - self._expand_asterisk_columns(new_node, new_expr.type) - continue + columns = self._asterisk_columns(new_expr.type) + select_nodes.extend([self.visit(expr) for expr in columns]) + else: + select_nodes.append(new_expr) - # not an asterisk + columns_with_explicit_alias = {} + for new_expr in select_nodes: if isinstance(new_expr.type, ast.FieldAliasType): alias = new_expr.type.alias elif isinstance(new_expr.type, ast.FieldType): @@ -139,12 +141,12 @@ def visit_select_query(self, node: ast.SelectQuery): if alias: # Remember the first visible or last hidden expr for each alias if isinstance(new_expr, ast.Alias) and new_expr.hidden: - if alias not in node_type.columns or not node_type.columns_with_explicit_alias.get(alias, False): + if alias not in node_type.columns or not columns_with_explicit_alias.get(alias, False): node_type.columns[alias] = new_expr.type - node_type.columns_with_explicit_alias[alias] = False + columns_with_explicit_alias[alias] = False else: node_type.columns[alias] = new_expr.type - node_type.columns_with_explicit_alias[alias] = True + columns_with_explicit_alias[alias] = True # add the column to the new select query new_node.select.append(new_expr) @@ -172,15 +174,12 @@ def visit_select_query(self, node: ast.SelectQuery): return new_node - def _expand_asterisk_columns(self, select_query: ast.SelectQuery, asterisk: ast.AsteriskType): + def _asterisk_columns(self, asterisk: ast.AsteriskType) -> List[ast.Expr]: """Expand an asterisk. Mutates `select_query.select` and `select_query.type.columns` with the new fields""" if isinstance(asterisk.table_type, ast.BaseTableType): table = asterisk.table_type.resolve_database_table() database_fields = table.get_asterisk() - for key in database_fields.keys(): - type = ast.FieldType(name=key, table_type=asterisk.table_type) - select_query.select.append(ast.Field(chain=[key], type=type)) - select_query.type.columns[key] = type + return [ast.Field(chain=[key]) for key in database_fields.keys()] elif ( isinstance(asterisk.table_type, ast.SelectUnionQueryType) or isinstance(asterisk.table_type, ast.SelectQueryType) @@ -192,10 +191,7 @@ def _expand_asterisk_columns(self, select_query: ast.SelectQuery, asterisk: ast. if isinstance(select, ast.SelectUnionQueryType): select = select.types[0] if isinstance(select, ast.SelectQueryType): - for name in select.columns.keys(): - type = ast.FieldType(name=name, table_type=asterisk.table_type) - select_query.select.append(ast.Field(chain=[name], type=type)) - select_query.type.columns[name] = type + return [ast.Field(chain=[key]) for key in select.columns.keys()] else: raise ResolverException("Can't expand asterisk (*) on subquery") else: diff --git a/posthog/hogql/test/test_resolver.py b/posthog/hogql/test/test_resolver.py index f2ee1d812ea65..5c5e714cda0c9 100644 --- a/posthog/hogql/test/test_resolver.py +++ b/posthog/hogql/test/test_resolver.py @@ -1,6 +1,6 @@ from datetime import timezone, datetime, date from typing import Optional, Dict, cast - +import pytest from django.test import override_settings from uuid import UUID @@ -10,12 +10,12 @@ from posthog.hogql.context import HogQLContext from posthog.hogql.database.database import create_hogql_database from posthog.hogql.database.models import ( - LazyJoin, FieldTraverser, StringJSONDatabaseField, StringDatabaseField, DateTimeDatabaseField, ) +from posthog.hogql.test.utils import pretty_dataclasses from posthog.hogql.visitor import clone_expr from posthog.hogql.parser import parse_select from posthog.hogql.printer import print_ast, print_prepared_ast @@ -44,42 +44,11 @@ def setUp(self): self.database = create_hogql_database(self.team.pk) self.context = HogQLContext(database=self.database, team_id=self.team.pk) + @pytest.mark.usefixtures("unittest_snapshot") def test_resolve_events_table(self): expr = self._select("SELECT event, events.timestamp FROM events WHERE events.event = 'test'") expr = resolve_types(expr, self.context) - - events_table_type = ast.TableType(table=self.database.events) - event_field_type = ast.FieldType(name="event", table_type=events_table_type) - timestamp_field_type = ast.FieldType(name="timestamp", table_type=events_table_type) - select_query_type = ast.SelectQueryType( - columns={"event": event_field_type, "timestamp": timestamp_field_type}, - tables={"events": events_table_type}, - ) - - expected = ast.SelectQuery( - select=[ - ast.Field(chain=["event"], type=event_field_type), - ast.Field(chain=["events", "timestamp"], type=timestamp_field_type), - ], - select_from=ast.JoinExpr( - table=ast.Field(chain=["events"], type=events_table_type), - type=events_table_type, - ), - where=ast.CompareOperation( - left=ast.Field(chain=["events", "event"], type=event_field_type), - op=ast.CompareOperationOp.Eq, - right=ast.Constant(value="test", type=ast.StringType()), - type=ast.BooleanType(), - ), - type=select_query_type, - ) - - # asserting individually to help debug if something is off - self.assertEqual(expr.select, expected.select) - self.assertEqual(expr.select_from, expected.select_from) - self.assertEqual(expr.where, expected.where) - self.assertEqual(expr.type, expected.type) - self.assertEqual(expr, expected) + assert pretty_dataclasses(expr) == self.snapshot def test_will_not_run_twice(self): expr = self._select("SELECT event, events.timestamp FROM events WHERE events.event = 'test'") @@ -91,186 +60,23 @@ def test_will_not_run_twice(self): "Type already resolved for SelectQuery (SelectQueryType). Can't run again.", ) + @pytest.mark.usefixtures("unittest_snapshot") def test_resolve_events_table_alias(self): expr = self._select("SELECT event, e.timestamp FROM events e WHERE e.event = 'test'") expr = resolve_types(expr, self.context) + assert pretty_dataclasses(expr) == self.snapshot - events_table_type = ast.TableType(table=self.database.events) - events_table_alias_type = ast.TableAliasType(alias="e", table_type=events_table_type) - event_field_type = ast.FieldType(name="event", table_type=events_table_alias_type) - timestamp_field_type = ast.FieldType(name="timestamp", table_type=events_table_alias_type) - select_query_type = ast.SelectQueryType( - columns={"event": event_field_type, "timestamp": timestamp_field_type}, - tables={"e": events_table_alias_type}, - ) - - expected = ast.SelectQuery( - select=[ - ast.Field(chain=["event"], type=event_field_type), - ast.Field(chain=["e", "timestamp"], type=timestamp_field_type), - ], - select_from=ast.JoinExpr( - table=ast.Field(chain=["events"], type=events_table_type), - alias="e", - type=events_table_alias_type, - ), - where=ast.CompareOperation( - left=ast.Field(chain=["e", "event"], type=event_field_type), - op=ast.CompareOperationOp.Eq, - right=ast.Constant(value="test", type=ast.StringType()), - type=ast.BooleanType(), - ), - type=select_query_type, - ) - - # asserting individually to help debug if something is off - self.assertEqual(expr.select, expected.select) - self.assertEqual(expr.select_from, expected.select_from) - self.assertEqual(expr.where, expected.where) - self.assertEqual(expr.type, expected.type) - self.assertEqual(expr, expected) - + @pytest.mark.usefixtures("unittest_snapshot") def test_resolve_events_table_column_alias(self): expr = self._select("SELECT event as ee, ee, ee as e, e.timestamp FROM events e WHERE e.event = 'test'") expr = resolve_types(expr, self.context) + assert pretty_dataclasses(expr) == self.snapshot - events_table_type = ast.TableType(table=self.database.events) - events_table_alias_type = ast.TableAliasType(alias="e", table_type=events_table_type) - event_field_type = ast.FieldType(name="event", table_type=events_table_alias_type) - timestamp_field_type = ast.FieldType(name="timestamp", table_type=events_table_alias_type) - - select_query_type = ast.SelectQueryType( - aliases={ - "ee": ast.FieldAliasType(alias="ee", type=event_field_type), - "e": ast.FieldAliasType( - alias="e", - type=ast.FieldAliasType(alias="ee", type=event_field_type), - ), - }, - columns={ - "ee": ast.FieldAliasType(alias="ee", type=event_field_type), - "e": ast.FieldAliasType( - alias="e", - type=ast.FieldAliasType(alias="ee", type=event_field_type), - ), - "timestamp": timestamp_field_type, - }, - tables={"e": events_table_alias_type}, - ) - - expected = ast.SelectQuery( - select=[ - ast.Alias( - alias="ee", - expr=ast.Field(chain=["event"], type=event_field_type), - type=select_query_type.aliases["ee"], - ), - ast.Field(chain=["ee"], type=select_query_type.aliases["ee"]), - ast.Alias( - alias="e", - expr=ast.Field(chain=["ee"], type=select_query_type.aliases["ee"]), - type=select_query_type.aliases["e"], # is ee ? - ), - ast.Field(chain=["e", "timestamp"], type=timestamp_field_type), - ], - select_from=ast.JoinExpr( - table=ast.Field(chain=["events"], type=events_table_type), - alias="e", - type=select_query_type.tables["e"], - ), - where=ast.CompareOperation( - left=ast.Field(chain=["e", "event"], type=event_field_type), - op=ast.CompareOperationOp.Eq, - right=ast.Constant(value="test", type=ast.StringType()), - type=ast.BooleanType(), - ), - type=select_query_type, - ) - # asserting individually to help debug if something is off - self.assertEqual(expr.select, expected.select) - self.assertEqual(expr.select_from, expected.select_from) - self.assertEqual(expr.where, expected.where) - self.assertEqual(expr.type, expected.type) - self.assertEqual(expr, expected) - + @pytest.mark.usefixtures("unittest_snapshot") def test_resolve_events_table_column_alias_inside_subquery(self): expr = self._select("SELECT b FROM (select event as b, timestamp as c from events) e WHERE e.b = 'test'") expr = resolve_types(expr, self.context) - inner_events_table_type = ast.TableType(table=self.database.events) - inner_event_field_type = ast.FieldAliasType( - alias="b", - type=ast.FieldType(name="event", table_type=inner_events_table_type), - ) - timestamp_field_type = ast.FieldType(name="timestamp", table_type=inner_events_table_type) - timstamp_alias_type = ast.FieldAliasType(alias="c", type=timestamp_field_type) - inner_select_type = ast.SelectQueryType( - aliases={ - "b": inner_event_field_type, - "c": ast.FieldAliasType(alias="c", type=timestamp_field_type), - }, - columns={ - "b": inner_event_field_type, - "c": ast.FieldAliasType(alias="c", type=timestamp_field_type), - }, - tables={ - "events": inner_events_table_type, - }, - ) - select_alias_type = ast.SelectQueryAliasType(alias="e", select_query_type=inner_select_type) - expected = ast.SelectQuery( - select=[ - ast.Field( - chain=["b"], - type=ast.FieldType( - name="b", - table_type=ast.SelectQueryAliasType(alias="e", select_query_type=inner_select_type), - ), - ), - ], - select_from=ast.JoinExpr( - table=ast.SelectQuery( - select=[ - ast.Alias( - alias="b", - expr=ast.Field(chain=["event"], type=inner_event_field_type.type), - type=inner_event_field_type, - ), - ast.Alias( - alias="c", - expr=ast.Field(chain=["timestamp"], type=timestamp_field_type), - type=timstamp_alias_type, - ), - ], - select_from=ast.JoinExpr( - table=ast.Field(chain=["events"], type=inner_events_table_type), - type=inner_events_table_type, - ), - type=inner_select_type, - ), - alias="e", - type=select_alias_type, - ), - where=ast.CompareOperation( - left=ast.Field( - chain=["e", "b"], - type=ast.FieldType(name="b", table_type=select_alias_type), - ), - op=ast.CompareOperationOp.Eq, - right=ast.Constant(value="test", type=ast.StringType()), - type=ast.BooleanType(), - ), - type=ast.SelectQueryType( - aliases={}, - columns={"b": ast.FieldType(name="b", table_type=select_alias_type)}, - tables={"e": select_alias_type}, - ), - ) - # asserting individually to help debug if something is off - self.assertEqual(expr.select, expected.select) - self.assertEqual(expr.select_from, expected.select_from) - self.assertEqual(expr.where, expected.where) - self.assertEqual(expr.type, expected.type) - self.assertEqual(expr, expected) + assert pretty_dataclasses(expr) == self.snapshot def test_resolve_subquery_no_field_access(self): # From ClickHouse's GitHub: "Aliases defined outside of subquery are not visible in subqueries (but see below)." @@ -281,6 +87,7 @@ def test_resolve_subquery_no_field_access(self): expr = resolve_types(expr, self.context) self.assertEqual(str(e.exception), "Unable to resolve field: e") + @pytest.mark.usefixtures("unittest_snapshot") def test_resolve_constant_type(self): with freeze_time("2020-01-10 00:00:00"): expr = self._select( @@ -295,66 +102,13 @@ def test_resolve_constant_type(self): }, ) expr = resolve_types(expr, self.context) - expected = ast.SelectQuery( - select=[ - ast.Constant(value=1, type=ast.IntegerType()), - ast.Constant(value="boo", type=ast.StringType()), - ast.Constant(value=True, type=ast.BooleanType()), - ast.Constant(value=1.1232, type=ast.FloatType()), - ast.Constant(value=None, type=ast.UnknownType()), - ast.Constant(value=date(2020, 1, 10), type=ast.DateType()), - ast.Constant( - value=datetime(2020, 1, 10, 0, 0, 0, tzinfo=timezone.utc), - type=ast.DateTimeType(), - ), - ast.Constant( - value=UUID("00000000-0000-4000-8000-000000000000"), - type=ast.UUIDType(), - ), - ast.Constant(value=[], type=ast.ArrayType(item_type=ast.UnknownType())), - ast.Constant(value=[1, 2], type=ast.ArrayType(item_type=ast.IntegerType())), - ast.Constant( - value=(1, 2, 3), - type=ast.TupleType( - item_types=[ - ast.IntegerType(), - ast.IntegerType(), - ast.IntegerType(), - ] - ), - ), - ], - type=ast.SelectQueryType(aliases={}, columns={}, tables={}), - ) - self.assertEqual(expr, expected) + assert pretty_dataclasses(expr) == self.snapshot + @pytest.mark.usefixtures("unittest_snapshot") def test_resolve_boolean_operation_types(self): expr = self._select("SELECT 1 and 1, 1 or 1, not true") expr = resolve_types(expr, self.context) - expected = ast.SelectQuery( - select=[ - ast.And( - exprs=[ - ast.Constant(value=1, type=ast.IntegerType()), - ast.Constant(value=1, type=ast.IntegerType()), - ], - type=ast.BooleanType(), - ), - ast.Or( - exprs=[ - ast.Constant(value=1, type=ast.IntegerType()), - ast.Constant(value=1, type=ast.IntegerType()), - ], - type=ast.BooleanType(), - ), - ast.Not( - expr=ast.Constant(value=True, type=ast.BooleanType()), - type=ast.BooleanType(), - ), - ], - type=ast.SelectQueryType(aliases={}, columns={}, tables={}), - ) - self.assertEqual(expr, expected) + assert pretty_dataclasses(expr) == self.snapshot def test_resolve_errors(self): queries = [ @@ -369,388 +123,53 @@ def test_resolve_errors(self): resolve_types(self._select(query), self.context) self.assertIn("Unable to resolve field:", str(e.exception)) + @pytest.mark.usefixtures("unittest_snapshot") def test_resolve_lazy_pdi_person_table(self): expr = self._select("select distinct_id, person.id from person_distinct_ids") expr = resolve_types(expr, self.context) - pdi_table_type = ast.LazyTableType(table=self.database.person_distinct_ids) - expected = ast.SelectQuery( - select=[ - ast.Field( - chain=["distinct_id"], - type=ast.FieldType(name="distinct_id", table_type=pdi_table_type), - ), - ast.Field( - chain=["person", "id"], - type=ast.FieldType( - name="id", - table_type=ast.LazyJoinType( - table_type=pdi_table_type, - field="person", - lazy_join=self.database.person_distinct_ids.fields.get("person"), - ), - ), - ), - ], - select_from=ast.JoinExpr( - table=ast.Field(chain=["person_distinct_ids"], type=pdi_table_type), - type=pdi_table_type, - ), - type=ast.SelectQueryType( - aliases={}, - anonymous_tables=[], - columns={ - "distinct_id": ast.FieldType(name="distinct_id", table_type=pdi_table_type), - "id": ast.FieldType( - name="id", - table_type=ast.LazyJoinType( - table_type=pdi_table_type, - lazy_join=self.database.person_distinct_ids.fields.get("person"), - field="person", - ), - ), - }, - tables={"person_distinct_ids": pdi_table_type}, - ), - ) - self.assertEqual(expr.select, expected.select) - self.assertEqual(expr.select_from, expected.select_from) - self.assertEqual(expr.where, expected.where) - self.assertEqual(expr.type, expected.type) - self.assertEqual(expr, expected) + assert pretty_dataclasses(expr) == self.snapshot + @pytest.mark.usefixtures("unittest_snapshot") def test_resolve_lazy_events_pdi_table(self): expr = self._select("select event, pdi.person_id from events") expr = resolve_types(expr, self.context) - events_table_type = ast.TableType(table=self.database.events) - expected = ast.SelectQuery( - select=[ - ast.Field( - chain=["event"], - type=ast.FieldType(name="event", table_type=events_table_type), - ), - ast.Field( - chain=["pdi", "person_id"], - type=ast.FieldType( - name="person_id", - table_type=ast.LazyJoinType( - table_type=events_table_type, - field="pdi", - lazy_join=cast(LazyJoin, self.database.events.fields.get("pdi")), - ), - ), - ), - ], - select_from=ast.JoinExpr( - table=ast.Field(chain=["events"], type=events_table_type), - type=events_table_type, - ), - type=ast.SelectQueryType( - aliases={}, - anonymous_tables=[], - columns={ - "event": ast.FieldType(name="event", table_type=events_table_type), - "person_id": ast.FieldType( - name="person_id", - table_type=ast.LazyJoinType( - table_type=events_table_type, - lazy_join=cast(LazyJoin, self.database.events.fields.get("pdi")), - field="pdi", - ), - ), - }, - tables={"events": events_table_type}, - ), - ) - self.assertEqual(expr.select, expected.select) - self.assertEqual(expr.select_from, expected.select_from) - self.assertEqual(expr.where, expected.where) - self.assertEqual(expr.type, expected.type) - self.assertEqual(expr, expected) + assert pretty_dataclasses(expr) == self.snapshot + @pytest.mark.usefixtures("unittest_snapshot") def test_resolve_lazy_events_pdi_table_aliased(self): expr = self._select("select event, e.pdi.person_id from events e") expr = resolve_types(expr, self.context) - events_table_type = ast.TableType(table=self.database.events) - events_table_alias_type = ast.TableAliasType(table_type=events_table_type, alias="e") - expected = ast.SelectQuery( - select=[ - ast.Field( - chain=["event"], - type=ast.FieldType(name="event", table_type=events_table_alias_type), - ), - ast.Field( - chain=["e", "pdi", "person_id"], - type=ast.FieldType( - name="person_id", - table_type=ast.LazyJoinType( - table_type=events_table_alias_type, - field="pdi", - lazy_join=cast(LazyJoin, self.database.events.fields.get("pdi")), - ), - ), - ), - ], - select_from=ast.JoinExpr( - table=ast.Field(chain=["events"], type=events_table_type), - alias="e", - type=events_table_alias_type, - ), - type=ast.SelectQueryType( - aliases={}, - anonymous_tables=[], - columns={ - "event": ast.FieldType(name="event", table_type=events_table_alias_type), - "person_id": ast.FieldType( - name="person_id", - table_type=ast.LazyJoinType( - table_type=events_table_alias_type, - lazy_join=cast(LazyJoin, self.database.events.fields.get("pdi")), - field="pdi", - ), - ), - }, - tables={"e": events_table_alias_type}, - ), - ) - self.assertEqual(expr.select, expected.select) - self.assertEqual(expr.select_from, expected.select_from) - self.assertEqual(expr.where, expected.where) - self.assertEqual(expr.type, expected.type) - self.assertEqual(expr, expected) + assert pretty_dataclasses(expr) == self.snapshot + @pytest.mark.usefixtures("unittest_snapshot") def test_resolve_lazy_events_pdi_person_table(self): expr = self._select("select event, pdi.person.id from events") expr = resolve_types(expr, self.context) - events_table_type = ast.TableType(table=self.database.events) - expected = ast.SelectQuery( - select=[ - ast.Field( - chain=["event"], - type=ast.FieldType(name="event", table_type=events_table_type), - ), - ast.Field( - chain=["pdi", "person", "id"], - type=ast.FieldType( - name="id", - table_type=ast.LazyJoinType( - table_type=ast.LazyJoinType( - table_type=events_table_type, - field="pdi", - lazy_join=cast(LazyJoin, self.database.events.fields.get("pdi")), - ), - field="person", - lazy_join=cast( - LazyJoin, - cast(LazyJoin, self.database.events.fields.get("pdi")).join_table.fields.get("person"), - ), - ), - ), - ), - ], - select_from=ast.JoinExpr( - table=ast.Field(chain=["events"], type=events_table_type), - type=events_table_type, - ), - type=ast.SelectQueryType( - aliases={}, - anonymous_tables=[], - columns={ - "event": ast.FieldType(name="event", table_type=events_table_type), - "id": ast.FieldType( - name="id", - table_type=ast.LazyJoinType( - table_type=ast.LazyJoinType( - table_type=events_table_type, - field="pdi", - lazy_join=cast(LazyJoin, self.database.events.fields.get("pdi")), - ), - field="person", - lazy_join=cast( - LazyJoin, - cast(LazyJoin, self.database.events.fields.get("pdi")).join_table.fields.get("person"), - ), - ), - ), - }, - tables={"events": events_table_type}, - ), - ) - self.assertEqual(expr.select, expected.select) - self.assertEqual(expr.select_from, expected.select_from) - self.assertEqual(expr.where, expected.where) - self.assertEqual(expr.type, expected.type) - self.assertEqual(expr, expected) + assert pretty_dataclasses(expr) == self.snapshot + @pytest.mark.usefixtures("unittest_snapshot") def test_resolve_lazy_events_pdi_person_table_aliased(self): expr = self._select("select event, e.pdi.person.id from events e") expr = resolve_types(expr, self.context) - events_table_type = ast.TableType(table=self.database.events) - events_table_alias_type = ast.TableAliasType(table_type=events_table_type, alias="e") - expected = ast.SelectQuery( - select=[ - ast.Field( - chain=["event"], - type=ast.FieldType(name="event", table_type=events_table_alias_type), - ), - ast.Field( - chain=["e", "pdi", "person", "id"], - type=ast.FieldType( - name="id", - table_type=ast.LazyJoinType( - table_type=ast.LazyJoinType( - table_type=events_table_alias_type, - field="pdi", - lazy_join=cast(LazyJoin, self.database.events.fields.get("pdi")), - ), - field="person", - lazy_join=cast( - LazyJoin, - cast(LazyJoin, self.database.events.fields.get("pdi")).join_table.fields.get("person"), - ), - ), - ), - ), - ], - select_from=ast.JoinExpr( - table=ast.Field(chain=["events"], type=events_table_type), - alias="e", - type=events_table_alias_type, - ), - type=ast.SelectQueryType( - aliases={}, - anonymous_tables=[], - columns={ - "event": ast.FieldType(name="event", table_type=events_table_alias_type), - "id": ast.FieldType( - name="id", - table_type=ast.LazyJoinType( - table_type=ast.LazyJoinType( - table_type=events_table_alias_type, - field="pdi", - lazy_join=cast(LazyJoin, self.database.events.fields.get("pdi")), - ), - field="person", - lazy_join=cast( - LazyJoin, - cast(LazyJoin, self.database.events.fields.get("pdi")).join_table.fields.get("person"), - ), - ), - ), - }, - tables={"e": events_table_alias_type}, - ), - ) - self.assertEqual(expr.select, expected.select) - self.assertEqual(expr.select_from, expected.select_from) - self.assertEqual(expr.where, expected.where) - self.assertEqual(expr.type, expected.type) - self.assertEqual(expr, expected) + assert pretty_dataclasses(expr) == self.snapshot + @pytest.mark.usefixtures("unittest_snapshot") def test_resolve_virtual_events_poe(self): expr = self._select("select event, poe.id from events") expr = resolve_types(expr, self.context) - events_table_type = ast.TableType(table=self.database.events) - expected = ast.SelectQuery( - select=[ - ast.Field( - chain=["event"], - type=ast.FieldType(name="event", table_type=events_table_type), - ), - ast.Field( - chain=["poe", "id"], - type=ast.FieldType( - name="id", - table_type=ast.VirtualTableType( - table_type=events_table_type, - field="poe", - virtual_table=self.database.events.fields["poe"], - ), - ), - ), - ], - select_from=ast.JoinExpr( - table=ast.Field(chain=["events"], type=events_table_type), - type=events_table_type, - ), - type=ast.SelectQueryType( - aliases={}, - anonymous_tables=[], - columns={ - "event": ast.FieldType(name="event", table_type=events_table_type), - "id": ast.FieldType( - name="id", - table_type=ast.VirtualTableType( - table_type=events_table_type, - field="poe", - virtual_table=self.database.events.fields.get("poe"), - ), - ), - }, - tables={"events": events_table_type}, - ), - ) - self.assertEqual(expr.select, expected.select) - self.assertEqual(expr.select_from, expected.select_from) - self.assertEqual(expr.where, expected.where) - self.assertEqual(expr.type, expected.type) - self.assertEqual(expr, expected) + assert pretty_dataclasses(expr) == self.snapshot + @pytest.mark.usefixtures("unittest_snapshot") def test_resolve_union_all(self): node = self._select("select event, timestamp from events union all select event, timestamp from events") node = resolve_types(node, self.context) + assert pretty_dataclasses(node) == self.snapshot - events_table_type = ast.TableType(table=self.database.events) - self.assertEqual( - node.select_queries[0].select, - [ - ast.Field( - chain=["event"], - type=ast.FieldType(name="event", table_type=events_table_type), - ), - ast.Field( - chain=["timestamp"], - type=ast.FieldType(name="timestamp", table_type=events_table_type), - ), - ], - ) - self.assertEqual( - node.select_queries[1].select, - [ - ast.Field( - chain=["event"], - type=ast.FieldType(name="event", table_type=events_table_type), - ), - ast.Field( - chain=["timestamp"], - type=ast.FieldType(name="timestamp", table_type=events_table_type), - ), - ], - ) - + @pytest.mark.usefixtures("unittest_snapshot") def test_call_type(self): node = self._select("select max(timestamp) from events") node = resolve_types(node, self.context) - expected = [ - ast.Call( - name="max", - # NB! timestamp was resolved to a DateTimeType for the Call's arg type. - type=ast.CallType( - name="max", - arg_types=[ast.DateTimeType()], - return_type=ast.UnknownType(), - ), - args=[ - ast.Field( - chain=["timestamp"], - type=ast.FieldType( - name="timestamp", - table_type=ast.TableType(table=self.database.events), - ), - ) - ], - ), - ] - self.assertEqual(node.select, expected) + assert pretty_dataclasses(node) == self.snapshot def test_ctes_loop(self): with self.assertRaises(ResolverException) as e: @@ -815,282 +234,40 @@ def test_ctes_subquery_recursion(self): ) @override_settings(PERSON_ON_EVENTS_OVERRIDE=False, PERSON_ON_EVENTS_V2_OVERRIDE=False) + @pytest.mark.usefixtures("unittest_snapshot") def test_asterisk_expander_table(self): self.setUp() # rebuild self.database with PERSON_ON_EVENTS_OVERRIDE=False node = self._select("select * from events") node = resolve_types(node, self.context) - - events_table_type = ast.TableType(table=self.database.events) - self.assertEqual( - node.select, - [ - ast.Field( - chain=["uuid"], - type=ast.FieldType(name="uuid", table_type=events_table_type), - ), - ast.Field( - chain=["event"], - type=ast.FieldType(name="event", table_type=events_table_type), - ), - ast.Field( - chain=["properties"], - type=ast.FieldType(name="properties", table_type=events_table_type), - ), - ast.Field( - chain=["timestamp"], - type=ast.FieldType(name="timestamp", table_type=events_table_type), - ), - ast.Field( - chain=["distinct_id"], - type=ast.FieldType(name="distinct_id", table_type=events_table_type), - ), - ast.Field( - chain=["elements_chain"], - type=ast.FieldType(name="elements_chain", table_type=events_table_type), - ), - ast.Field( - chain=["created_at"], - type=ast.FieldType(name="created_at", table_type=events_table_type), - ), - ast.Field( - chain=["$session_id"], - type=ast.FieldType(name="$session_id", table_type=events_table_type), - ), - ast.Field( - chain=["$group_0"], - type=ast.FieldType(name="$group_0", table_type=events_table_type), - ), - ast.Field( - chain=["$group_1"], - type=ast.FieldType(name="$group_1", table_type=events_table_type), - ), - ast.Field( - chain=["$group_2"], - type=ast.FieldType(name="$group_2", table_type=events_table_type), - ), - ast.Field( - chain=["$group_3"], - type=ast.FieldType(name="$group_3", table_type=events_table_type), - ), - ast.Field( - chain=["$group_4"], - type=ast.FieldType(name="$group_4", table_type=events_table_type), - ), - ], - ) + assert pretty_dataclasses(node) == self.snapshot @override_settings(PERSON_ON_EVENTS_OVERRIDE=False, PERSON_ON_EVENTS_V2_OVERRIDE=False) + @pytest.mark.usefixtures("unittest_snapshot") def test_asterisk_expander_table_alias(self): self.setUp() # rebuild self.database with PERSON_ON_EVENTS_OVERRIDE=False node = self._select("select * from events e") node = resolve_types(node, self.context) + assert pretty_dataclasses(node) == self.snapshot - events_table_type = ast.TableType(table=self.database.events) - events_table_alias_type = ast.TableAliasType(table_type=events_table_type, alias="e") - self.assertEqual( - node.select, - [ - ast.Field( - chain=["uuid"], - type=ast.FieldType(name="uuid", table_type=events_table_alias_type), - ), - ast.Field( - chain=["event"], - type=ast.FieldType(name="event", table_type=events_table_alias_type), - ), - ast.Field( - chain=["properties"], - type=ast.FieldType(name="properties", table_type=events_table_alias_type), - ), - ast.Field( - chain=["timestamp"], - type=ast.FieldType(name="timestamp", table_type=events_table_alias_type), - ), - ast.Field( - chain=["distinct_id"], - type=ast.FieldType(name="distinct_id", table_type=events_table_alias_type), - ), - ast.Field( - chain=["elements_chain"], - type=ast.FieldType(name="elements_chain", table_type=events_table_alias_type), - ), - ast.Field( - chain=["created_at"], - type=ast.FieldType(name="created_at", table_type=events_table_alias_type), - ), - ast.Field( - chain=["$session_id"], - type=ast.FieldType(name="$session_id", table_type=events_table_alias_type), - ), - ast.Field( - chain=["$group_0"], - type=ast.FieldType(name="$group_0", table_type=events_table_alias_type), - ), - ast.Field( - chain=["$group_1"], - type=ast.FieldType(name="$group_1", table_type=events_table_alias_type), - ), - ast.Field( - chain=["$group_2"], - type=ast.FieldType(name="$group_2", table_type=events_table_alias_type), - ), - ast.Field( - chain=["$group_3"], - type=ast.FieldType(name="$group_3", table_type=events_table_alias_type), - ), - ast.Field( - chain=["$group_4"], - type=ast.FieldType(name="$group_4", table_type=events_table_alias_type), - ), - ], - ) - + @pytest.mark.usefixtures("unittest_snapshot") def test_asterisk_expander_subquery(self): node = self._select("select * from (select 1 as a, 2 as b)") node = resolve_types(node, self.context) - select_subquery_type = ast.SelectQueryType( - aliases={ - "a": ast.FieldAliasType(alias="a", type=ast.IntegerType()), - "b": ast.FieldAliasType(alias="b", type=ast.IntegerType()), - }, - columns={ - "a": ast.FieldAliasType(alias="a", type=ast.IntegerType()), - "b": ast.FieldAliasType(alias="b", type=ast.IntegerType()), - }, - tables={}, - anonymous_tables=[], - ) - self.assertEqual( - node.select, - [ - ast.Field( - chain=["a"], - type=ast.FieldType(name="a", table_type=select_subquery_type), - ), - ast.Field( - chain=["b"], - type=ast.FieldType(name="b", table_type=select_subquery_type), - ), - ], - ) + assert pretty_dataclasses(node) == self.snapshot + @pytest.mark.usefixtures("unittest_snapshot") def test_asterisk_expander_subquery_alias(self): node = self._select("select x.* from (select 1 as a, 2 as b) x") node = resolve_types(node, self.context) - select_subquery_type = ast.SelectQueryAliasType( - alias="x", - select_query_type=ast.SelectQueryType( - aliases={ - "a": ast.FieldAliasType(alias="a", type=ast.IntegerType()), - "b": ast.FieldAliasType(alias="b", type=ast.IntegerType()), - }, - columns={ - "a": ast.FieldAliasType(alias="a", type=ast.IntegerType()), - "b": ast.FieldAliasType(alias="b", type=ast.IntegerType()), - }, - tables={}, - anonymous_tables=[], - ), - ) - self.assertEqual( - node.select, - [ - ast.Field( - chain=["a"], - type=ast.FieldType(name="a", table_type=select_subquery_type), - ), - ast.Field( - chain=["b"], - type=ast.FieldType(name="b", table_type=select_subquery_type), - ), - ], - ) + assert pretty_dataclasses(node) == self.snapshot @override_settings(PERSON_ON_EVENTS_OVERRIDE=False, PERSON_ON_EVENTS_V2_OVERRIDE=False) + @pytest.mark.usefixtures("unittest_snapshot") def test_asterisk_expander_from_subquery_table(self): self.setUp() # rebuild self.database with PERSON_ON_EVENTS_OVERRIDE=False node = self._select("select * from (select * from events)") node = resolve_types(node, self.context) - - events_table_type = ast.TableType(table=self.database.events) - inner_select_type = ast.SelectQueryType( - tables={"events": events_table_type}, - anonymous_tables=[], - aliases={}, - columns={ - "uuid": ast.FieldType(name="uuid", table_type=events_table_type), - "event": ast.FieldType(name="event", table_type=events_table_type), - "properties": ast.FieldType(name="properties", table_type=events_table_type), - "timestamp": ast.FieldType(name="timestamp", table_type=events_table_type), - "distinct_id": ast.FieldType(name="distinct_id", table_type=events_table_type), - "elements_chain": ast.FieldType(name="elements_chain", table_type=events_table_type), - "created_at": ast.FieldType(name="created_at", table_type=events_table_type), - "$session_id": ast.FieldType(name="$session_id", table_type=events_table_type), - "$group_0": ast.FieldType(name="$group_0", table_type=events_table_type), - "$group_1": ast.FieldType(name="$group_1", table_type=events_table_type), - "$group_2": ast.FieldType(name="$group_2", table_type=events_table_type), - "$group_3": ast.FieldType(name="$group_3", table_type=events_table_type), - "$group_4": ast.FieldType(name="$group_4", table_type=events_table_type), - }, - ) - - self.assertEqual( - node.select, - [ - ast.Field( - chain=["uuid"], - type=ast.FieldType(name="uuid", table_type=inner_select_type), - ), - ast.Field( - chain=["event"], - type=ast.FieldType(name="event", table_type=inner_select_type), - ), - ast.Field( - chain=["properties"], - type=ast.FieldType(name="properties", table_type=inner_select_type), - ), - ast.Field( - chain=["timestamp"], - type=ast.FieldType(name="timestamp", table_type=inner_select_type), - ), - ast.Field( - chain=["distinct_id"], - type=ast.FieldType(name="distinct_id", table_type=inner_select_type), - ), - ast.Field( - chain=["elements_chain"], - type=ast.FieldType(name="elements_chain", table_type=inner_select_type), - ), - ast.Field( - chain=["created_at"], - type=ast.FieldType(name="created_at", table_type=inner_select_type), - ), - ast.Field( - chain=["$session_id"], - type=ast.FieldType(name="$session_id", table_type=inner_select_type), - ), - ast.Field( - chain=["$group_0"], - type=ast.FieldType(name="$group_0", table_type=inner_select_type), - ), - ast.Field( - chain=["$group_1"], - type=ast.FieldType(name="$group_1", table_type=inner_select_type), - ), - ast.Field( - chain=["$group_2"], - type=ast.FieldType(name="$group_2", table_type=inner_select_type), - ), - ast.Field( - chain=["$group_3"], - type=ast.FieldType(name="$group_3", table_type=inner_select_type), - ), - ast.Field( - chain=["$group_4"], - type=ast.FieldType(name="$group_4", table_type=inner_select_type), - ), - ], - ) + assert pretty_dataclasses(node) == self.snapshot def test_asterisk_expander_multiple_table_error(self): node = self._select("select * from (select 1 as a, 2 as b) x left join (select 1 as a, 2 as b) y on x.a = y.a") @@ -1102,95 +279,12 @@ def test_asterisk_expander_multiple_table_error(self): ) @override_settings(PERSON_ON_EVENTS_OVERRIDE=False, PERSON_ON_EVENTS_V2_OVERRIDE=False) + @pytest.mark.usefixtures("unittest_snapshot") def test_asterisk_expander_select_union(self): self.setUp() # rebuild self.database with PERSON_ON_EVENTS_OVERRIDE=False node = self._select("select * from (select * from events union all select * from events)") node = resolve_types(node, self.context) - - events_table_type = ast.TableType(table=self.database.events) - inner_select_type = ast.SelectUnionQueryType( - types=[ - ast.SelectQueryType( - tables={"events": events_table_type}, - anonymous_tables=[], - aliases={}, - columns={ - "uuid": ast.FieldType(name="uuid", table_type=events_table_type), - "event": ast.FieldType(name="event", table_type=events_table_type), - "properties": ast.FieldType(name="properties", table_type=events_table_type), - "timestamp": ast.FieldType(name="timestamp", table_type=events_table_type), - "distinct_id": ast.FieldType(name="distinct_id", table_type=events_table_type), - "elements_chain": ast.FieldType(name="elements_chain", table_type=events_table_type), - "created_at": ast.FieldType(name="created_at", table_type=events_table_type), - "$session_id": ast.FieldType(name="$session_id", table_type=events_table_type), - "$group_0": ast.FieldType(name="$group_0", table_type=events_table_type), - "$group_1": ast.FieldType(name="$group_1", table_type=events_table_type), - "$group_2": ast.FieldType(name="$group_2", table_type=events_table_type), - "$group_3": ast.FieldType(name="$group_3", table_type=events_table_type), - "$group_4": ast.FieldType(name="$group_4", table_type=events_table_type), - }, - ) - ] - * 2 - ) - - self.assertEqual( - node.select, - [ - ast.Field( - chain=["uuid"], - type=ast.FieldType(name="uuid", table_type=inner_select_type), - ), - ast.Field( - chain=["event"], - type=ast.FieldType(name="event", table_type=inner_select_type), - ), - ast.Field( - chain=["properties"], - type=ast.FieldType(name="properties", table_type=inner_select_type), - ), - ast.Field( - chain=["timestamp"], - type=ast.FieldType(name="timestamp", table_type=inner_select_type), - ), - ast.Field( - chain=["distinct_id"], - type=ast.FieldType(name="distinct_id", table_type=inner_select_type), - ), - ast.Field( - chain=["elements_chain"], - type=ast.FieldType(name="elements_chain", table_type=inner_select_type), - ), - ast.Field( - chain=["created_at"], - type=ast.FieldType(name="created_at", table_type=inner_select_type), - ), - ast.Field( - chain=["$session_id"], - type=ast.FieldType(name="$session_id", table_type=inner_select_type), - ), - ast.Field( - chain=["$group_0"], - type=ast.FieldType(name="$group_0", table_type=inner_select_type), - ), - ast.Field( - chain=["$group_1"], - type=ast.FieldType(name="$group_1", table_type=inner_select_type), - ), - ast.Field( - chain=["$group_2"], - type=ast.FieldType(name="$group_2", table_type=inner_select_type), - ), - ast.Field( - chain=["$group_3"], - type=ast.FieldType(name="$group_3", table_type=inner_select_type), - ), - ast.Field( - chain=["$group_4"], - type=ast.FieldType(name="$group_4", table_type=inner_select_type), - ), - ], - ) + assert pretty_dataclasses(node) == self.snapshot def test_lambda_parent_scope(self): # does not raise @@ -1234,7 +328,8 @@ def test_visit_hogqlx_tag(self): node = cast(ast.SelectQuery, resolve_types(node, self.context)) table_node = cast(ast.SelectQuery, node).select_from.table expected = ast.SelectQuery( - select=[ast.Field(chain=["event"])], select_from=ast.JoinExpr(table=ast.Field(chain=["events"])) + select=[ast.Alias(hidden=True, alias="event", expr=ast.Field(chain=["event"]))], + select_from=ast.JoinExpr(table=ast.Field(chain=["events"])), ) assert clone_expr(table_node, clear_types=True) == expected diff --git a/posthog/hogql/test/utils.py b/posthog/hogql/test/utils.py index 8e5fc45313a0f..c63f17e3cbc5c 100644 --- a/posthog/hogql/test/utils.py +++ b/posthog/hogql/test/utils.py @@ -1,3 +1,7 @@ +import dataclasses +import json + + def pretty_print_in_tests(query: str, team_id: int) -> str: return ( query.replace("SELECT", "\nSELECT") @@ -9,3 +13,46 @@ def pretty_print_in_tests(query: str, team_id: int) -> str: .replace("SETTINGS", "\nSETTINGS") .replace(f"team_id, {team_id})", "team_id, 420)") ) + + +def pretty_dataclasses(obj, seen=None, indent=0): + if seen is None: + seen = set() + + indent_space = " " * indent + next_indent = " " * (indent + 2) + + if dataclasses.is_dataclass(obj): + obj_id = id(obj) + if obj_id in seen: + return "" + seen.add(obj_id) + + field_strings = [] + fields = sorted(dataclasses.fields(obj), key=lambda f: f.name) + for f in fields: + value = getattr(obj, f.name) + if value is not None: + formatted_value = pretty_dataclasses(value, seen, indent + 2) + field_strings.append(f"{next_indent}{f.name}: {formatted_value}") + + return "{\n" + "\n".join(field_strings) + "\n" + indent_space + "}" + + elif isinstance(obj, list): + if len(obj) == 0: + return "[]" + elements = [pretty_dataclasses(item, seen, indent + 2) for item in obj] + return "[\n" + ",\n".join(next_indent + element for element in elements) + "\n" + indent_space + "]" + + elif isinstance(obj, dict): + if len(obj) == 0: + return "{}" + sorted_items = sorted(obj.items()) + key_value_pairs = [f"{k}: {pretty_dataclasses(v, seen, indent + 2)}" for k, v in sorted_items] + return "{\n" + ",\n".join(next_indent + pair for pair in key_value_pairs) + "\n" + indent_space + "}" + + elif isinstance(obj, str): + return json.dumps(obj) + + else: + return str(obj) From 6d579c74dbde8cd159d1e13c38ee1e9ff0cd438e Mon Sep 17 00:00:00 2001 From: Marius Andra Date: Tue, 21 Nov 2023 22:19:50 +0100 Subject: [PATCH 06/15] resolver --- .../test/__snapshots__/test_resolver.ambr | 3318 +++++++++++++++++ 1 file changed, 3318 insertions(+) create mode 100644 posthog/hogql/test/__snapshots__/test_resolver.ambr diff --git a/posthog/hogql/test/__snapshots__/test_resolver.ambr b/posthog/hogql/test/__snapshots__/test_resolver.ambr new file mode 100644 index 0000000000000..7d9973d90cadf --- /dev/null +++ b/posthog/hogql/test/__snapshots__/test_resolver.ambr @@ -0,0 +1,3318 @@ +# name: TestResolver.test_asterisk_expander_from_subquery_table + ' + { + select: [ + { + alias: "uuid" + expr: { + chain: [ + "uuid" + ] + type: { + name: "uuid" + table_type: { + aliases: {} + anonymous_tables: [] + columns: { + $group_0: { + alias: "$group_0" + type: { + name: "$group_0" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x1088f5120>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x1088f45e0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x1088f48b0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x1088f4820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x1088f5ab0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + }, + $group_1: { + alias: "$group_1" + type: { + name: "$group_1" + table_type: + } + }, + $group_2: { + alias: "$group_2" + type: { + name: "$group_2" + table_type: + } + }, + $group_3: { + alias: "$group_3" + type: { + name: "$group_3" + table_type: + } + }, + $group_4: { + alias: "$group_4" + type: { + name: "$group_4" + table_type: + } + }, + $session_id: { + alias: "$session_id" + type: { + name: "$session_id" + table_type: + } + }, + created_at: { + alias: "created_at" + type: { + name: "created_at" + table_type: + } + }, + distinct_id: { + alias: "distinct_id" + type: { + name: "distinct_id" + table_type: + } + }, + elements_chain: { + alias: "elements_chain" + type: { + name: "elements_chain" + table_type: + } + }, + event: { + alias: "event" + type: { + name: "event" + table_type: + } + }, + properties: { + alias: "properties" + type: { + name: "properties" + table_type: + } + }, + timestamp: { + alias: "timestamp" + type: { + name: "timestamp" + table_type: + } + }, + uuid: { + alias: "uuid" + type: { + name: "uuid" + table_type: + } + } + } + ctes: {} + tables: { + events: + } + } + } + } + hidden: True + type: { + alias: "uuid" + type: + } + }, + { + alias: "event" + expr: { + chain: [ + "event" + ] + type: { + name: "event" + table_type: + } + } + hidden: True + type: { + alias: "event" + type: + } + }, + { + alias: "properties" + expr: { + chain: [ + "properties" + ] + type: { + name: "properties" + table_type: + } + } + hidden: True + type: { + alias: "properties" + type: + } + }, + { + alias: "timestamp" + expr: { + chain: [ + "timestamp" + ] + type: { + name: "timestamp" + table_type: + } + } + hidden: True + type: { + alias: "timestamp" + type: + } + }, + { + alias: "distinct_id" + expr: { + chain: [ + "distinct_id" + ] + type: { + name: "distinct_id" + table_type: + } + } + hidden: True + type: { + alias: "distinct_id" + type: + } + }, + { + alias: "elements_chain" + expr: { + chain: [ + "elements_chain" + ] + type: { + name: "elements_chain" + table_type: + } + } + hidden: True + type: { + alias: "elements_chain" + type: + } + }, + { + alias: "created_at" + expr: { + chain: [ + "created_at" + ] + type: { + name: "created_at" + table_type: + } + } + hidden: True + type: { + alias: "created_at" + type: + } + }, + { + alias: "$session_id" + expr: { + chain: [ + "$session_id" + ] + type: { + name: "$session_id" + table_type: + } + } + hidden: True + type: { + alias: "$session_id" + type: + } + }, + { + alias: "$group_0" + expr: { + chain: [ + "$group_0" + ] + type: { + name: "$group_0" + table_type: + } + } + hidden: True + type: { + alias: "$group_0" + type: + } + }, + { + alias: "$group_1" + expr: { + chain: [ + "$group_1" + ] + type: { + name: "$group_1" + table_type: + } + } + hidden: True + type: { + alias: "$group_1" + type: + } + }, + { + alias: "$group_2" + expr: { + chain: [ + "$group_2" + ] + type: { + name: "$group_2" + table_type: + } + } + hidden: True + type: { + alias: "$group_2" + type: + } + }, + { + alias: "$group_3" + expr: { + chain: [ + "$group_3" + ] + type: { + name: "$group_3" + table_type: + } + } + hidden: True + type: { + alias: "$group_3" + type: + } + }, + { + alias: "$group_4" + expr: { + chain: [ + "$group_4" + ] + type: { + name: "$group_4" + table_type: + } + } + hidden: True + type: { + alias: "$group_4" + type: + } + } + ] + select_from: { + table: { + select: [ + { + alias: "uuid" + expr: { + chain: [ + "uuid" + ] + type: + } + hidden: True + type: + }, + { + alias: "event" + expr: { + chain: [ + "event" + ] + type: + } + hidden: True + type: + }, + { + alias: "properties" + expr: { + chain: [ + "properties" + ] + type: + } + hidden: True + type: + }, + { + alias: "timestamp" + expr: { + chain: [ + "timestamp" + ] + type: + } + hidden: True + type: + }, + { + alias: "distinct_id" + expr: { + chain: [ + "distinct_id" + ] + type: + } + hidden: True + type: + }, + { + alias: "elements_chain" + expr: { + chain: [ + "elements_chain" + ] + type: + } + hidden: True + type: + }, + { + alias: "created_at" + expr: { + chain: [ + "created_at" + ] + type: + } + hidden: True + type: + }, + { + alias: "$session_id" + expr: { + chain: [ + "$session_id" + ] + type: + } + hidden: True + type: + }, + { + alias: "$group_0" + expr: { + chain: [ + "$group_0" + ] + type: + } + hidden: True + type: + }, + { + alias: "$group_1" + expr: { + chain: [ + "$group_1" + ] + type: + } + hidden: True + type: + }, + { + alias: "$group_2" + expr: { + chain: [ + "$group_2" + ] + type: + } + hidden: True + type: + }, + { + alias: "$group_3" + expr: { + chain: [ + "$group_3" + ] + type: + } + hidden: True + type: + }, + { + alias: "$group_4" + expr: { + chain: [ + "$group_4" + ] + type: + } + hidden: True + type: + } + ] + select_from: { + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [ + + ] + columns: { + $group_0: , + $group_1: , + $group_2: , + $group_3: , + $group_4: , + $session_id: , + created_at: , + distinct_id: , + elements_chain: , + event: , + properties: , + timestamp: , + uuid: + } + ctes: {} + tables: {} + } + } + ' +--- +# name: TestResolver.test_asterisk_expander_select_union + ' + { + select: [ + { + alias: "uuid" + expr: { + chain: [ + "uuid" + ] + type: { + name: "uuid" + table_type: { + aliases: {} + anonymous_tables: [] + columns: { + $group_0: { + alias: "$group_0" + type: { + name: "$group_0" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x1088f5120>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x1088f45e0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x1088f48b0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x1088f4820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x1088f5ab0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + }, + $group_1: { + alias: "$group_1" + type: { + name: "$group_1" + table_type: + } + }, + $group_2: { + alias: "$group_2" + type: { + name: "$group_2" + table_type: + } + }, + $group_3: { + alias: "$group_3" + type: { + name: "$group_3" + table_type: + } + }, + $group_4: { + alias: "$group_4" + type: { + name: "$group_4" + table_type: + } + }, + $session_id: { + alias: "$session_id" + type: { + name: "$session_id" + table_type: + } + }, + created_at: { + alias: "created_at" + type: { + name: "created_at" + table_type: + } + }, + distinct_id: { + alias: "distinct_id" + type: { + name: "distinct_id" + table_type: + } + }, + elements_chain: { + alias: "elements_chain" + type: { + name: "elements_chain" + table_type: + } + }, + event: { + alias: "event" + type: { + name: "event" + table_type: + } + }, + properties: { + alias: "properties" + type: { + name: "properties" + table_type: + } + }, + timestamp: { + alias: "timestamp" + type: { + name: "timestamp" + table_type: + } + }, + uuid: { + alias: "uuid" + type: { + name: "uuid" + table_type: + } + } + } + ctes: {} + tables: { + events: + } + } + } + } + hidden: True + type: { + alias: "uuid" + type: + } + }, + { + alias: "event" + expr: { + chain: [ + "event" + ] + type: { + name: "event" + table_type: + } + } + hidden: True + type: { + alias: "event" + type: + } + }, + { + alias: "properties" + expr: { + chain: [ + "properties" + ] + type: { + name: "properties" + table_type: + } + } + hidden: True + type: { + alias: "properties" + type: + } + }, + { + alias: "timestamp" + expr: { + chain: [ + "timestamp" + ] + type: { + name: "timestamp" + table_type: + } + } + hidden: True + type: { + alias: "timestamp" + type: + } + }, + { + alias: "distinct_id" + expr: { + chain: [ + "distinct_id" + ] + type: { + name: "distinct_id" + table_type: + } + } + hidden: True + type: { + alias: "distinct_id" + type: + } + }, + { + alias: "elements_chain" + expr: { + chain: [ + "elements_chain" + ] + type: { + name: "elements_chain" + table_type: + } + } + hidden: True + type: { + alias: "elements_chain" + type: + } + }, + { + alias: "created_at" + expr: { + chain: [ + "created_at" + ] + type: { + name: "created_at" + table_type: + } + } + hidden: True + type: { + alias: "created_at" + type: + } + }, + { + alias: "$session_id" + expr: { + chain: [ + "$session_id" + ] + type: { + name: "$session_id" + table_type: + } + } + hidden: True + type: { + alias: "$session_id" + type: + } + }, + { + alias: "$group_0" + expr: { + chain: [ + "$group_0" + ] + type: { + name: "$group_0" + table_type: + } + } + hidden: True + type: { + alias: "$group_0" + type: + } + }, + { + alias: "$group_1" + expr: { + chain: [ + "$group_1" + ] + type: { + name: "$group_1" + table_type: + } + } + hidden: True + type: { + alias: "$group_1" + type: + } + }, + { + alias: "$group_2" + expr: { + chain: [ + "$group_2" + ] + type: { + name: "$group_2" + table_type: + } + } + hidden: True + type: { + alias: "$group_2" + type: + } + }, + { + alias: "$group_3" + expr: { + chain: [ + "$group_3" + ] + type: { + name: "$group_3" + table_type: + } + } + hidden: True + type: { + alias: "$group_3" + type: + } + }, + { + alias: "$group_4" + expr: { + chain: [ + "$group_4" + ] + type: { + name: "$group_4" + table_type: + } + } + hidden: True + type: { + alias: "$group_4" + type: + } + } + ] + select_from: { + table: { + select_queries: [ + { + select: [ + { + alias: "uuid" + expr: { + chain: [ + "uuid" + ] + type: + } + hidden: True + type: + }, + { + alias: "event" + expr: { + chain: [ + "event" + ] + type: + } + hidden: True + type: + }, + { + alias: "properties" + expr: { + chain: [ + "properties" + ] + type: + } + hidden: True + type: + }, + { + alias: "timestamp" + expr: { + chain: [ + "timestamp" + ] + type: + } + hidden: True + type: + }, + { + alias: "distinct_id" + expr: { + chain: [ + "distinct_id" + ] + type: + } + hidden: True + type: + }, + { + alias: "elements_chain" + expr: { + chain: [ + "elements_chain" + ] + type: + } + hidden: True + type: + }, + { + alias: "created_at" + expr: { + chain: [ + "created_at" + ] + type: + } + hidden: True + type: + }, + { + alias: "$session_id" + expr: { + chain: [ + "$session_id" + ] + type: + } + hidden: True + type: + }, + { + alias: "$group_0" + expr: { + chain: [ + "$group_0" + ] + type: + } + hidden: True + type: + }, + { + alias: "$group_1" + expr: { + chain: [ + "$group_1" + ] + type: + } + hidden: True + type: + }, + { + alias: "$group_2" + expr: { + chain: [ + "$group_2" + ] + type: + } + hidden: True + type: + }, + { + alias: "$group_3" + expr: { + chain: [ + "$group_3" + ] + type: + } + hidden: True + type: + }, + { + alias: "$group_4" + expr: { + chain: [ + "$group_4" + ] + type: + } + hidden: True + type: + } + ] + select_from: { + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: + }, + { + select: [ + { + alias: "uuid" + expr: { + chain: [ + "uuid" + ] + type: { + name: "uuid" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x1088f5120>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x1088f45e0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x1088f48b0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x1088f4820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x1088f5ab0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + } + hidden: True + type: { + alias: "uuid" + type: + } + }, + { + alias: "event" + expr: { + chain: [ + "event" + ] + type: { + name: "event" + table_type: + } + } + hidden: True + type: { + alias: "event" + type: + } + }, + { + alias: "properties" + expr: { + chain: [ + "properties" + ] + type: { + name: "properties" + table_type: + } + } + hidden: True + type: { + alias: "properties" + type: + } + }, + { + alias: "timestamp" + expr: { + chain: [ + "timestamp" + ] + type: { + name: "timestamp" + table_type: + } + } + hidden: True + type: { + alias: "timestamp" + type: + } + }, + { + alias: "distinct_id" + expr: { + chain: [ + "distinct_id" + ] + type: { + name: "distinct_id" + table_type: + } + } + hidden: True + type: { + alias: "distinct_id" + type: + } + }, + { + alias: "elements_chain" + expr: { + chain: [ + "elements_chain" + ] + type: { + name: "elements_chain" + table_type: + } + } + hidden: True + type: { + alias: "elements_chain" + type: + } + }, + { + alias: "created_at" + expr: { + chain: [ + "created_at" + ] + type: { + name: "created_at" + table_type: + } + } + hidden: True + type: { + alias: "created_at" + type: + } + }, + { + alias: "$session_id" + expr: { + chain: [ + "$session_id" + ] + type: { + name: "$session_id" + table_type: + } + } + hidden: True + type: { + alias: "$session_id" + type: + } + }, + { + alias: "$group_0" + expr: { + chain: [ + "$group_0" + ] + type: { + name: "$group_0" + table_type: + } + } + hidden: True + type: { + alias: "$group_0" + type: + } + }, + { + alias: "$group_1" + expr: { + chain: [ + "$group_1" + ] + type: { + name: "$group_1" + table_type: + } + } + hidden: True + type: { + alias: "$group_1" + type: + } + }, + { + alias: "$group_2" + expr: { + chain: [ + "$group_2" + ] + type: { + name: "$group_2" + table_type: + } + } + hidden: True + type: { + alias: "$group_2" + type: + } + }, + { + alias: "$group_3" + expr: { + chain: [ + "$group_3" + ] + type: { + name: "$group_3" + table_type: + } + } + hidden: True + type: { + alias: "$group_3" + type: + } + }, + { + alias: "$group_4" + expr: { + chain: [ + "$group_4" + ] + type: { + name: "$group_4" + table_type: + } + } + hidden: True + type: { + alias: "$group_4" + type: + } + } + ] + select_from: { + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: { + $group_0: , + $group_1: , + $group_2: , + $group_3: , + $group_4: , + $session_id: , + created_at: , + distinct_id: , + elements_chain: , + event: , + properties: , + timestamp: , + uuid: + } + ctes: {} + tables: { + events: + } + } + } + ] + type: { + types: [ + , + + ] + } + } + type: + } + type: { + aliases: {} + anonymous_tables: [ + + ] + columns: { + $group_0: , + $group_1: , + $group_2: , + $group_3: , + $group_4: , + $session_id: , + created_at: , + distinct_id: , + elements_chain: , + event: , + properties: , + timestamp: , + uuid: + } + ctes: {} + tables: {} + } + } + ' +--- +# name: TestResolver.test_asterisk_expander_subquery + ' + { + select: [ + { + alias: "a" + expr: { + chain: [ + "a" + ] + type: { + name: "a" + table_type: { + aliases: { + a: { + alias: "a" + type: { + data_type: "int" + } + }, + b: { + alias: "b" + type: { + data_type: "int" + } + } + } + anonymous_tables: [] + columns: { + a: , + b: + } + ctes: {} + tables: {} + } + } + } + hidden: True + type: { + alias: "a" + type: + } + }, + { + alias: "b" + expr: { + chain: [ + "b" + ] + type: { + name: "b" + table_type: + } + } + hidden: True + type: { + alias: "b" + type: + } + } + ] + select_from: { + table: { + select: [ + { + alias: "a" + expr: { + type: + value: 1 + } + hidden: False + type: + }, + { + alias: "b" + expr: { + type: + value: 2 + } + hidden: False + type: + } + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [ + + ] + columns: { + a: , + b: + } + ctes: {} + tables: {} + } + } + ' +--- +# name: TestResolver.test_asterisk_expander_subquery_alias + ' + { + select: [ + { + alias: "a" + expr: { + chain: [ + "a" + ] + type: { + name: "a" + table_type: { + alias: "x" + select_query_type: { + aliases: { + a: { + alias: "a" + type: { + data_type: "int" + } + }, + b: { + alias: "b" + type: { + data_type: "int" + } + } + } + anonymous_tables: [] + columns: { + a: , + b: + } + ctes: {} + tables: {} + } + } + } + } + hidden: True + type: { + alias: "a" + type: + } + }, + { + alias: "b" + expr: { + chain: [ + "b" + ] + type: { + name: "b" + table_type: + } + } + hidden: True + type: { + alias: "b" + type: + } + } + ] + select_from: { + alias: "x" + table: { + select: [ + { + alias: "a" + expr: { + type: + value: 1 + } + hidden: False + type: + }, + { + alias: "b" + expr: { + type: + value: 2 + } + hidden: False + type: + } + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: { + a: , + b: + } + ctes: {} + tables: { + x: + } + } + } + ' +--- +# name: TestResolver.test_asterisk_expander_table + ' + { + select: [ + { + alias: "uuid" + expr: { + chain: [ + "uuid" + ] + type: { + name: "uuid" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x1088f5120>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x1088f45e0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x1088f48b0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x1088f4820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x1088f5ab0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + } + hidden: True + type: { + alias: "uuid" + type: + } + }, + { + alias: "event" + expr: { + chain: [ + "event" + ] + type: { + name: "event" + table_type: + } + } + hidden: True + type: { + alias: "event" + type: + } + }, + { + alias: "properties" + expr: { + chain: [ + "properties" + ] + type: { + name: "properties" + table_type: + } + } + hidden: True + type: { + alias: "properties" + type: + } + }, + { + alias: "timestamp" + expr: { + chain: [ + "timestamp" + ] + type: { + name: "timestamp" + table_type: + } + } + hidden: True + type: { + alias: "timestamp" + type: + } + }, + { + alias: "distinct_id" + expr: { + chain: [ + "distinct_id" + ] + type: { + name: "distinct_id" + table_type: + } + } + hidden: True + type: { + alias: "distinct_id" + type: + } + }, + { + alias: "elements_chain" + expr: { + chain: [ + "elements_chain" + ] + type: { + name: "elements_chain" + table_type: + } + } + hidden: True + type: { + alias: "elements_chain" + type: + } + }, + { + alias: "created_at" + expr: { + chain: [ + "created_at" + ] + type: { + name: "created_at" + table_type: + } + } + hidden: True + type: { + alias: "created_at" + type: + } + }, + { + alias: "$session_id" + expr: { + chain: [ + "$session_id" + ] + type: { + name: "$session_id" + table_type: + } + } + hidden: True + type: { + alias: "$session_id" + type: + } + }, + { + alias: "$group_0" + expr: { + chain: [ + "$group_0" + ] + type: { + name: "$group_0" + table_type: + } + } + hidden: True + type: { + alias: "$group_0" + type: + } + }, + { + alias: "$group_1" + expr: { + chain: [ + "$group_1" + ] + type: { + name: "$group_1" + table_type: + } + } + hidden: True + type: { + alias: "$group_1" + type: + } + }, + { + alias: "$group_2" + expr: { + chain: [ + "$group_2" + ] + type: { + name: "$group_2" + table_type: + } + } + hidden: True + type: { + alias: "$group_2" + type: + } + }, + { + alias: "$group_3" + expr: { + chain: [ + "$group_3" + ] + type: { + name: "$group_3" + table_type: + } + } + hidden: True + type: { + alias: "$group_3" + type: + } + }, + { + alias: "$group_4" + expr: { + chain: [ + "$group_4" + ] + type: { + name: "$group_4" + table_type: + } + } + hidden: True + type: { + alias: "$group_4" + type: + } + } + ] + select_from: { + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: { + $group_0: , + $group_1: , + $group_2: , + $group_3: , + $group_4: , + $session_id: , + created_at: , + distinct_id: , + elements_chain: , + event: , + properties: , + timestamp: , + uuid: + } + ctes: {} + tables: { + events: + } + } + } + ' +--- +# name: TestResolver.test_asterisk_expander_table_alias + ' + { + select: [ + { + alias: "uuid" + expr: { + chain: [ + "uuid" + ] + type: { + name: "uuid" + table_type: { + alias: "e" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x1088f5120>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x1088f45e0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x1088f48b0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x1088f4820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x1088f5ab0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + } + } + hidden: True + type: { + alias: "uuid" + type: + } + }, + { + alias: "event" + expr: { + chain: [ + "event" + ] + type: { + name: "event" + table_type: + } + } + hidden: True + type: { + alias: "event" + type: + } + }, + { + alias: "properties" + expr: { + chain: [ + "properties" + ] + type: { + name: "properties" + table_type: + } + } + hidden: True + type: { + alias: "properties" + type: + } + }, + { + alias: "timestamp" + expr: { + chain: [ + "timestamp" + ] + type: { + name: "timestamp" + table_type: + } + } + hidden: True + type: { + alias: "timestamp" + type: + } + }, + { + alias: "distinct_id" + expr: { + chain: [ + "distinct_id" + ] + type: { + name: "distinct_id" + table_type: + } + } + hidden: True + type: { + alias: "distinct_id" + type: + } + }, + { + alias: "elements_chain" + expr: { + chain: [ + "elements_chain" + ] + type: { + name: "elements_chain" + table_type: + } + } + hidden: True + type: { + alias: "elements_chain" + type: + } + }, + { + alias: "created_at" + expr: { + chain: [ + "created_at" + ] + type: { + name: "created_at" + table_type: + } + } + hidden: True + type: { + alias: "created_at" + type: + } + }, + { + alias: "$session_id" + expr: { + chain: [ + "$session_id" + ] + type: { + name: "$session_id" + table_type: + } + } + hidden: True + type: { + alias: "$session_id" + type: + } + }, + { + alias: "$group_0" + expr: { + chain: [ + "$group_0" + ] + type: { + name: "$group_0" + table_type: + } + } + hidden: True + type: { + alias: "$group_0" + type: + } + }, + { + alias: "$group_1" + expr: { + chain: [ + "$group_1" + ] + type: { + name: "$group_1" + table_type: + } + } + hidden: True + type: { + alias: "$group_1" + type: + } + }, + { + alias: "$group_2" + expr: { + chain: [ + "$group_2" + ] + type: { + name: "$group_2" + table_type: + } + } + hidden: True + type: { + alias: "$group_2" + type: + } + }, + { + alias: "$group_3" + expr: { + chain: [ + "$group_3" + ] + type: { + name: "$group_3" + table_type: + } + } + hidden: True + type: { + alias: "$group_3" + type: + } + }, + { + alias: "$group_4" + expr: { + chain: [ + "$group_4" + ] + type: { + name: "$group_4" + table_type: + } + } + hidden: True + type: { + alias: "$group_4" + type: + } + } + ] + select_from: { + alias: "e" + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: { + $group_0: , + $group_1: , + $group_2: , + $group_3: , + $group_4: , + $session_id: , + created_at: , + distinct_id: , + elements_chain: , + event: , + properties: , + timestamp: , + uuid: + } + ctes: {} + tables: { + e: + } + } + } + ' +--- +# name: TestResolver.test_call_type + ' + { + select: [ + { + args: [ + { + alias: "timestamp" + expr: { + chain: [ + "timestamp" + ] + type: { + name: "timestamp" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x1088f5120>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x1088f45e0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x1088f48b0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x1088f4820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x1088f5ab0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + } + hidden: True + type: { + alias: "timestamp" + type: + } + } + ] + distinct: False + name: "max" + type: { + arg_types: [ + { + data_type: "datetime" + } + ] + name: "max" + return_type: { + data_type: "unknown" + } + } + } + ] + select_from: { + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: {} + ctes: {} + tables: { + events: + } + } + } + ' +--- +# name: TestResolver.test_resolve_boolean_operation_types + ' + { + select: [ + { + exprs: [ + { + type: { + data_type: "int" + } + value: 1 + }, + { + type: { + data_type: "int" + } + value: 1 + } + ] + type: { + data_type: "bool" + } + }, + { + exprs: [ + { + type: { + data_type: "int" + } + value: 1 + }, + { + type: { + data_type: "int" + } + value: 1 + } + ] + type: { + data_type: "bool" + } + }, + { + expr: { + type: { + data_type: "bool" + } + value: True + } + type: { + data_type: "bool" + } + } + ] + type: { + aliases: {} + anonymous_tables: [] + columns: {} + ctes: {} + tables: {} + } + } + ' +--- +# name: TestResolver.test_resolve_constant_type + ' + { + select: [ + { + type: { + data_type: "int" + } + value: 1 + }, + { + type: { + data_type: "str" + } + value: "boo" + }, + { + type: { + data_type: "bool" + } + value: True + }, + { + type: { + data_type: "float" + } + value: 1.1232 + }, + { + type: { + data_type: "unknown" + } + }, + { + type: { + data_type: "date" + } + value: 2020-01-10 + }, + { + type: { + data_type: "datetime" + } + value: 2020-01-10 00:00:00+00:00 + }, + { + type: { + data_type: "uuid" + } + value: 00000000-0000-4000-8000-000000000000 + }, + { + type: { + data_type: "array" + item_type: { + data_type: "unknown" + } + } + value: [] + }, + { + type: { + data_type: "array" + item_type: { + data_type: "int" + } + } + value: [ + 1, + 2 + ] + }, + { + type: { + data_type: "tuple" + item_types: [ + { + data_type: "int" + }, + { + data_type: "int" + }, + { + data_type: "int" + } + ] + } + value: (1, 2, 3) + } + ] + type: { + aliases: {} + anonymous_tables: [] + columns: {} + ctes: {} + tables: {} + } + } + ' +--- +# name: TestResolver.test_resolve_events_table + ' + { + select: [ + { + alias: "event" + expr: { + chain: [ + "event" + ] + type: { + name: "event" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x1088f5120>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x1088f45e0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x1088f48b0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x1088f4820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x1088f5ab0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + } + hidden: True + type: { + alias: "event" + type: + } + }, + { + alias: "timestamp" + expr: { + chain: [ + "events", + "timestamp" + ] + type: { + name: "timestamp" + table_type: + } + } + hidden: True + type: { + alias: "timestamp" + type: + } + } + ] + select_from: { + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: { + event: , + timestamp: + } + ctes: {} + tables: { + events: + } + } + where: { + left: { + alias: "event" + expr: { + chain: [ + "events", + "event" + ] + type: { + name: "event" + table_type: + } + } + hidden: True + type: { + alias: "event" + type: + } + } + op: "==" + right: { + type: { + data_type: "str" + } + value: "test" + } + type: { + data_type: "bool" + } + } + } + ' +--- +# name: TestResolver.test_resolve_events_table_alias + ' + { + select: [ + { + alias: "event" + expr: { + chain: [ + "event" + ] + type: { + name: "event" + table_type: { + alias: "e" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x1088f5120>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x1088f45e0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x1088f48b0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x1088f4820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x1088f5ab0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + } + } + hidden: True + type: { + alias: "event" + type: + } + }, + { + alias: "timestamp" + expr: { + chain: [ + "e", + "timestamp" + ] + type: { + name: "timestamp" + table_type: + } + } + hidden: True + type: { + alias: "timestamp" + type: + } + } + ] + select_from: { + alias: "e" + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: { + event: , + timestamp: + } + ctes: {} + tables: { + e: + } + } + where: { + left: { + alias: "event" + expr: { + chain: [ + "e", + "event" + ] + type: { + name: "event" + table_type: + } + } + hidden: True + type: { + alias: "event" + type: + } + } + op: "==" + right: { + type: { + data_type: "str" + } + value: "test" + } + type: { + data_type: "bool" + } + } + } + ' +--- +# name: TestResolver.test_resolve_events_table_column_alias + ' + { + select: [ + { + alias: "ee" + expr: { + alias: "event" + expr: { + chain: [ + "event" + ] + type: { + name: "event" + table_type: { + alias: "e" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x1088f5120>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x1088f45e0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x1088f48b0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x1088f4820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x1088f5ab0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + } + } + hidden: True + type: { + alias: "event" + type: + } + } + hidden: False + type: { + alias: "ee" + type: + } + }, + { + chain: [ + "ee" + ] + type: + }, + { + alias: "e" + expr: { + chain: [ + "ee" + ] + type: + } + hidden: False + type: { + alias: "e" + type: + } + }, + { + alias: "timestamp" + expr: { + chain: [ + "e", + "timestamp" + ] + type: { + name: "timestamp" + table_type: + } + } + hidden: True + type: { + alias: "timestamp" + type: + } + } + ] + select_from: { + alias: "e" + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: { + aliases: { + e: , + ee: + } + anonymous_tables: [] + columns: { + e: , + ee: , + timestamp: + } + ctes: {} + tables: { + e: + } + } + where: { + left: { + alias: "event" + expr: { + chain: [ + "e", + "event" + ] + type: { + name: "event" + table_type: + } + } + hidden: True + type: { + alias: "event" + type: + } + } + op: "==" + right: { + type: { + data_type: "str" + } + value: "test" + } + type: { + data_type: "bool" + } + } + } + ' +--- +# name: TestResolver.test_resolve_events_table_column_alias_inside_subquery + ' + { + select: [ + { + alias: "b" + expr: { + chain: [ + "b" + ] + type: { + name: "b" + table_type: { + alias: "e" + select_query_type: { + aliases: { + b: { + alias: "b" + type: { + alias: "event" + type: { + name: "event" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x1088f5120>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x1088f45e0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x1088f48b0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x1088f4820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x1088f5ab0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + } + }, + c: { + alias: "c" + type: { + alias: "timestamp" + type: { + name: "timestamp" + table_type: + } + } + } + } + anonymous_tables: [] + columns: { + b: , + c: + } + ctes: {} + tables: { + events: + } + } + } + } + } + hidden: True + type: { + alias: "b" + type: + } + } + ] + select_from: { + alias: "e" + table: { + select: [ + { + alias: "b" + expr: { + alias: "event" + expr: { + chain: [ + "event" + ] + type: + } + hidden: True + type: + } + hidden: False + type: + }, + { + alias: "c" + expr: { + alias: "timestamp" + expr: { + chain: [ + "timestamp" + ] + type: + } + hidden: True + type: + } + hidden: False + type: + } + ] + select_from: { + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: { + b: + } + ctes: {} + tables: { + e: + } + } + where: { + left: { + alias: "b" + expr: { + chain: [ + "e", + "b" + ] + type: { + name: "b" + table_type: + } + } + hidden: True + type: { + alias: "b" + type: + } + } + op: "==" + right: { + type: { + data_type: "str" + } + value: "test" + } + type: { + data_type: "bool" + } + } + } + ' +--- +# name: TestResolver.test_resolve_lazy_events_pdi_person_table + ' + { + select: [ + { + alias: "event" + expr: { + chain: [ + "event" + ] + type: { + name: "event" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x1088f5120>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x1088f45e0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x1088f48b0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x1088f4820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x1088f5ab0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + } + hidden: True + type: { + alias: "event" + type: + } + }, + { + alias: "id" + expr: { + chain: [ + "pdi", + "person", + "id" + ] + type: { + name: "id" + table_type: { + field: "person" + lazy_join: join_function= join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}) from_field='person_id' + table_type: { + field: "pdi" + lazy_join: join_function= join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}) from_field='distinct_id' + table_type: + } + } + } + } + hidden: True + type: { + alias: "id" + type: + } + } + ] + select_from: { + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: { + event: , + id: + } + ctes: {} + tables: { + events: + } + } + } + ' +--- +# name: TestResolver.test_resolve_lazy_events_pdi_person_table_aliased + ' + { + select: [ + { + alias: "event" + expr: { + chain: [ + "event" + ] + type: { + name: "event" + table_type: { + alias: "e" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x1088f5120>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x1088f45e0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x1088f48b0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x1088f4820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x1088f5ab0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + } + } + hidden: True + type: { + alias: "event" + type: + } + }, + { + alias: "id" + expr: { + chain: [ + "e", + "pdi", + "person", + "id" + ] + type: { + name: "id" + table_type: { + field: "person" + lazy_join: join_function= join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}) from_field='person_id' + table_type: { + field: "pdi" + lazy_join: join_function= join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}) from_field='distinct_id' + table_type: + } + } + } + } + hidden: True + type: { + alias: "id" + type: + } + } + ] + select_from: { + alias: "e" + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: { + event: , + id: + } + ctes: {} + tables: { + e: + } + } + } + ' +--- +# name: TestResolver.test_resolve_lazy_events_pdi_table + ' + { + select: [ + { + alias: "event" + expr: { + chain: [ + "event" + ] + type: { + name: "event" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x1088f5120>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x1088f45e0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x1088f48b0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x1088f4820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x1088f5ab0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + } + hidden: True + type: { + alias: "event" + type: + } + }, + { + alias: "person_id" + expr: { + chain: [ + "pdi", + "person_id" + ] + type: { + name: "person_id" + table_type: { + field: "pdi" + lazy_join: join_function= join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}) from_field='distinct_id' + table_type: + } + } + } + hidden: True + type: { + alias: "person_id" + type: + } + } + ] + select_from: { + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: { + event: , + person_id: + } + ctes: {} + tables: { + events: + } + } + } + ' +--- +# name: TestResolver.test_resolve_lazy_events_pdi_table_aliased + ' + { + select: [ + { + alias: "event" + expr: { + chain: [ + "event" + ] + type: { + name: "event" + table_type: { + alias: "e" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x1088f5120>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x1088f45e0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x1088f48b0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x1088f4820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x1088f5ab0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + } + } + hidden: True + type: { + alias: "event" + type: + } + }, + { + alias: "person_id" + expr: { + chain: [ + "e", + "pdi", + "person_id" + ] + type: { + name: "person_id" + table_type: { + field: "pdi" + lazy_join: join_function= join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}) from_field='distinct_id' + table_type: + } + } + } + hidden: True + type: { + alias: "person_id" + type: + } + } + ] + select_from: { + alias: "e" + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: { + event: , + person_id: + } + ctes: {} + tables: { + e: + } + } + } + ' +--- +# name: TestResolver.test_resolve_lazy_pdi_person_table + ' + { + select: [ + { + alias: "distinct_id" + expr: { + chain: [ + "distinct_id" + ] + type: { + name: "distinct_id" + table_type: { + table: fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')} + } + } + } + hidden: True + type: { + alias: "distinct_id" + type: + } + }, + { + alias: "id" + expr: { + chain: [ + "person", + "id" + ] + type: { + name: "id" + table_type: { + field: "person" + lazy_join: join_function= join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}) from_field='person_id' + table_type: + } + } + } + hidden: True + type: { + alias: "id" + type: + } + } + ] + select_from: { + table: { + chain: [ + "person_distinct_ids" + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: { + distinct_id: , + id: + } + ctes: {} + tables: { + person_distinct_ids: + } + } + } + ' +--- +# name: TestResolver.test_resolve_union_all + ' + { + select_queries: [ + { + select: [ + { + alias: "event" + expr: { + chain: [ + "event" + ] + type: { + name: "event" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x1088f5120>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x1088f45e0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x1088f48b0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x1088f4820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x1088f5ab0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + } + hidden: True + type: { + alias: "event" + type: + } + }, + { + alias: "timestamp" + expr: { + chain: [ + "timestamp" + ] + type: { + name: "timestamp" + table_type: + } + } + hidden: True + type: { + alias: "timestamp" + type: + } + } + ] + select_from: { + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: { + event: , + timestamp: + } + ctes: {} + tables: { + events: + } + } + }, + { + select: [ + { + alias: "event" + expr: { + chain: [ + "event" + ] + type: { + name: "event" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x1088f5120>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x1088f45e0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x1088f48b0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x1088f4820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x1088f5ab0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + } + hidden: True + type: { + alias: "event" + type: + } + }, + { + alias: "timestamp" + expr: { + chain: [ + "timestamp" + ] + type: { + name: "timestamp" + table_type: + } + } + hidden: True + type: { + alias: "timestamp" + type: + } + } + ] + select_from: { + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: { + event: , + timestamp: + } + ctes: {} + tables: { + events: + } + } + } + ] + type: { + types: [ + , + + ] + } + } + ' +--- +# name: TestResolver.test_resolve_virtual_events_poe + ' + { + select: [ + { + alias: "event" + expr: { + chain: [ + "event" + ] + type: { + name: "event" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x1088f5120>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x1088f45e0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x1088f48b0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x1088f4820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x1088f5ab0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + } + hidden: True + type: { + alias: "event" + type: + } + }, + { + alias: "id" + expr: { + chain: [ + "poe", + "id" + ] + type: { + name: "id" + table_type: { + field: "poe" + table_type: + virtual_table: fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)} + } + } + } + hidden: True + type: { + alias: "id" + type: + } + } + ] + select_from: { + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: { + event: , + id: + } + ctes: {} + tables: { + events: + } + } + } + ' +--- From 688580330cdd83acd66b4cf9251ae896ab60975d Mon Sep 17 00:00:00 2001 From: Marius Andra Date: Tue, 21 Nov 2023 22:41:29 +0100 Subject: [PATCH 07/15] feat(hogql): resolver test snapshots --- .../test/__snapshots__/test_resolver.ambr | 2310 +++++++++++++++++ posthog/hogql/test/test_resolver.py | 998 +------ posthog/hogql/test/utils.py | 47 + 3 files changed, 2402 insertions(+), 953 deletions(-) create mode 100644 posthog/hogql/test/__snapshots__/test_resolver.ambr diff --git a/posthog/hogql/test/__snapshots__/test_resolver.ambr b/posthog/hogql/test/__snapshots__/test_resolver.ambr new file mode 100644 index 0000000000000..bde7c1b94e77f --- /dev/null +++ b/posthog/hogql/test/__snapshots__/test_resolver.ambr @@ -0,0 +1,2310 @@ +# name: TestResolver.test_asterisk_expander_from_subquery_table + ' + { + select: [ + { + chain: [ + "uuid" + ] + type: { + name: "uuid" + table_type: { + aliases: {} + anonymous_tables: [] + columns: { + $group_0: { + name: "$group_0" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + }, + $group_1: { + name: "$group_1" + table_type: + }, + $group_2: { + name: "$group_2" + table_type: + }, + $group_3: { + name: "$group_3" + table_type: + }, + $group_4: { + name: "$group_4" + table_type: + }, + $session_id: { + name: "$session_id" + table_type: + }, + created_at: { + name: "created_at" + table_type: + }, + distinct_id: { + name: "distinct_id" + table_type: + }, + elements_chain: { + name: "elements_chain" + table_type: + }, + event: { + name: "event" + table_type: + }, + properties: { + name: "properties" + table_type: + }, + timestamp: { + name: "timestamp" + table_type: + }, + uuid: { + name: "uuid" + table_type: + } + } + ctes: {} + tables: { + events: + } + } + } + }, + { + chain: [ + "event" + ] + type: { + name: "event" + table_type: + } + }, + { + chain: [ + "properties" + ] + type: { + name: "properties" + table_type: + } + }, + { + chain: [ + "timestamp" + ] + type: { + name: "timestamp" + table_type: + } + }, + { + chain: [ + "distinct_id" + ] + type: { + name: "distinct_id" + table_type: + } + }, + { + chain: [ + "elements_chain" + ] + type: { + name: "elements_chain" + table_type: + } + }, + { + chain: [ + "created_at" + ] + type: { + name: "created_at" + table_type: + } + }, + { + chain: [ + "$session_id" + ] + type: { + name: "$session_id" + table_type: + } + }, + { + chain: [ + "$group_0" + ] + type: { + name: "$group_0" + table_type: + } + }, + { + chain: [ + "$group_1" + ] + type: { + name: "$group_1" + table_type: + } + }, + { + chain: [ + "$group_2" + ] + type: { + name: "$group_2" + table_type: + } + }, + { + chain: [ + "$group_3" + ] + type: { + name: "$group_3" + table_type: + } + }, + { + chain: [ + "$group_4" + ] + type: { + name: "$group_4" + table_type: + } + } + ] + select_from: { + table: { + select: [ + { + chain: [ + "uuid" + ] + type: + }, + { + chain: [ + "event" + ] + type: + }, + { + chain: [ + "properties" + ] + type: + }, + { + chain: [ + "timestamp" + ] + type: + }, + { + chain: [ + "distinct_id" + ] + type: + }, + { + chain: [ + "elements_chain" + ] + type: + }, + { + chain: [ + "created_at" + ] + type: + }, + { + chain: [ + "$session_id" + ] + type: + }, + { + chain: [ + "$group_0" + ] + type: + }, + { + chain: [ + "$group_1" + ] + type: + }, + { + chain: [ + "$group_2" + ] + type: + }, + { + chain: [ + "$group_3" + ] + type: + }, + { + chain: [ + "$group_4" + ] + type: + } + ] + select_from: { + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [ + + ] + columns: { + $group_0: , + $group_1: , + $group_2: , + $group_3: , + $group_4: , + $session_id: , + created_at: , + distinct_id: , + elements_chain: , + event: , + properties: , + timestamp: , + uuid: + } + ctes: {} + tables: {} + } + } + ' +--- +# name: TestResolver.test_asterisk_expander_select_union + ' + { + select: [ + { + chain: [ + "uuid" + ] + type: { + name: "uuid" + table_type: { + types: [ + { + aliases: {} + anonymous_tables: [] + columns: { + $group_0: { + name: "$group_0" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + }, + $group_1: { + name: "$group_1" + table_type: + }, + $group_2: { + name: "$group_2" + table_type: + }, + $group_3: { + name: "$group_3" + table_type: + }, + $group_4: { + name: "$group_4" + table_type: + }, + $session_id: { + name: "$session_id" + table_type: + }, + created_at: { + name: "created_at" + table_type: + }, + distinct_id: { + name: "distinct_id" + table_type: + }, + elements_chain: { + name: "elements_chain" + table_type: + }, + event: { + name: "event" + table_type: + }, + properties: { + name: "properties" + table_type: + }, + timestamp: { + name: "timestamp" + table_type: + }, + uuid: { + name: "uuid" + table_type: + } + } + ctes: {} + tables: { + events: + } + }, + { + aliases: {} + anonymous_tables: [] + columns: { + $group_0: { + name: "$group_0" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + }, + $group_1: { + name: "$group_1" + table_type: + }, + $group_2: { + name: "$group_2" + table_type: + }, + $group_3: { + name: "$group_3" + table_type: + }, + $group_4: { + name: "$group_4" + table_type: + }, + $session_id: { + name: "$session_id" + table_type: + }, + created_at: { + name: "created_at" + table_type: + }, + distinct_id: { + name: "distinct_id" + table_type: + }, + elements_chain: { + name: "elements_chain" + table_type: + }, + event: { + name: "event" + table_type: + }, + properties: { + name: "properties" + table_type: + }, + timestamp: { + name: "timestamp" + table_type: + }, + uuid: { + name: "uuid" + table_type: + } + } + ctes: {} + tables: { + events: + } + } + ] + } + } + }, + { + chain: [ + "event" + ] + type: { + name: "event" + table_type: + } + }, + { + chain: [ + "properties" + ] + type: { + name: "properties" + table_type: + } + }, + { + chain: [ + "timestamp" + ] + type: { + name: "timestamp" + table_type: + } + }, + { + chain: [ + "distinct_id" + ] + type: { + name: "distinct_id" + table_type: + } + }, + { + chain: [ + "elements_chain" + ] + type: { + name: "elements_chain" + table_type: + } + }, + { + chain: [ + "created_at" + ] + type: { + name: "created_at" + table_type: + } + }, + { + chain: [ + "$session_id" + ] + type: { + name: "$session_id" + table_type: + } + }, + { + chain: [ + "$group_0" + ] + type: { + name: "$group_0" + table_type: + } + }, + { + chain: [ + "$group_1" + ] + type: { + name: "$group_1" + table_type: + } + }, + { + chain: [ + "$group_2" + ] + type: { + name: "$group_2" + table_type: + } + }, + { + chain: [ + "$group_3" + ] + type: { + name: "$group_3" + table_type: + } + }, + { + chain: [ + "$group_4" + ] + type: { + name: "$group_4" + table_type: + } + } + ] + select_from: { + table: { + select_queries: [ + { + select: [ + { + chain: [ + "uuid" + ] + type: + }, + { + chain: [ + "event" + ] + type: + }, + { + chain: [ + "properties" + ] + type: + }, + { + chain: [ + "timestamp" + ] + type: + }, + { + chain: [ + "distinct_id" + ] + type: + }, + { + chain: [ + "elements_chain" + ] + type: + }, + { + chain: [ + "created_at" + ] + type: + }, + { + chain: [ + "$session_id" + ] + type: + }, + { + chain: [ + "$group_0" + ] + type: + }, + { + chain: [ + "$group_1" + ] + type: + }, + { + chain: [ + "$group_2" + ] + type: + }, + { + chain: [ + "$group_3" + ] + type: + }, + { + chain: [ + "$group_4" + ] + type: + } + ] + select_from: { + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: + }, + { + select: [ + { + chain: [ + "uuid" + ] + type: + }, + { + chain: [ + "event" + ] + type: + }, + { + chain: [ + "properties" + ] + type: + }, + { + chain: [ + "timestamp" + ] + type: + }, + { + chain: [ + "distinct_id" + ] + type: + }, + { + chain: [ + "elements_chain" + ] + type: + }, + { + chain: [ + "created_at" + ] + type: + }, + { + chain: [ + "$session_id" + ] + type: + }, + { + chain: [ + "$group_0" + ] + type: + }, + { + chain: [ + "$group_1" + ] + type: + }, + { + chain: [ + "$group_2" + ] + type: + }, + { + chain: [ + "$group_3" + ] + type: + }, + { + chain: [ + "$group_4" + ] + type: + } + ] + select_from: { + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: + } + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [ + + ] + columns: { + $group_0: , + $group_1: , + $group_2: , + $group_3: , + $group_4: , + $session_id: , + created_at: , + distinct_id: , + elements_chain: , + event: , + properties: , + timestamp: , + uuid: + } + ctes: {} + tables: {} + } + } + ' +--- +# name: TestResolver.test_asterisk_expander_subquery + ' + { + select: [ + { + chain: [ + "a" + ] + type: { + name: "a" + table_type: { + aliases: { + a: { + alias: "a" + type: { + data_type: "int" + } + }, + b: { + alias: "b" + type: { + data_type: "int" + } + } + } + anonymous_tables: [] + columns: { + a: , + b: + } + ctes: {} + tables: {} + } + } + }, + { + chain: [ + "b" + ] + type: { + name: "b" + table_type: + } + } + ] + select_from: { + table: { + select: [ + { + alias: "a" + expr: { + type: + value: 1 + } + type: + }, + { + alias: "b" + expr: { + type: + value: 2 + } + type: + } + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [ + + ] + columns: { + a: , + b: + } + ctes: {} + tables: {} + } + } + ' +--- +# name: TestResolver.test_asterisk_expander_subquery_alias + ' + { + select: [ + { + chain: [ + "a" + ] + type: { + name: "a" + table_type: { + alias: "x" + select_query_type: { + aliases: { + a: { + alias: "a" + type: { + data_type: "int" + } + }, + b: { + alias: "b" + type: { + data_type: "int" + } + } + } + anonymous_tables: [] + columns: { + a: , + b: + } + ctes: {} + tables: {} + } + } + } + }, + { + chain: [ + "b" + ] + type: { + name: "b" + table_type: + } + } + ] + select_from: { + alias: "x" + table: { + select: [ + { + alias: "a" + expr: { + type: + value: 1 + } + type: + }, + { + alias: "b" + expr: { + type: + value: 2 + } + type: + } + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: { + a: , + b: + } + ctes: {} + tables: { + x: + } + } + } + ' +--- +# name: TestResolver.test_asterisk_expander_table + ' + { + select: [ + { + chain: [ + "uuid" + ] + type: { + name: "uuid" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + }, + { + chain: [ + "event" + ] + type: { + name: "event" + table_type: + } + }, + { + chain: [ + "properties" + ] + type: { + name: "properties" + table_type: + } + }, + { + chain: [ + "timestamp" + ] + type: { + name: "timestamp" + table_type: + } + }, + { + chain: [ + "distinct_id" + ] + type: { + name: "distinct_id" + table_type: + } + }, + { + chain: [ + "elements_chain" + ] + type: { + name: "elements_chain" + table_type: + } + }, + { + chain: [ + "created_at" + ] + type: { + name: "created_at" + table_type: + } + }, + { + chain: [ + "$session_id" + ] + type: { + name: "$session_id" + table_type: + } + }, + { + chain: [ + "$group_0" + ] + type: { + name: "$group_0" + table_type: + } + }, + { + chain: [ + "$group_1" + ] + type: { + name: "$group_1" + table_type: + } + }, + { + chain: [ + "$group_2" + ] + type: { + name: "$group_2" + table_type: + } + }, + { + chain: [ + "$group_3" + ] + type: { + name: "$group_3" + table_type: + } + }, + { + chain: [ + "$group_4" + ] + type: { + name: "$group_4" + table_type: + } + } + ] + select_from: { + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: { + $group_0: , + $group_1: , + $group_2: , + $group_3: , + $group_4: , + $session_id: , + created_at: , + distinct_id: , + elements_chain: , + event: , + properties: , + timestamp: , + uuid: + } + ctes: {} + tables: { + events: + } + } + } + ' +--- +# name: TestResolver.test_asterisk_expander_table_alias + ' + { + select: [ + { + chain: [ + "uuid" + ] + type: { + name: "uuid" + table_type: { + alias: "e" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + } + }, + { + chain: [ + "event" + ] + type: { + name: "event" + table_type: + } + }, + { + chain: [ + "properties" + ] + type: { + name: "properties" + table_type: + } + }, + { + chain: [ + "timestamp" + ] + type: { + name: "timestamp" + table_type: + } + }, + { + chain: [ + "distinct_id" + ] + type: { + name: "distinct_id" + table_type: + } + }, + { + chain: [ + "elements_chain" + ] + type: { + name: "elements_chain" + table_type: + } + }, + { + chain: [ + "created_at" + ] + type: { + name: "created_at" + table_type: + } + }, + { + chain: [ + "$session_id" + ] + type: { + name: "$session_id" + table_type: + } + }, + { + chain: [ + "$group_0" + ] + type: { + name: "$group_0" + table_type: + } + }, + { + chain: [ + "$group_1" + ] + type: { + name: "$group_1" + table_type: + } + }, + { + chain: [ + "$group_2" + ] + type: { + name: "$group_2" + table_type: + } + }, + { + chain: [ + "$group_3" + ] + type: { + name: "$group_3" + table_type: + } + }, + { + chain: [ + "$group_4" + ] + type: { + name: "$group_4" + table_type: + } + } + ] + select_from: { + alias: "e" + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: { + $group_0: , + $group_1: , + $group_2: , + $group_3: , + $group_4: , + $session_id: , + created_at: , + distinct_id: , + elements_chain: , + event: , + properties: , + timestamp: , + uuid: + } + ctes: {} + tables: { + e: + } + } + } + ' +--- +# name: TestResolver.test_call_type + ' + { + select: [ + { + args: [ + { + chain: [ + "timestamp" + ] + type: { + name: "timestamp" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + } + ] + distinct: False + name: "max" + type: { + arg_types: [ + { + data_type: "datetime" + } + ] + name: "max" + return_type: { + data_type: "unknown" + } + } + } + ] + select_from: { + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: {} + ctes: {} + tables: { + events: + } + } + } + ' +--- +# name: TestResolver.test_resolve_boolean_operation_types + ' + { + select: [ + { + exprs: [ + { + type: { + data_type: "int" + } + value: 1 + }, + { + type: { + data_type: "int" + } + value: 1 + } + ] + type: { + data_type: "bool" + } + }, + { + exprs: [ + { + type: { + data_type: "int" + } + value: 1 + }, + { + type: { + data_type: "int" + } + value: 1 + } + ] + type: { + data_type: "bool" + } + }, + { + expr: { + type: { + data_type: "bool" + } + value: True + } + type: { + data_type: "bool" + } + } + ] + type: { + aliases: {} + anonymous_tables: [] + columns: {} + ctes: {} + tables: {} + } + } + ' +--- +# name: TestResolver.test_resolve_constant_type + ' + { + select: [ + { + type: { + data_type: "int" + } + value: 1 + }, + { + type: { + data_type: "str" + } + value: "boo" + }, + { + type: { + data_type: "bool" + } + value: True + }, + { + type: { + data_type: "float" + } + value: 1.1232 + }, + { + type: { + data_type: "unknown" + } + }, + { + type: { + data_type: "date" + } + value: 2020-01-10 + }, + { + type: { + data_type: "datetime" + } + value: 2020-01-10 00:00:00+00:00 + }, + { + type: { + data_type: "uuid" + } + value: 00000000-0000-4000-8000-000000000000 + }, + { + type: { + data_type: "array" + item_type: { + data_type: "unknown" + } + } + value: [] + }, + { + type: { + data_type: "array" + item_type: { + data_type: "int" + } + } + value: [ + 1, + 2 + ] + }, + { + type: { + data_type: "tuple" + item_types: [ + { + data_type: "int" + }, + { + data_type: "int" + }, + { + data_type: "int" + } + ] + } + value: (1, 2, 3) + } + ] + type: { + aliases: {} + anonymous_tables: [] + columns: {} + ctes: {} + tables: {} + } + } + ' +--- +# name: TestResolver.test_resolve_events_table + ' + { + select: [ + { + chain: [ + "event" + ] + type: { + name: "event" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + }, + { + chain: [ + "events", + "timestamp" + ] + type: { + name: "timestamp" + table_type: + } + } + ] + select_from: { + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: { + event: , + timestamp: + } + ctes: {} + tables: { + events: + } + } + where: { + left: { + chain: [ + "events", + "event" + ] + type: { + name: "event" + table_type: + } + } + op: "==" + right: { + type: { + data_type: "str" + } + value: "test" + } + type: { + data_type: "bool" + } + } + } + ' +--- +# name: TestResolver.test_resolve_events_table_alias + ' + { + select: [ + { + chain: [ + "event" + ] + type: { + name: "event" + table_type: { + alias: "e" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + } + }, + { + chain: [ + "e", + "timestamp" + ] + type: { + name: "timestamp" + table_type: + } + } + ] + select_from: { + alias: "e" + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: { + event: , + timestamp: + } + ctes: {} + tables: { + e: + } + } + where: { + left: { + chain: [ + "e", + "event" + ] + type: { + name: "event" + table_type: + } + } + op: "==" + right: { + type: { + data_type: "str" + } + value: "test" + } + type: { + data_type: "bool" + } + } + } + ' +--- +# name: TestResolver.test_resolve_events_table_column_alias + ' + { + select: [ + { + alias: "ee" + expr: { + chain: [ + "event" + ] + type: { + name: "event" + table_type: { + alias: "e" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + } + } + type: { + alias: "ee" + type: + } + }, + { + chain: [ + "ee" + ] + type: + }, + { + alias: "e" + expr: { + chain: [ + "ee" + ] + type: + } + type: { + alias: "e" + type: + } + }, + { + chain: [ + "e", + "timestamp" + ] + type: { + name: "timestamp" + table_type: + } + } + ] + select_from: { + alias: "e" + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: { + aliases: { + e: , + ee: + } + anonymous_tables: [] + columns: { + e: , + ee: , + timestamp: + } + ctes: {} + tables: { + e: + } + } + where: { + left: { + chain: [ + "e", + "event" + ] + type: { + name: "event" + table_type: + } + } + op: "==" + right: { + type: { + data_type: "str" + } + value: "test" + } + type: { + data_type: "bool" + } + } + } + ' +--- +# name: TestResolver.test_resolve_events_table_column_alias_inside_subquery + ' + { + select: [ + { + chain: [ + "b" + ] + type: { + name: "b" + table_type: { + alias: "e" + select_query_type: { + aliases: { + b: { + alias: "b" + type: { + name: "event" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + }, + c: { + alias: "c" + type: { + name: "timestamp" + table_type: + } + } + } + anonymous_tables: [] + columns: { + b: , + c: + } + ctes: {} + tables: { + events: + } + } + } + } + } + ] + select_from: { + alias: "e" + table: { + select: [ + { + alias: "b" + expr: { + chain: [ + "event" + ] + type: + } + type: + }, + { + alias: "c" + expr: { + chain: [ + "timestamp" + ] + type: + } + type: + } + ] + select_from: { + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: { + b: + } + ctes: {} + tables: { + e: + } + } + where: { + left: { + chain: [ + "e", + "b" + ] + type: { + name: "b" + table_type: + } + } + op: "==" + right: { + type: { + data_type: "str" + } + value: "test" + } + type: { + data_type: "bool" + } + } + } + ' +--- +# name: TestResolver.test_resolve_lazy_events_pdi_person_table + ' + { + select: [ + { + chain: [ + "event" + ] + type: { + name: "event" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + }, + { + chain: [ + "pdi", + "person", + "id" + ] + type: { + name: "id" + table_type: { + field: "person" + lazy_join: join_function= join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}) from_field='person_id' + table_type: { + field: "pdi" + lazy_join: join_function= join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}) from_field='distinct_id' + table_type: + } + } + } + } + ] + select_from: { + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: { + event: , + id: + } + ctes: {} + tables: { + events: + } + } + } + ' +--- +# name: TestResolver.test_resolve_lazy_events_pdi_person_table_aliased + ' + { + select: [ + { + chain: [ + "event" + ] + type: { + name: "event" + table_type: { + alias: "e" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + } + }, + { + chain: [ + "e", + "pdi", + "person", + "id" + ] + type: { + name: "id" + table_type: { + field: "person" + lazy_join: join_function= join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}) from_field='person_id' + table_type: { + field: "pdi" + lazy_join: join_function= join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}) from_field='distinct_id' + table_type: + } + } + } + } + ] + select_from: { + alias: "e" + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: { + event: , + id: + } + ctes: {} + tables: { + e: + } + } + } + ' +--- +# name: TestResolver.test_resolve_lazy_events_pdi_table + ' + { + select: [ + { + chain: [ + "event" + ] + type: { + name: "event" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + }, + { + chain: [ + "pdi", + "person_id" + ] + type: { + name: "person_id" + table_type: { + field: "pdi" + lazy_join: join_function= join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}) from_field='distinct_id' + table_type: + } + } + } + ] + select_from: { + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: { + event: , + person_id: + } + ctes: {} + tables: { + events: + } + } + } + ' +--- +# name: TestResolver.test_resolve_lazy_events_pdi_table_aliased + ' + { + select: [ + { + chain: [ + "event" + ] + type: { + name: "event" + table_type: { + alias: "e" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + } + }, + { + chain: [ + "e", + "pdi", + "person_id" + ] + type: { + name: "person_id" + table_type: { + field: "pdi" + lazy_join: join_function= join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}) from_field='distinct_id' + table_type: + } + } + } + ] + select_from: { + alias: "e" + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: { + event: , + person_id: + } + ctes: {} + tables: { + e: + } + } + } + ' +--- +# name: TestResolver.test_resolve_lazy_pdi_person_table + ' + { + select: [ + { + chain: [ + "distinct_id" + ] + type: { + name: "distinct_id" + table_type: { + table: fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')} + } + } + }, + { + chain: [ + "person", + "id" + ] + type: { + name: "id" + table_type: { + field: "person" + lazy_join: join_function= join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}) from_field='person_id' + table_type: + } + } + } + ] + select_from: { + table: { + chain: [ + "person_distinct_ids" + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: { + distinct_id: , + id: + } + ctes: {} + tables: { + person_distinct_ids: + } + } + } + ' +--- +# name: TestResolver.test_resolve_union_all + ' + { + select_queries: [ + { + select: [ + { + chain: [ + "event" + ] + type: { + name: "event" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + }, + { + chain: [ + "timestamp" + ] + type: { + name: "timestamp" + table_type: + } + } + ] + select_from: { + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: { + event: , + timestamp: + } + ctes: {} + tables: { + events: + } + } + }, + { + select: [ + { + chain: [ + "event" + ] + type: { + name: "event" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + }, + { + chain: [ + "timestamp" + ] + type: { + name: "timestamp" + table_type: + } + } + ] + select_from: { + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: { + event: , + timestamp: + } + ctes: {} + tables: { + events: + } + } + } + ] + type: { + types: [ + , + + ] + } + } + ' +--- +# name: TestResolver.test_resolve_virtual_events_poe + ' + { + select: [ + { + chain: [ + "event" + ] + type: { + name: "event" + table_type: { + table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + } + } + }, + { + chain: [ + "poe", + "id" + ] + type: { + name: "id" + table_type: { + field: "poe" + table_type: + virtual_table: fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)} + } + } + } + ] + select_from: { + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: { + event: , + id: + } + ctes: {} + tables: { + events: + } + } + } + ' +--- diff --git a/posthog/hogql/test/test_resolver.py b/posthog/hogql/test/test_resolver.py index f2ee1d812ea65..069e633e0a457 100644 --- a/posthog/hogql/test/test_resolver.py +++ b/posthog/hogql/test/test_resolver.py @@ -1,6 +1,6 @@ from datetime import timezone, datetime, date from typing import Optional, Dict, cast - +import pytest from django.test import override_settings from uuid import UUID @@ -10,12 +10,12 @@ from posthog.hogql.context import HogQLContext from posthog.hogql.database.database import create_hogql_database from posthog.hogql.database.models import ( - LazyJoin, FieldTraverser, StringJSONDatabaseField, StringDatabaseField, DateTimeDatabaseField, ) +from posthog.hogql.test.utils import pretty_dataclasses from posthog.hogql.visitor import clone_expr from posthog.hogql.parser import parse_select from posthog.hogql.printer import print_ast, print_prepared_ast @@ -44,42 +44,11 @@ def setUp(self): self.database = create_hogql_database(self.team.pk) self.context = HogQLContext(database=self.database, team_id=self.team.pk) + @pytest.mark.usefixtures("unittest_snapshot") def test_resolve_events_table(self): expr = self._select("SELECT event, events.timestamp FROM events WHERE events.event = 'test'") expr = resolve_types(expr, self.context) - - events_table_type = ast.TableType(table=self.database.events) - event_field_type = ast.FieldType(name="event", table_type=events_table_type) - timestamp_field_type = ast.FieldType(name="timestamp", table_type=events_table_type) - select_query_type = ast.SelectQueryType( - columns={"event": event_field_type, "timestamp": timestamp_field_type}, - tables={"events": events_table_type}, - ) - - expected = ast.SelectQuery( - select=[ - ast.Field(chain=["event"], type=event_field_type), - ast.Field(chain=["events", "timestamp"], type=timestamp_field_type), - ], - select_from=ast.JoinExpr( - table=ast.Field(chain=["events"], type=events_table_type), - type=events_table_type, - ), - where=ast.CompareOperation( - left=ast.Field(chain=["events", "event"], type=event_field_type), - op=ast.CompareOperationOp.Eq, - right=ast.Constant(value="test", type=ast.StringType()), - type=ast.BooleanType(), - ), - type=select_query_type, - ) - - # asserting individually to help debug if something is off - self.assertEqual(expr.select, expected.select) - self.assertEqual(expr.select_from, expected.select_from) - self.assertEqual(expr.where, expected.where) - self.assertEqual(expr.type, expected.type) - self.assertEqual(expr, expected) + assert pretty_dataclasses(expr) == self.snapshot def test_will_not_run_twice(self): expr = self._select("SELECT event, events.timestamp FROM events WHERE events.event = 'test'") @@ -91,186 +60,23 @@ def test_will_not_run_twice(self): "Type already resolved for SelectQuery (SelectQueryType). Can't run again.", ) + @pytest.mark.usefixtures("unittest_snapshot") def test_resolve_events_table_alias(self): expr = self._select("SELECT event, e.timestamp FROM events e WHERE e.event = 'test'") expr = resolve_types(expr, self.context) + assert pretty_dataclasses(expr) == self.snapshot - events_table_type = ast.TableType(table=self.database.events) - events_table_alias_type = ast.TableAliasType(alias="e", table_type=events_table_type) - event_field_type = ast.FieldType(name="event", table_type=events_table_alias_type) - timestamp_field_type = ast.FieldType(name="timestamp", table_type=events_table_alias_type) - select_query_type = ast.SelectQueryType( - columns={"event": event_field_type, "timestamp": timestamp_field_type}, - tables={"e": events_table_alias_type}, - ) - - expected = ast.SelectQuery( - select=[ - ast.Field(chain=["event"], type=event_field_type), - ast.Field(chain=["e", "timestamp"], type=timestamp_field_type), - ], - select_from=ast.JoinExpr( - table=ast.Field(chain=["events"], type=events_table_type), - alias="e", - type=events_table_alias_type, - ), - where=ast.CompareOperation( - left=ast.Field(chain=["e", "event"], type=event_field_type), - op=ast.CompareOperationOp.Eq, - right=ast.Constant(value="test", type=ast.StringType()), - type=ast.BooleanType(), - ), - type=select_query_type, - ) - - # asserting individually to help debug if something is off - self.assertEqual(expr.select, expected.select) - self.assertEqual(expr.select_from, expected.select_from) - self.assertEqual(expr.where, expected.where) - self.assertEqual(expr.type, expected.type) - self.assertEqual(expr, expected) - + @pytest.mark.usefixtures("unittest_snapshot") def test_resolve_events_table_column_alias(self): expr = self._select("SELECT event as ee, ee, ee as e, e.timestamp FROM events e WHERE e.event = 'test'") expr = resolve_types(expr, self.context) + assert pretty_dataclasses(expr) == self.snapshot - events_table_type = ast.TableType(table=self.database.events) - events_table_alias_type = ast.TableAliasType(alias="e", table_type=events_table_type) - event_field_type = ast.FieldType(name="event", table_type=events_table_alias_type) - timestamp_field_type = ast.FieldType(name="timestamp", table_type=events_table_alias_type) - - select_query_type = ast.SelectQueryType( - aliases={ - "ee": ast.FieldAliasType(alias="ee", type=event_field_type), - "e": ast.FieldAliasType( - alias="e", - type=ast.FieldAliasType(alias="ee", type=event_field_type), - ), - }, - columns={ - "ee": ast.FieldAliasType(alias="ee", type=event_field_type), - "e": ast.FieldAliasType( - alias="e", - type=ast.FieldAliasType(alias="ee", type=event_field_type), - ), - "timestamp": timestamp_field_type, - }, - tables={"e": events_table_alias_type}, - ) - - expected = ast.SelectQuery( - select=[ - ast.Alias( - alias="ee", - expr=ast.Field(chain=["event"], type=event_field_type), - type=select_query_type.aliases["ee"], - ), - ast.Field(chain=["ee"], type=select_query_type.aliases["ee"]), - ast.Alias( - alias="e", - expr=ast.Field(chain=["ee"], type=select_query_type.aliases["ee"]), - type=select_query_type.aliases["e"], # is ee ? - ), - ast.Field(chain=["e", "timestamp"], type=timestamp_field_type), - ], - select_from=ast.JoinExpr( - table=ast.Field(chain=["events"], type=events_table_type), - alias="e", - type=select_query_type.tables["e"], - ), - where=ast.CompareOperation( - left=ast.Field(chain=["e", "event"], type=event_field_type), - op=ast.CompareOperationOp.Eq, - right=ast.Constant(value="test", type=ast.StringType()), - type=ast.BooleanType(), - ), - type=select_query_type, - ) - # asserting individually to help debug if something is off - self.assertEqual(expr.select, expected.select) - self.assertEqual(expr.select_from, expected.select_from) - self.assertEqual(expr.where, expected.where) - self.assertEqual(expr.type, expected.type) - self.assertEqual(expr, expected) - + @pytest.mark.usefixtures("unittest_snapshot") def test_resolve_events_table_column_alias_inside_subquery(self): expr = self._select("SELECT b FROM (select event as b, timestamp as c from events) e WHERE e.b = 'test'") expr = resolve_types(expr, self.context) - inner_events_table_type = ast.TableType(table=self.database.events) - inner_event_field_type = ast.FieldAliasType( - alias="b", - type=ast.FieldType(name="event", table_type=inner_events_table_type), - ) - timestamp_field_type = ast.FieldType(name="timestamp", table_type=inner_events_table_type) - timstamp_alias_type = ast.FieldAliasType(alias="c", type=timestamp_field_type) - inner_select_type = ast.SelectQueryType( - aliases={ - "b": inner_event_field_type, - "c": ast.FieldAliasType(alias="c", type=timestamp_field_type), - }, - columns={ - "b": inner_event_field_type, - "c": ast.FieldAliasType(alias="c", type=timestamp_field_type), - }, - tables={ - "events": inner_events_table_type, - }, - ) - select_alias_type = ast.SelectQueryAliasType(alias="e", select_query_type=inner_select_type) - expected = ast.SelectQuery( - select=[ - ast.Field( - chain=["b"], - type=ast.FieldType( - name="b", - table_type=ast.SelectQueryAliasType(alias="e", select_query_type=inner_select_type), - ), - ), - ], - select_from=ast.JoinExpr( - table=ast.SelectQuery( - select=[ - ast.Alias( - alias="b", - expr=ast.Field(chain=["event"], type=inner_event_field_type.type), - type=inner_event_field_type, - ), - ast.Alias( - alias="c", - expr=ast.Field(chain=["timestamp"], type=timestamp_field_type), - type=timstamp_alias_type, - ), - ], - select_from=ast.JoinExpr( - table=ast.Field(chain=["events"], type=inner_events_table_type), - type=inner_events_table_type, - ), - type=inner_select_type, - ), - alias="e", - type=select_alias_type, - ), - where=ast.CompareOperation( - left=ast.Field( - chain=["e", "b"], - type=ast.FieldType(name="b", table_type=select_alias_type), - ), - op=ast.CompareOperationOp.Eq, - right=ast.Constant(value="test", type=ast.StringType()), - type=ast.BooleanType(), - ), - type=ast.SelectQueryType( - aliases={}, - columns={"b": ast.FieldType(name="b", table_type=select_alias_type)}, - tables={"e": select_alias_type}, - ), - ) - # asserting individually to help debug if something is off - self.assertEqual(expr.select, expected.select) - self.assertEqual(expr.select_from, expected.select_from) - self.assertEqual(expr.where, expected.where) - self.assertEqual(expr.type, expected.type) - self.assertEqual(expr, expected) + assert pretty_dataclasses(expr) == self.snapshot def test_resolve_subquery_no_field_access(self): # From ClickHouse's GitHub: "Aliases defined outside of subquery are not visible in subqueries (but see below)." @@ -281,6 +87,7 @@ def test_resolve_subquery_no_field_access(self): expr = resolve_types(expr, self.context) self.assertEqual(str(e.exception), "Unable to resolve field: e") + @pytest.mark.usefixtures("unittest_snapshot") def test_resolve_constant_type(self): with freeze_time("2020-01-10 00:00:00"): expr = self._select( @@ -295,66 +102,13 @@ def test_resolve_constant_type(self): }, ) expr = resolve_types(expr, self.context) - expected = ast.SelectQuery( - select=[ - ast.Constant(value=1, type=ast.IntegerType()), - ast.Constant(value="boo", type=ast.StringType()), - ast.Constant(value=True, type=ast.BooleanType()), - ast.Constant(value=1.1232, type=ast.FloatType()), - ast.Constant(value=None, type=ast.UnknownType()), - ast.Constant(value=date(2020, 1, 10), type=ast.DateType()), - ast.Constant( - value=datetime(2020, 1, 10, 0, 0, 0, tzinfo=timezone.utc), - type=ast.DateTimeType(), - ), - ast.Constant( - value=UUID("00000000-0000-4000-8000-000000000000"), - type=ast.UUIDType(), - ), - ast.Constant(value=[], type=ast.ArrayType(item_type=ast.UnknownType())), - ast.Constant(value=[1, 2], type=ast.ArrayType(item_type=ast.IntegerType())), - ast.Constant( - value=(1, 2, 3), - type=ast.TupleType( - item_types=[ - ast.IntegerType(), - ast.IntegerType(), - ast.IntegerType(), - ] - ), - ), - ], - type=ast.SelectQueryType(aliases={}, columns={}, tables={}), - ) - self.assertEqual(expr, expected) + assert pretty_dataclasses(expr) == self.snapshot + @pytest.mark.usefixtures("unittest_snapshot") def test_resolve_boolean_operation_types(self): expr = self._select("SELECT 1 and 1, 1 or 1, not true") expr = resolve_types(expr, self.context) - expected = ast.SelectQuery( - select=[ - ast.And( - exprs=[ - ast.Constant(value=1, type=ast.IntegerType()), - ast.Constant(value=1, type=ast.IntegerType()), - ], - type=ast.BooleanType(), - ), - ast.Or( - exprs=[ - ast.Constant(value=1, type=ast.IntegerType()), - ast.Constant(value=1, type=ast.IntegerType()), - ], - type=ast.BooleanType(), - ), - ast.Not( - expr=ast.Constant(value=True, type=ast.BooleanType()), - type=ast.BooleanType(), - ), - ], - type=ast.SelectQueryType(aliases={}, columns={}, tables={}), - ) - self.assertEqual(expr, expected) + assert pretty_dataclasses(expr) == self.snapshot def test_resolve_errors(self): queries = [ @@ -369,388 +123,53 @@ def test_resolve_errors(self): resolve_types(self._select(query), self.context) self.assertIn("Unable to resolve field:", str(e.exception)) + @pytest.mark.usefixtures("unittest_snapshot") def test_resolve_lazy_pdi_person_table(self): expr = self._select("select distinct_id, person.id from person_distinct_ids") expr = resolve_types(expr, self.context) - pdi_table_type = ast.LazyTableType(table=self.database.person_distinct_ids) - expected = ast.SelectQuery( - select=[ - ast.Field( - chain=["distinct_id"], - type=ast.FieldType(name="distinct_id", table_type=pdi_table_type), - ), - ast.Field( - chain=["person", "id"], - type=ast.FieldType( - name="id", - table_type=ast.LazyJoinType( - table_type=pdi_table_type, - field="person", - lazy_join=self.database.person_distinct_ids.fields.get("person"), - ), - ), - ), - ], - select_from=ast.JoinExpr( - table=ast.Field(chain=["person_distinct_ids"], type=pdi_table_type), - type=pdi_table_type, - ), - type=ast.SelectQueryType( - aliases={}, - anonymous_tables=[], - columns={ - "distinct_id": ast.FieldType(name="distinct_id", table_type=pdi_table_type), - "id": ast.FieldType( - name="id", - table_type=ast.LazyJoinType( - table_type=pdi_table_type, - lazy_join=self.database.person_distinct_ids.fields.get("person"), - field="person", - ), - ), - }, - tables={"person_distinct_ids": pdi_table_type}, - ), - ) - self.assertEqual(expr.select, expected.select) - self.assertEqual(expr.select_from, expected.select_from) - self.assertEqual(expr.where, expected.where) - self.assertEqual(expr.type, expected.type) - self.assertEqual(expr, expected) + assert pretty_dataclasses(expr) == self.snapshot + @pytest.mark.usefixtures("unittest_snapshot") def test_resolve_lazy_events_pdi_table(self): expr = self._select("select event, pdi.person_id from events") expr = resolve_types(expr, self.context) - events_table_type = ast.TableType(table=self.database.events) - expected = ast.SelectQuery( - select=[ - ast.Field( - chain=["event"], - type=ast.FieldType(name="event", table_type=events_table_type), - ), - ast.Field( - chain=["pdi", "person_id"], - type=ast.FieldType( - name="person_id", - table_type=ast.LazyJoinType( - table_type=events_table_type, - field="pdi", - lazy_join=cast(LazyJoin, self.database.events.fields.get("pdi")), - ), - ), - ), - ], - select_from=ast.JoinExpr( - table=ast.Field(chain=["events"], type=events_table_type), - type=events_table_type, - ), - type=ast.SelectQueryType( - aliases={}, - anonymous_tables=[], - columns={ - "event": ast.FieldType(name="event", table_type=events_table_type), - "person_id": ast.FieldType( - name="person_id", - table_type=ast.LazyJoinType( - table_type=events_table_type, - lazy_join=cast(LazyJoin, self.database.events.fields.get("pdi")), - field="pdi", - ), - ), - }, - tables={"events": events_table_type}, - ), - ) - self.assertEqual(expr.select, expected.select) - self.assertEqual(expr.select_from, expected.select_from) - self.assertEqual(expr.where, expected.where) - self.assertEqual(expr.type, expected.type) - self.assertEqual(expr, expected) + assert pretty_dataclasses(expr) == self.snapshot + @pytest.mark.usefixtures("unittest_snapshot") def test_resolve_lazy_events_pdi_table_aliased(self): expr = self._select("select event, e.pdi.person_id from events e") expr = resolve_types(expr, self.context) - events_table_type = ast.TableType(table=self.database.events) - events_table_alias_type = ast.TableAliasType(table_type=events_table_type, alias="e") - expected = ast.SelectQuery( - select=[ - ast.Field( - chain=["event"], - type=ast.FieldType(name="event", table_type=events_table_alias_type), - ), - ast.Field( - chain=["e", "pdi", "person_id"], - type=ast.FieldType( - name="person_id", - table_type=ast.LazyJoinType( - table_type=events_table_alias_type, - field="pdi", - lazy_join=cast(LazyJoin, self.database.events.fields.get("pdi")), - ), - ), - ), - ], - select_from=ast.JoinExpr( - table=ast.Field(chain=["events"], type=events_table_type), - alias="e", - type=events_table_alias_type, - ), - type=ast.SelectQueryType( - aliases={}, - anonymous_tables=[], - columns={ - "event": ast.FieldType(name="event", table_type=events_table_alias_type), - "person_id": ast.FieldType( - name="person_id", - table_type=ast.LazyJoinType( - table_type=events_table_alias_type, - lazy_join=cast(LazyJoin, self.database.events.fields.get("pdi")), - field="pdi", - ), - ), - }, - tables={"e": events_table_alias_type}, - ), - ) - self.assertEqual(expr.select, expected.select) - self.assertEqual(expr.select_from, expected.select_from) - self.assertEqual(expr.where, expected.where) - self.assertEqual(expr.type, expected.type) - self.assertEqual(expr, expected) + assert pretty_dataclasses(expr) == self.snapshot + @pytest.mark.usefixtures("unittest_snapshot") def test_resolve_lazy_events_pdi_person_table(self): expr = self._select("select event, pdi.person.id from events") expr = resolve_types(expr, self.context) - events_table_type = ast.TableType(table=self.database.events) - expected = ast.SelectQuery( - select=[ - ast.Field( - chain=["event"], - type=ast.FieldType(name="event", table_type=events_table_type), - ), - ast.Field( - chain=["pdi", "person", "id"], - type=ast.FieldType( - name="id", - table_type=ast.LazyJoinType( - table_type=ast.LazyJoinType( - table_type=events_table_type, - field="pdi", - lazy_join=cast(LazyJoin, self.database.events.fields.get("pdi")), - ), - field="person", - lazy_join=cast( - LazyJoin, - cast(LazyJoin, self.database.events.fields.get("pdi")).join_table.fields.get("person"), - ), - ), - ), - ), - ], - select_from=ast.JoinExpr( - table=ast.Field(chain=["events"], type=events_table_type), - type=events_table_type, - ), - type=ast.SelectQueryType( - aliases={}, - anonymous_tables=[], - columns={ - "event": ast.FieldType(name="event", table_type=events_table_type), - "id": ast.FieldType( - name="id", - table_type=ast.LazyJoinType( - table_type=ast.LazyJoinType( - table_type=events_table_type, - field="pdi", - lazy_join=cast(LazyJoin, self.database.events.fields.get("pdi")), - ), - field="person", - lazy_join=cast( - LazyJoin, - cast(LazyJoin, self.database.events.fields.get("pdi")).join_table.fields.get("person"), - ), - ), - ), - }, - tables={"events": events_table_type}, - ), - ) - self.assertEqual(expr.select, expected.select) - self.assertEqual(expr.select_from, expected.select_from) - self.assertEqual(expr.where, expected.where) - self.assertEqual(expr.type, expected.type) - self.assertEqual(expr, expected) + assert pretty_dataclasses(expr) == self.snapshot + @pytest.mark.usefixtures("unittest_snapshot") def test_resolve_lazy_events_pdi_person_table_aliased(self): expr = self._select("select event, e.pdi.person.id from events e") expr = resolve_types(expr, self.context) - events_table_type = ast.TableType(table=self.database.events) - events_table_alias_type = ast.TableAliasType(table_type=events_table_type, alias="e") - expected = ast.SelectQuery( - select=[ - ast.Field( - chain=["event"], - type=ast.FieldType(name="event", table_type=events_table_alias_type), - ), - ast.Field( - chain=["e", "pdi", "person", "id"], - type=ast.FieldType( - name="id", - table_type=ast.LazyJoinType( - table_type=ast.LazyJoinType( - table_type=events_table_alias_type, - field="pdi", - lazy_join=cast(LazyJoin, self.database.events.fields.get("pdi")), - ), - field="person", - lazy_join=cast( - LazyJoin, - cast(LazyJoin, self.database.events.fields.get("pdi")).join_table.fields.get("person"), - ), - ), - ), - ), - ], - select_from=ast.JoinExpr( - table=ast.Field(chain=["events"], type=events_table_type), - alias="e", - type=events_table_alias_type, - ), - type=ast.SelectQueryType( - aliases={}, - anonymous_tables=[], - columns={ - "event": ast.FieldType(name="event", table_type=events_table_alias_type), - "id": ast.FieldType( - name="id", - table_type=ast.LazyJoinType( - table_type=ast.LazyJoinType( - table_type=events_table_alias_type, - field="pdi", - lazy_join=cast(LazyJoin, self.database.events.fields.get("pdi")), - ), - field="person", - lazy_join=cast( - LazyJoin, - cast(LazyJoin, self.database.events.fields.get("pdi")).join_table.fields.get("person"), - ), - ), - ), - }, - tables={"e": events_table_alias_type}, - ), - ) - self.assertEqual(expr.select, expected.select) - self.assertEqual(expr.select_from, expected.select_from) - self.assertEqual(expr.where, expected.where) - self.assertEqual(expr.type, expected.type) - self.assertEqual(expr, expected) + assert pretty_dataclasses(expr) == self.snapshot + @pytest.mark.usefixtures("unittest_snapshot") def test_resolve_virtual_events_poe(self): expr = self._select("select event, poe.id from events") expr = resolve_types(expr, self.context) - events_table_type = ast.TableType(table=self.database.events) - expected = ast.SelectQuery( - select=[ - ast.Field( - chain=["event"], - type=ast.FieldType(name="event", table_type=events_table_type), - ), - ast.Field( - chain=["poe", "id"], - type=ast.FieldType( - name="id", - table_type=ast.VirtualTableType( - table_type=events_table_type, - field="poe", - virtual_table=self.database.events.fields["poe"], - ), - ), - ), - ], - select_from=ast.JoinExpr( - table=ast.Field(chain=["events"], type=events_table_type), - type=events_table_type, - ), - type=ast.SelectQueryType( - aliases={}, - anonymous_tables=[], - columns={ - "event": ast.FieldType(name="event", table_type=events_table_type), - "id": ast.FieldType( - name="id", - table_type=ast.VirtualTableType( - table_type=events_table_type, - field="poe", - virtual_table=self.database.events.fields.get("poe"), - ), - ), - }, - tables={"events": events_table_type}, - ), - ) - self.assertEqual(expr.select, expected.select) - self.assertEqual(expr.select_from, expected.select_from) - self.assertEqual(expr.where, expected.where) - self.assertEqual(expr.type, expected.type) - self.assertEqual(expr, expected) + assert pretty_dataclasses(expr) == self.snapshot + @pytest.mark.usefixtures("unittest_snapshot") def test_resolve_union_all(self): node = self._select("select event, timestamp from events union all select event, timestamp from events") node = resolve_types(node, self.context) + assert pretty_dataclasses(node) == self.snapshot - events_table_type = ast.TableType(table=self.database.events) - self.assertEqual( - node.select_queries[0].select, - [ - ast.Field( - chain=["event"], - type=ast.FieldType(name="event", table_type=events_table_type), - ), - ast.Field( - chain=["timestamp"], - type=ast.FieldType(name="timestamp", table_type=events_table_type), - ), - ], - ) - self.assertEqual( - node.select_queries[1].select, - [ - ast.Field( - chain=["event"], - type=ast.FieldType(name="event", table_type=events_table_type), - ), - ast.Field( - chain=["timestamp"], - type=ast.FieldType(name="timestamp", table_type=events_table_type), - ), - ], - ) - + @pytest.mark.usefixtures("unittest_snapshot") def test_call_type(self): node = self._select("select max(timestamp) from events") node = resolve_types(node, self.context) - expected = [ - ast.Call( - name="max", - # NB! timestamp was resolved to a DateTimeType for the Call's arg type. - type=ast.CallType( - name="max", - arg_types=[ast.DateTimeType()], - return_type=ast.UnknownType(), - ), - args=[ - ast.Field( - chain=["timestamp"], - type=ast.FieldType( - name="timestamp", - table_type=ast.TableType(table=self.database.events), - ), - ) - ], - ), - ] - self.assertEqual(node.select, expected) + assert pretty_dataclasses(node) == self.snapshot def test_ctes_loop(self): with self.assertRaises(ResolverException) as e: @@ -760,10 +179,7 @@ def test_ctes_loop(self): def test_ctes_basic_column(self): expr = self._print_hogql("with 1 as cte select cte from events") expected = self._print_hogql("select 1 from events") - self.assertEqual( - expr, - expected, - ) + self.assertEqual(expr, expected) def test_ctes_recursive_column(self): self.assertEqual( @@ -815,282 +231,40 @@ def test_ctes_subquery_recursion(self): ) @override_settings(PERSON_ON_EVENTS_OVERRIDE=False, PERSON_ON_EVENTS_V2_OVERRIDE=False) + @pytest.mark.usefixtures("unittest_snapshot") def test_asterisk_expander_table(self): self.setUp() # rebuild self.database with PERSON_ON_EVENTS_OVERRIDE=False node = self._select("select * from events") node = resolve_types(node, self.context) - - events_table_type = ast.TableType(table=self.database.events) - self.assertEqual( - node.select, - [ - ast.Field( - chain=["uuid"], - type=ast.FieldType(name="uuid", table_type=events_table_type), - ), - ast.Field( - chain=["event"], - type=ast.FieldType(name="event", table_type=events_table_type), - ), - ast.Field( - chain=["properties"], - type=ast.FieldType(name="properties", table_type=events_table_type), - ), - ast.Field( - chain=["timestamp"], - type=ast.FieldType(name="timestamp", table_type=events_table_type), - ), - ast.Field( - chain=["distinct_id"], - type=ast.FieldType(name="distinct_id", table_type=events_table_type), - ), - ast.Field( - chain=["elements_chain"], - type=ast.FieldType(name="elements_chain", table_type=events_table_type), - ), - ast.Field( - chain=["created_at"], - type=ast.FieldType(name="created_at", table_type=events_table_type), - ), - ast.Field( - chain=["$session_id"], - type=ast.FieldType(name="$session_id", table_type=events_table_type), - ), - ast.Field( - chain=["$group_0"], - type=ast.FieldType(name="$group_0", table_type=events_table_type), - ), - ast.Field( - chain=["$group_1"], - type=ast.FieldType(name="$group_1", table_type=events_table_type), - ), - ast.Field( - chain=["$group_2"], - type=ast.FieldType(name="$group_2", table_type=events_table_type), - ), - ast.Field( - chain=["$group_3"], - type=ast.FieldType(name="$group_3", table_type=events_table_type), - ), - ast.Field( - chain=["$group_4"], - type=ast.FieldType(name="$group_4", table_type=events_table_type), - ), - ], - ) + assert pretty_dataclasses(node) == self.snapshot @override_settings(PERSON_ON_EVENTS_OVERRIDE=False, PERSON_ON_EVENTS_V2_OVERRIDE=False) + @pytest.mark.usefixtures("unittest_snapshot") def test_asterisk_expander_table_alias(self): self.setUp() # rebuild self.database with PERSON_ON_EVENTS_OVERRIDE=False node = self._select("select * from events e") node = resolve_types(node, self.context) + assert pretty_dataclasses(node) == self.snapshot - events_table_type = ast.TableType(table=self.database.events) - events_table_alias_type = ast.TableAliasType(table_type=events_table_type, alias="e") - self.assertEqual( - node.select, - [ - ast.Field( - chain=["uuid"], - type=ast.FieldType(name="uuid", table_type=events_table_alias_type), - ), - ast.Field( - chain=["event"], - type=ast.FieldType(name="event", table_type=events_table_alias_type), - ), - ast.Field( - chain=["properties"], - type=ast.FieldType(name="properties", table_type=events_table_alias_type), - ), - ast.Field( - chain=["timestamp"], - type=ast.FieldType(name="timestamp", table_type=events_table_alias_type), - ), - ast.Field( - chain=["distinct_id"], - type=ast.FieldType(name="distinct_id", table_type=events_table_alias_type), - ), - ast.Field( - chain=["elements_chain"], - type=ast.FieldType(name="elements_chain", table_type=events_table_alias_type), - ), - ast.Field( - chain=["created_at"], - type=ast.FieldType(name="created_at", table_type=events_table_alias_type), - ), - ast.Field( - chain=["$session_id"], - type=ast.FieldType(name="$session_id", table_type=events_table_alias_type), - ), - ast.Field( - chain=["$group_0"], - type=ast.FieldType(name="$group_0", table_type=events_table_alias_type), - ), - ast.Field( - chain=["$group_1"], - type=ast.FieldType(name="$group_1", table_type=events_table_alias_type), - ), - ast.Field( - chain=["$group_2"], - type=ast.FieldType(name="$group_2", table_type=events_table_alias_type), - ), - ast.Field( - chain=["$group_3"], - type=ast.FieldType(name="$group_3", table_type=events_table_alias_type), - ), - ast.Field( - chain=["$group_4"], - type=ast.FieldType(name="$group_4", table_type=events_table_alias_type), - ), - ], - ) - + @pytest.mark.usefixtures("unittest_snapshot") def test_asterisk_expander_subquery(self): node = self._select("select * from (select 1 as a, 2 as b)") node = resolve_types(node, self.context) - select_subquery_type = ast.SelectQueryType( - aliases={ - "a": ast.FieldAliasType(alias="a", type=ast.IntegerType()), - "b": ast.FieldAliasType(alias="b", type=ast.IntegerType()), - }, - columns={ - "a": ast.FieldAliasType(alias="a", type=ast.IntegerType()), - "b": ast.FieldAliasType(alias="b", type=ast.IntegerType()), - }, - tables={}, - anonymous_tables=[], - ) - self.assertEqual( - node.select, - [ - ast.Field( - chain=["a"], - type=ast.FieldType(name="a", table_type=select_subquery_type), - ), - ast.Field( - chain=["b"], - type=ast.FieldType(name="b", table_type=select_subquery_type), - ), - ], - ) + assert pretty_dataclasses(node) == self.snapshot + @pytest.mark.usefixtures("unittest_snapshot") def test_asterisk_expander_subquery_alias(self): node = self._select("select x.* from (select 1 as a, 2 as b) x") node = resolve_types(node, self.context) - select_subquery_type = ast.SelectQueryAliasType( - alias="x", - select_query_type=ast.SelectQueryType( - aliases={ - "a": ast.FieldAliasType(alias="a", type=ast.IntegerType()), - "b": ast.FieldAliasType(alias="b", type=ast.IntegerType()), - }, - columns={ - "a": ast.FieldAliasType(alias="a", type=ast.IntegerType()), - "b": ast.FieldAliasType(alias="b", type=ast.IntegerType()), - }, - tables={}, - anonymous_tables=[], - ), - ) - self.assertEqual( - node.select, - [ - ast.Field( - chain=["a"], - type=ast.FieldType(name="a", table_type=select_subquery_type), - ), - ast.Field( - chain=["b"], - type=ast.FieldType(name="b", table_type=select_subquery_type), - ), - ], - ) + assert pretty_dataclasses(node) == self.snapshot @override_settings(PERSON_ON_EVENTS_OVERRIDE=False, PERSON_ON_EVENTS_V2_OVERRIDE=False) + @pytest.mark.usefixtures("unittest_snapshot") def test_asterisk_expander_from_subquery_table(self): self.setUp() # rebuild self.database with PERSON_ON_EVENTS_OVERRIDE=False node = self._select("select * from (select * from events)") node = resolve_types(node, self.context) - - events_table_type = ast.TableType(table=self.database.events) - inner_select_type = ast.SelectQueryType( - tables={"events": events_table_type}, - anonymous_tables=[], - aliases={}, - columns={ - "uuid": ast.FieldType(name="uuid", table_type=events_table_type), - "event": ast.FieldType(name="event", table_type=events_table_type), - "properties": ast.FieldType(name="properties", table_type=events_table_type), - "timestamp": ast.FieldType(name="timestamp", table_type=events_table_type), - "distinct_id": ast.FieldType(name="distinct_id", table_type=events_table_type), - "elements_chain": ast.FieldType(name="elements_chain", table_type=events_table_type), - "created_at": ast.FieldType(name="created_at", table_type=events_table_type), - "$session_id": ast.FieldType(name="$session_id", table_type=events_table_type), - "$group_0": ast.FieldType(name="$group_0", table_type=events_table_type), - "$group_1": ast.FieldType(name="$group_1", table_type=events_table_type), - "$group_2": ast.FieldType(name="$group_2", table_type=events_table_type), - "$group_3": ast.FieldType(name="$group_3", table_type=events_table_type), - "$group_4": ast.FieldType(name="$group_4", table_type=events_table_type), - }, - ) - - self.assertEqual( - node.select, - [ - ast.Field( - chain=["uuid"], - type=ast.FieldType(name="uuid", table_type=inner_select_type), - ), - ast.Field( - chain=["event"], - type=ast.FieldType(name="event", table_type=inner_select_type), - ), - ast.Field( - chain=["properties"], - type=ast.FieldType(name="properties", table_type=inner_select_type), - ), - ast.Field( - chain=["timestamp"], - type=ast.FieldType(name="timestamp", table_type=inner_select_type), - ), - ast.Field( - chain=["distinct_id"], - type=ast.FieldType(name="distinct_id", table_type=inner_select_type), - ), - ast.Field( - chain=["elements_chain"], - type=ast.FieldType(name="elements_chain", table_type=inner_select_type), - ), - ast.Field( - chain=["created_at"], - type=ast.FieldType(name="created_at", table_type=inner_select_type), - ), - ast.Field( - chain=["$session_id"], - type=ast.FieldType(name="$session_id", table_type=inner_select_type), - ), - ast.Field( - chain=["$group_0"], - type=ast.FieldType(name="$group_0", table_type=inner_select_type), - ), - ast.Field( - chain=["$group_1"], - type=ast.FieldType(name="$group_1", table_type=inner_select_type), - ), - ast.Field( - chain=["$group_2"], - type=ast.FieldType(name="$group_2", table_type=inner_select_type), - ), - ast.Field( - chain=["$group_3"], - type=ast.FieldType(name="$group_3", table_type=inner_select_type), - ), - ast.Field( - chain=["$group_4"], - type=ast.FieldType(name="$group_4", table_type=inner_select_type), - ), - ], - ) + assert pretty_dataclasses(node) == self.snapshot def test_asterisk_expander_multiple_table_error(self): node = self._select("select * from (select 1 as a, 2 as b) x left join (select 1 as a, 2 as b) y on x.a = y.a") @@ -1102,95 +276,12 @@ def test_asterisk_expander_multiple_table_error(self): ) @override_settings(PERSON_ON_EVENTS_OVERRIDE=False, PERSON_ON_EVENTS_V2_OVERRIDE=False) + @pytest.mark.usefixtures("unittest_snapshot") def test_asterisk_expander_select_union(self): self.setUp() # rebuild self.database with PERSON_ON_EVENTS_OVERRIDE=False node = self._select("select * from (select * from events union all select * from events)") node = resolve_types(node, self.context) - - events_table_type = ast.TableType(table=self.database.events) - inner_select_type = ast.SelectUnionQueryType( - types=[ - ast.SelectQueryType( - tables={"events": events_table_type}, - anonymous_tables=[], - aliases={}, - columns={ - "uuid": ast.FieldType(name="uuid", table_type=events_table_type), - "event": ast.FieldType(name="event", table_type=events_table_type), - "properties": ast.FieldType(name="properties", table_type=events_table_type), - "timestamp": ast.FieldType(name="timestamp", table_type=events_table_type), - "distinct_id": ast.FieldType(name="distinct_id", table_type=events_table_type), - "elements_chain": ast.FieldType(name="elements_chain", table_type=events_table_type), - "created_at": ast.FieldType(name="created_at", table_type=events_table_type), - "$session_id": ast.FieldType(name="$session_id", table_type=events_table_type), - "$group_0": ast.FieldType(name="$group_0", table_type=events_table_type), - "$group_1": ast.FieldType(name="$group_1", table_type=events_table_type), - "$group_2": ast.FieldType(name="$group_2", table_type=events_table_type), - "$group_3": ast.FieldType(name="$group_3", table_type=events_table_type), - "$group_4": ast.FieldType(name="$group_4", table_type=events_table_type), - }, - ) - ] - * 2 - ) - - self.assertEqual( - node.select, - [ - ast.Field( - chain=["uuid"], - type=ast.FieldType(name="uuid", table_type=inner_select_type), - ), - ast.Field( - chain=["event"], - type=ast.FieldType(name="event", table_type=inner_select_type), - ), - ast.Field( - chain=["properties"], - type=ast.FieldType(name="properties", table_type=inner_select_type), - ), - ast.Field( - chain=["timestamp"], - type=ast.FieldType(name="timestamp", table_type=inner_select_type), - ), - ast.Field( - chain=["distinct_id"], - type=ast.FieldType(name="distinct_id", table_type=inner_select_type), - ), - ast.Field( - chain=["elements_chain"], - type=ast.FieldType(name="elements_chain", table_type=inner_select_type), - ), - ast.Field( - chain=["created_at"], - type=ast.FieldType(name="created_at", table_type=inner_select_type), - ), - ast.Field( - chain=["$session_id"], - type=ast.FieldType(name="$session_id", table_type=inner_select_type), - ), - ast.Field( - chain=["$group_0"], - type=ast.FieldType(name="$group_0", table_type=inner_select_type), - ), - ast.Field( - chain=["$group_1"], - type=ast.FieldType(name="$group_1", table_type=inner_select_type), - ), - ast.Field( - chain=["$group_2"], - type=ast.FieldType(name="$group_2", table_type=inner_select_type), - ), - ast.Field( - chain=["$group_3"], - type=ast.FieldType(name="$group_3", table_type=inner_select_type), - ), - ast.Field( - chain=["$group_4"], - type=ast.FieldType(name="$group_4", table_type=inner_select_type), - ), - ], - ) + assert pretty_dataclasses(node) == self.snapshot def test_lambda_parent_scope(self): # does not raise @@ -1234,7 +325,8 @@ def test_visit_hogqlx_tag(self): node = cast(ast.SelectQuery, resolve_types(node, self.context)) table_node = cast(ast.SelectQuery, node).select_from.table expected = ast.SelectQuery( - select=[ast.Field(chain=["event"])], select_from=ast.JoinExpr(table=ast.Field(chain=["events"])) + select=[ast.Field(chain=["event"])], + select_from=ast.JoinExpr(table=ast.Field(chain=["events"])), ) assert clone_expr(table_node, clear_types=True) == expected diff --git a/posthog/hogql/test/utils.py b/posthog/hogql/test/utils.py index 8e5fc45313a0f..c63f17e3cbc5c 100644 --- a/posthog/hogql/test/utils.py +++ b/posthog/hogql/test/utils.py @@ -1,3 +1,7 @@ +import dataclasses +import json + + def pretty_print_in_tests(query: str, team_id: int) -> str: return ( query.replace("SELECT", "\nSELECT") @@ -9,3 +13,46 @@ def pretty_print_in_tests(query: str, team_id: int) -> str: .replace("SETTINGS", "\nSETTINGS") .replace(f"team_id, {team_id})", "team_id, 420)") ) + + +def pretty_dataclasses(obj, seen=None, indent=0): + if seen is None: + seen = set() + + indent_space = " " * indent + next_indent = " " * (indent + 2) + + if dataclasses.is_dataclass(obj): + obj_id = id(obj) + if obj_id in seen: + return "" + seen.add(obj_id) + + field_strings = [] + fields = sorted(dataclasses.fields(obj), key=lambda f: f.name) + for f in fields: + value = getattr(obj, f.name) + if value is not None: + formatted_value = pretty_dataclasses(value, seen, indent + 2) + field_strings.append(f"{next_indent}{f.name}: {formatted_value}") + + return "{\n" + "\n".join(field_strings) + "\n" + indent_space + "}" + + elif isinstance(obj, list): + if len(obj) == 0: + return "[]" + elements = [pretty_dataclasses(item, seen, indent + 2) for item in obj] + return "[\n" + ",\n".join(next_indent + element for element in elements) + "\n" + indent_space + "]" + + elif isinstance(obj, dict): + if len(obj) == 0: + return "{}" + sorted_items = sorted(obj.items()) + key_value_pairs = [f"{k}: {pretty_dataclasses(v, seen, indent + 2)}" for k, v in sorted_items] + return "{\n" + ",\n".join(next_indent + pair for pair in key_value_pairs) + "\n" + indent_space + "}" + + elif isinstance(obj, str): + return json.dumps(obj) + + else: + return str(obj) From b16e3518c8c7dbad61badfdce1b7037992a755c8 Mon Sep 17 00:00:00 2001 From: Marius Andra Date: Tue, 21 Nov 2023 23:14:47 +0100 Subject: [PATCH 08/15] fixes --- .../test/__snapshots__/test_resolver.ambr | 726 +++++++++++++++++- posthog/hogql/test/utils.py | 7 + 2 files changed, 707 insertions(+), 26 deletions(-) diff --git a/posthog/hogql/test/__snapshots__/test_resolver.ambr b/posthog/hogql/test/__snapshots__/test_resolver.ambr index bde7c1b94e77f..78223c03c2b66 100644 --- a/posthog/hogql/test/__snapshots__/test_resolver.ambr +++ b/posthog/hogql/test/__snapshots__/test_resolver.ambr @@ -15,7 +15,41 @@ $group_0: { name: "$group_0" table_type: { - table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + table: { + fields: { + $group_0: {}, + $group_1: {}, + $group_2: {}, + $group_3: {}, + $group_4: {}, + $session_id: {}, + created_at: {}, + distinct_id: {}, + elements_chain: {}, + event: {}, + goe_0: {}, + goe_1: {}, + goe_2: {}, + goe_3: {}, + goe_4: {}, + group_0: {}, + group_1: {}, + group_2: {}, + group_3: {}, + group_4: {}, + override: {}, + override_person_id: {}, + pdi: {}, + person: {}, + person_id: {}, + poe: {}, + properties: {}, + session: {}, + team_id: {}, + timestamp: {}, + uuid: {} + } + } } }, $group_1: { @@ -323,7 +357,41 @@ $group_0: { name: "$group_0" table_type: { - table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + table: { + fields: { + $group_0: {}, + $group_1: {}, + $group_2: {}, + $group_3: {}, + $group_4: {}, + $session_id: {}, + created_at: {}, + distinct_id: {}, + elements_chain: {}, + event: {}, + goe_0: {}, + goe_1: {}, + goe_2: {}, + goe_3: {}, + goe_4: {}, + group_0: {}, + group_1: {}, + group_2: {}, + group_3: {}, + group_4: {}, + override: {}, + override_person_id: {}, + pdi: {}, + person: {}, + person_id: {}, + poe: {}, + properties: {}, + session: {}, + team_id: {}, + timestamp: {}, + uuid: {} + } + } } }, $group_1: { @@ -387,7 +455,41 @@ $group_0: { name: "$group_0" table_type: { - table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + table: { + fields: { + $group_0: {}, + $group_1: {}, + $group_2: {}, + $group_3: {}, + $group_4: {}, + $session_id: {}, + created_at: {}, + distinct_id: {}, + elements_chain: {}, + event: {}, + goe_0: {}, + goe_1: {}, + goe_2: {}, + goe_3: {}, + goe_4: {}, + group_0: {}, + group_1: {}, + group_2: {}, + group_3: {}, + group_4: {}, + override: {}, + override_person_id: {}, + pdi: {}, + person: {}, + person_id: {}, + poe: {}, + properties: {}, + session: {}, + team_id: {}, + timestamp: {}, + uuid: {} + } + } } }, $group_1: { @@ -958,7 +1060,41 @@ type: { name: "uuid" table_type: { - table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + table: { + fields: { + $group_0: {}, + $group_1: {}, + $group_2: {}, + $group_3: {}, + $group_4: {}, + $session_id: {}, + created_at: {}, + distinct_id: {}, + elements_chain: {}, + event: {}, + goe_0: {}, + goe_1: {}, + goe_2: {}, + goe_3: {}, + goe_4: {}, + group_0: {}, + group_1: {}, + group_2: {}, + group_3: {}, + group_4: {}, + override: {}, + override_person_id: {}, + pdi: {}, + person: {}, + person_id: {}, + poe: {}, + properties: {}, + session: {}, + team_id: {}, + timestamp: {}, + uuid: {} + } + } } } }, @@ -1119,7 +1255,41 @@ table_type: { alias: "e" table_type: { - table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + table: { + fields: { + $group_0: {}, + $group_1: {}, + $group_2: {}, + $group_3: {}, + $group_4: {}, + $session_id: {}, + created_at: {}, + distinct_id: {}, + elements_chain: {}, + event: {}, + goe_0: {}, + goe_1: {}, + goe_2: {}, + goe_3: {}, + goe_4: {}, + group_0: {}, + group_1: {}, + group_2: {}, + group_3: {}, + group_4: {}, + override: {}, + override_person_id: {}, + pdi: {}, + person: {}, + person_id: {}, + poe: {}, + properties: {}, + session: {}, + team_id: {}, + timestamp: {}, + uuid: {} + } + } } } } @@ -1282,7 +1452,41 @@ type: { name: "timestamp" table_type: { - table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + table: { + fields: { + $group_0: {}, + $group_1: {}, + $group_2: {}, + $group_3: {}, + $group_4: {}, + $session_id: {}, + created_at: {}, + distinct_id: {}, + elements_chain: {}, + event: {}, + goe_0: {}, + goe_1: {}, + goe_2: {}, + goe_3: {}, + goe_4: {}, + group_0: {}, + group_1: {}, + group_2: {}, + group_3: {}, + group_4: {}, + override: {}, + override_person_id: {}, + pdi: {}, + person: {}, + person_id: {}, + poe: {}, + properties: {}, + session: {}, + team_id: {}, + timestamp: {}, + uuid: {} + } + } } } } @@ -1498,7 +1702,41 @@ type: { name: "event" table_type: { - table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + table: { + fields: { + $group_0: {}, + $group_1: {}, + $group_2: {}, + $group_3: {}, + $group_4: {}, + $session_id: {}, + created_at: {}, + distinct_id: {}, + elements_chain: {}, + event: {}, + goe_0: {}, + goe_1: {}, + goe_2: {}, + goe_3: {}, + goe_4: {}, + group_0: {}, + group_1: {}, + group_2: {}, + group_3: {}, + group_4: {}, + override: {}, + override_person_id: {}, + pdi: {}, + person: {}, + person_id: {}, + poe: {}, + properties: {}, + session: {}, + team_id: {}, + timestamp: {}, + uuid: {} + } + } } } }, @@ -1572,7 +1810,41 @@ table_type: { alias: "e" table_type: { - table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + table: { + fields: { + $group_0: {}, + $group_1: {}, + $group_2: {}, + $group_3: {}, + $group_4: {}, + $session_id: {}, + created_at: {}, + distinct_id: {}, + elements_chain: {}, + event: {}, + goe_0: {}, + goe_1: {}, + goe_2: {}, + goe_3: {}, + goe_4: {}, + group_0: {}, + group_1: {}, + group_2: {}, + group_3: {}, + group_4: {}, + override: {}, + override_person_id: {}, + pdi: {}, + person: {}, + person_id: {}, + poe: {}, + properties: {}, + session: {}, + team_id: {}, + timestamp: {}, + uuid: {} + } + } } } } @@ -1650,7 +1922,41 @@ table_type: { alias: "e" table_type: { - table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + table: { + fields: { + $group_0: {}, + $group_1: {}, + $group_2: {}, + $group_3: {}, + $group_4: {}, + $session_id: {}, + created_at: {}, + distinct_id: {}, + elements_chain: {}, + event: {}, + goe_0: {}, + goe_1: {}, + goe_2: {}, + goe_3: {}, + goe_4: {}, + group_0: {}, + group_1: {}, + group_2: {}, + group_3: {}, + group_4: {}, + override: {}, + override_person_id: {}, + pdi: {}, + person: {}, + person_id: {}, + poe: {}, + properties: {}, + session: {}, + team_id: {}, + timestamp: {}, + uuid: {} + } + } } } } @@ -1760,7 +2066,41 @@ type: { name: "event" table_type: { - table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + table: { + fields: { + $group_0: {}, + $group_1: {}, + $group_2: {}, + $group_3: {}, + $group_4: {}, + $session_id: {}, + created_at: {}, + distinct_id: {}, + elements_chain: {}, + event: {}, + goe_0: {}, + goe_1: {}, + goe_2: {}, + goe_3: {}, + goe_4: {}, + group_0: {}, + group_1: {}, + group_2: {}, + group_3: {}, + group_4: {}, + override: {}, + override_person_id: {}, + pdi: {}, + person: {}, + person_id: {}, + poe: {}, + properties: {}, + session: {}, + team_id: {}, + timestamp: {}, + uuid: {} + } + } } } }, @@ -1871,7 +2211,41 @@ type: { name: "event" table_type: { - table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + table: { + fields: { + $group_0: {}, + $group_1: {}, + $group_2: {}, + $group_3: {}, + $group_4: {}, + $session_id: {}, + created_at: {}, + distinct_id: {}, + elements_chain: {}, + event: {}, + goe_0: {}, + goe_1: {}, + goe_2: {}, + goe_3: {}, + goe_4: {}, + group_0: {}, + group_1: {}, + group_2: {}, + group_3: {}, + group_4: {}, + override: {}, + override_person_id: {}, + pdi: {}, + person: {}, + person_id: {}, + poe: {}, + properties: {}, + session: {}, + team_id: {}, + timestamp: {}, + uuid: {} + } + } } } }, @@ -1885,10 +2259,34 @@ name: "id" table_type: { field: "person" - lazy_join: join_function= join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}) from_field='person_id' + lazy_join: { + from_field: "person_id", + join_function: , + join_table: { + fields: { + created_at: {}, + id: {}, + is_identified: {}, + pdi: {}, + properties: {}, + team_id: {} + } + } + } table_type: { field: "pdi" - lazy_join: join_function= join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}) from_field='distinct_id' + lazy_join: { + from_field: "distinct_id", + join_function: , + join_table: { + fields: { + distinct_id: {}, + person: {}, + person_id: {}, + team_id: {} + } + } + } table_type: } } @@ -1932,7 +2330,41 @@ table_type: { alias: "e" table_type: { - table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + table: { + fields: { + $group_0: {}, + $group_1: {}, + $group_2: {}, + $group_3: {}, + $group_4: {}, + $session_id: {}, + created_at: {}, + distinct_id: {}, + elements_chain: {}, + event: {}, + goe_0: {}, + goe_1: {}, + goe_2: {}, + goe_3: {}, + goe_4: {}, + group_0: {}, + group_1: {}, + group_2: {}, + group_3: {}, + group_4: {}, + override: {}, + override_person_id: {}, + pdi: {}, + person: {}, + person_id: {}, + poe: {}, + properties: {}, + session: {}, + team_id: {}, + timestamp: {}, + uuid: {} + } + } } } } @@ -1948,10 +2380,34 @@ name: "id" table_type: { field: "person" - lazy_join: join_function= join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}) from_field='person_id' + lazy_join: { + from_field: "person_id", + join_function: , + join_table: { + fields: { + created_at: {}, + id: {}, + is_identified: {}, + pdi: {}, + properties: {}, + team_id: {} + } + } + } table_type: { field: "pdi" - lazy_join: join_function= join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}) from_field='distinct_id' + lazy_join: { + from_field: "distinct_id", + join_function: , + join_table: { + fields: { + distinct_id: {}, + person: {}, + person_id: {}, + team_id: {} + } + } + } table_type: } } @@ -1994,7 +2450,41 @@ type: { name: "event" table_type: { - table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + table: { + fields: { + $group_0: {}, + $group_1: {}, + $group_2: {}, + $group_3: {}, + $group_4: {}, + $session_id: {}, + created_at: {}, + distinct_id: {}, + elements_chain: {}, + event: {}, + goe_0: {}, + goe_1: {}, + goe_2: {}, + goe_3: {}, + goe_4: {}, + group_0: {}, + group_1: {}, + group_2: {}, + group_3: {}, + group_4: {}, + override: {}, + override_person_id: {}, + pdi: {}, + person: {}, + person_id: {}, + poe: {}, + properties: {}, + session: {}, + team_id: {}, + timestamp: {}, + uuid: {} + } + } } } }, @@ -2007,7 +2497,18 @@ name: "person_id" table_type: { field: "pdi" - lazy_join: join_function= join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}) from_field='distinct_id' + lazy_join: { + from_field: "distinct_id", + join_function: , + join_table: { + fields: { + distinct_id: {}, + person: {}, + person_id: {}, + team_id: {} + } + } + } table_type: } } @@ -2050,7 +2551,41 @@ table_type: { alias: "e" table_type: { - table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + table: { + fields: { + $group_0: {}, + $group_1: {}, + $group_2: {}, + $group_3: {}, + $group_4: {}, + $session_id: {}, + created_at: {}, + distinct_id: {}, + elements_chain: {}, + event: {}, + goe_0: {}, + goe_1: {}, + goe_2: {}, + goe_3: {}, + goe_4: {}, + group_0: {}, + group_1: {}, + group_2: {}, + group_3: {}, + group_4: {}, + override: {}, + override_person_id: {}, + pdi: {}, + person: {}, + person_id: {}, + poe: {}, + properties: {}, + session: {}, + team_id: {}, + timestamp: {}, + uuid: {} + } + } } } } @@ -2065,7 +2600,18 @@ name: "person_id" table_type: { field: "pdi" - lazy_join: join_function= join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}) from_field='distinct_id' + lazy_join: { + from_field: "distinct_id", + join_function: , + join_table: { + fields: { + distinct_id: {}, + person: {}, + person_id: {}, + team_id: {} + } + } + } table_type: } } @@ -2107,7 +2653,14 @@ type: { name: "distinct_id" table_type: { - table: fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')} + table: { + fields: { + distinct_id: {}, + person: {}, + person_id: {}, + team_id: {} + } + } } } }, @@ -2120,7 +2673,20 @@ name: "id" table_type: { field: "person" - lazy_join: join_function= join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}) from_field='person_id' + lazy_join: { + from_field: "person_id", + join_function: , + join_table: { + fields: { + created_at: {}, + id: {}, + is_identified: {}, + pdi: {}, + properties: {}, + team_id: {} + } + } + } table_type: } } @@ -2163,7 +2729,41 @@ type: { name: "event" table_type: { - table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + table: { + fields: { + $group_0: {}, + $group_1: {}, + $group_2: {}, + $group_3: {}, + $group_4: {}, + $session_id: {}, + created_at: {}, + distinct_id: {}, + elements_chain: {}, + event: {}, + goe_0: {}, + goe_1: {}, + goe_2: {}, + goe_3: {}, + goe_4: {}, + group_0: {}, + group_1: {}, + group_2: {}, + group_3: {}, + group_4: {}, + override: {}, + override_person_id: {}, + pdi: {}, + person: {}, + person_id: {}, + poe: {}, + properties: {}, + session: {}, + team_id: {}, + timestamp: {}, + uuid: {} + } + } } } }, @@ -2208,7 +2808,41 @@ type: { name: "event" table_type: { - table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + table: { + fields: { + $group_0: {}, + $group_1: {}, + $group_2: {}, + $group_3: {}, + $group_4: {}, + $session_id: {}, + created_at: {}, + distinct_id: {}, + elements_chain: {}, + event: {}, + goe_0: {}, + goe_1: {}, + goe_2: {}, + goe_3: {}, + goe_4: {}, + group_0: {}, + group_1: {}, + group_2: {}, + group_3: {}, + group_4: {}, + override: {}, + override_person_id: {}, + pdi: {}, + person: {}, + person_id: {}, + poe: {}, + properties: {}, + session: {}, + team_id: {}, + timestamp: {}, + uuid: {} + } + } } } }, @@ -2265,7 +2899,41 @@ type: { name: "event" table_type: { - table: fields={'uuid': StringDatabaseField(name='uuid', array=None, nullable=None), 'event': StringDatabaseField(name='event', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'timestamp': DateTimeDatabaseField(name='timestamp', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'elements_chain': StringDatabaseField(name='elements_chain', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), '$session_id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonDistinctIdsTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None), 'person': LazyJoin(join_function=, join_table=PersonsTable(fields={'id': StringDatabaseField(name='id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='properties', array=None, nullable=None), 'is_identified': BooleanDatabaseField(name='is_identified', array=None, nullable=None), 'pdi': LazyJoin(join_function=, join_table=PersonsPDITable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'distinct_id': StringDatabaseField(name='distinct_id', array=None, nullable=None), 'person_id': StringDatabaseField(name='person_id', array=None, nullable=None)}), from_field='id')}), from_field='person_id')}), from_field='distinct_id'), 'override': LazyJoin(join_function=, join_table=PersonOverridesTable(fields={'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'old_person_id': StringDatabaseField(name='old_person_id', array=None, nullable=None), 'override_person_id': StringDatabaseField(name='override_person_id', array=None, nullable=None), 'oldest_event': DateTimeDatabaseField(name='oldest_event', array=None, nullable=None), 'merged_at': DateTimeDatabaseField(name='merged_at', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None)}), from_field='person_id'), 'override_person_id': FieldTraverser(chain=['override', 'override_person_id']), 'poe': EventsPersonSubTable(fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)}), 'goe_0': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_0', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group0_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group0_properties', array=None, nullable=None)}), 'goe_1': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_1', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group1_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group1_properties', array=None, nullable=None)}), 'goe_2': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_2', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group2_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group2_properties', array=None, nullable=None)}), 'goe_3': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_3', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group3_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group3_properties', array=None, nullable=None)}), 'goe_4': EventsGroupSubTable(fields={'key': StringDatabaseField(name='$group_4', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='group4_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group4_properties', array=None, nullable=None)}), 'person': FieldTraverser(chain=['pdi', 'person']), 'person_id': FieldTraverser(chain=['pdi', 'person_id']), '$group_0': StringDatabaseField(name='$group_0', array=None, nullable=None), 'group_0': LazyJoin(join_function=.join_with_group_table at 0x10d934430>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_0'), '$group_1': StringDatabaseField(name='$group_1', array=None, nullable=None), 'group_1': LazyJoin(join_function=.join_with_group_table at 0x10d934af0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_1'), '$group_2': StringDatabaseField(name='$group_2', array=None, nullable=None), 'group_2': LazyJoin(join_function=.join_with_group_table at 0x10d934820>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_2'), '$group_3': StringDatabaseField(name='$group_3', array=None, nullable=None), 'group_3': LazyJoin(join_function=.join_with_group_table at 0x10d934ca0>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_3'), '$group_4': StringDatabaseField(name='$group_4', array=None, nullable=None), 'group_4': LazyJoin(join_function=.join_with_group_table at 0x10d934b80>, join_table=GroupsTable(fields={'index': IntegerDatabaseField(name='group_type_index', array=None, nullable=None), 'team_id': IntegerDatabaseField(name='team_id', array=None, nullable=None), 'key': StringDatabaseField(name='group_key', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='created_at', array=None, nullable=None), 'updated_at': DateTimeDatabaseField(name='_timestamp', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='group_properties', array=None, nullable=None)}), from_field='$group_4'), 'session': LazyJoin(join_function=, join_table=EventsSessionSubTable(fields={'id': StringDatabaseField(name='$session_id', array=None, nullable=None), 'duration': IntegerDatabaseField(name='session_duration', array=None, nullable=None)}), from_field='$session_id')} + table: { + fields: { + $group_0: {}, + $group_1: {}, + $group_2: {}, + $group_3: {}, + $group_4: {}, + $session_id: {}, + created_at: {}, + distinct_id: {}, + elements_chain: {}, + event: {}, + goe_0: {}, + goe_1: {}, + goe_2: {}, + goe_3: {}, + goe_4: {}, + group_0: {}, + group_1: {}, + group_2: {}, + group_3: {}, + group_4: {}, + override: {}, + override_person_id: {}, + pdi: {}, + person: {}, + person_id: {}, + poe: {}, + properties: {}, + session: {}, + team_id: {}, + timestamp: {}, + uuid: {} + } + } } } }, @@ -2279,7 +2947,13 @@ table_type: { field: "poe" table_type: - virtual_table: fields={'id': StringDatabaseField(name='person_id', array=None, nullable=None), 'created_at': DateTimeDatabaseField(name='person_created_at', array=None, nullable=None), 'properties': StringJSONDatabaseField(name='person_properties', array=None, nullable=None)} + virtual_table: { + fields: { + created_at: {}, + id: {}, + properties: {} + } + } } } } diff --git a/posthog/hogql/test/utils.py b/posthog/hogql/test/utils.py index c63f17e3cbc5c..7e46c620c997a 100644 --- a/posthog/hogql/test/utils.py +++ b/posthog/hogql/test/utils.py @@ -1,5 +1,6 @@ import dataclasses import json +from pydantic import BaseModel def pretty_print_in_tests(query: str, team_id: int) -> str: @@ -22,6 +23,9 @@ def pretty_dataclasses(obj, seen=None, indent=0): indent_space = " " * indent next_indent = " " * (indent + 2) + if isinstance(obj, BaseModel): + obj = obj.model_dump() + if dataclasses.is_dataclass(obj): obj_id = id(obj) if obj_id in seen: @@ -54,5 +58,8 @@ def pretty_dataclasses(obj, seen=None, indent=0): elif isinstance(obj, str): return json.dumps(obj) + elif callable(obj): + return "" + else: return str(obj) From b5e5bc1dab00250a45167181de64c3e8a72115f6 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 21 Nov 2023 22:21:17 +0000 Subject: [PATCH 09/15] Update query snapshots --- ee/clickhouse/models/test/__snapshots__/test_property.ambr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/clickhouse/models/test/__snapshots__/test_property.ambr b/ee/clickhouse/models/test/__snapshots__/test_property.ambr index cc8e77f83a0dc..d27396834cf99 100644 --- a/ee/clickhouse/models/test/__snapshots__/test_property.ambr +++ b/ee/clickhouse/models/test/__snapshots__/test_property.ambr @@ -57,7 +57,7 @@ --- # name: test_parse_groups_persons_edge_case_with_single_filter ( - 'AND ( has(%(vglobalperson_0)s, replaceRegexpAll(JSONExtractRaw(person_props, %(kglobalperson_0)s), \'^"|"$\', \'\')))', + 'AND ( has(%(vglobalperson_0)s, "pmat_email"))', { 'kglobalperson_0': 'email', 'vglobalperson_0': [ From 602f643adf2f4eda62bf662032d79bcf03bb403e Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 21 Nov 2023 22:21:23 +0000 Subject: [PATCH 10/15] Update query snapshots --- ee/clickhouse/models/test/__snapshots__/test_property.ambr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/clickhouse/models/test/__snapshots__/test_property.ambr b/ee/clickhouse/models/test/__snapshots__/test_property.ambr index cc8e77f83a0dc..d27396834cf99 100644 --- a/ee/clickhouse/models/test/__snapshots__/test_property.ambr +++ b/ee/clickhouse/models/test/__snapshots__/test_property.ambr @@ -57,7 +57,7 @@ --- # name: test_parse_groups_persons_edge_case_with_single_filter ( - 'AND ( has(%(vglobalperson_0)s, replaceRegexpAll(JSONExtractRaw(person_props, %(kglobalperson_0)s), \'^"|"$\', \'\')))', + 'AND ( has(%(vglobalperson_0)s, "pmat_email"))', { 'kglobalperson_0': 'email', 'vglobalperson_0': [ From f67f4ca01136c20bb8c8c9bf58a94239ddbbaaf1 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 21 Nov 2023 22:22:40 +0000 Subject: [PATCH 11/15] Update query snapshots --- .../api/test/__snapshots__/test_query.ambr | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/posthog/api/test/__snapshots__/test_query.ambr b/posthog/api/test/__snapshots__/test_query.ambr index d467a08e15b7a..38ee1f19a66b2 100644 --- a/posthog/api/test/__snapshots__/test_query.ambr +++ b/posthog/api/test/__snapshots__/test_query.ambr @@ -3,7 +3,7 @@ /* user_id:0 request:_snapshot_ */ SELECT events.event, events.distinct_id, - replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', ''), + replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '') AS key, 'a%sd', concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '')), '')) FROM events @@ -20,7 +20,7 @@ /* user_id:0 request:_snapshot_ */ SELECT events.event, events.distinct_id, - replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', ''), + replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '') AS key, 'a%sd', concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '')), '')) FROM events @@ -37,7 +37,7 @@ /* user_id:0 request:_snapshot_ */ SELECT events.event, events.distinct_id, - replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', ''), + replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '') AS key, 'a%sd', concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '')), '')) FROM events @@ -54,7 +54,7 @@ /* user_id:0 request:_snapshot_ */ SELECT events.event, events.distinct_id, - nullIf(nullIf(events.mat_key, ''), 'null'), + nullIf(nullIf(events.mat_key, ''), 'null') AS key, 'a%sd', concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(nullIf(nullIf(events.mat_key, ''), 'null')), '')) FROM events @@ -71,7 +71,7 @@ /* user_id:0 request:_snapshot_ */ SELECT events.event, events.distinct_id, - nullIf(nullIf(events.mat_key, ''), 'null'), + nullIf(nullIf(events.mat_key, ''), 'null') AS key, 'a%sd', concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(nullIf(nullIf(events.mat_key, ''), 'null')), '')) FROM events @@ -88,7 +88,7 @@ /* user_id:0 request:_snapshot_ */ SELECT events.event, events.distinct_id, - nullIf(nullIf(events.mat_key, ''), 'null'), + nullIf(nullIf(events.mat_key, ''), 'null') AS key, 'a%sd', concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(nullIf(nullIf(events.mat_key, ''), 'null')), '')) FROM events @@ -144,7 +144,7 @@ /* user_id:0 request:_snapshot_ */ SELECT events.event, events.distinct_id, - replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '') + replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '') AS key FROM events WHERE equals(events.team_id, 2) ORDER BY toTimeZone(events.timestamp, 'UTC') ASC @@ -158,7 +158,7 @@ /* user_id:0 request:_snapshot_ */ SELECT events.event, events.distinct_id, - nullIf(nullIf(events.mat_key, ''), 'null') + nullIf(nullIf(events.mat_key, ''), 'null') AS key FROM events WHERE equals(events.team_id, 2) ORDER BY toTimeZone(events.timestamp, 'UTC') ASC @@ -204,7 +204,7 @@ /* user_id:0 request:_snapshot_ */ SELECT events.event, events.distinct_id, - replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', ''), + replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '') AS key, 'a%sd', concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '')), '')) FROM events @@ -221,7 +221,7 @@ /* user_id:0 request:_snapshot_ */ SELECT events.event, events.distinct_id, - replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', ''), + replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '') AS key, 'a%sd', concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '')), '')) FROM events @@ -238,7 +238,7 @@ /* user_id:0 request:_snapshot_ */ SELECT events.event, events.distinct_id, - replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', ''), + replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '') AS key, 'a%sd', concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '')), '')) FROM events @@ -255,7 +255,7 @@ /* user_id:0 request:_snapshot_ */ SELECT events.event, events.distinct_id, - replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', ''), + replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '') AS key, 'a%sd', concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '')), '')) FROM events @@ -272,7 +272,7 @@ /* user_id:0 request:_snapshot_ */ SELECT events.event, events.distinct_id, - nullIf(nullIf(events.mat_key, ''), 'null'), + nullIf(nullIf(events.mat_key, ''), 'null') AS key, 'a%sd', concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(nullIf(nullIf(events.mat_key, ''), 'null')), '')) FROM events @@ -289,7 +289,7 @@ /* user_id:0 request:_snapshot_ */ SELECT events.event, events.distinct_id, - nullIf(nullIf(events.mat_key, ''), 'null'), + nullIf(nullIf(events.mat_key, ''), 'null') AS key, 'a%sd', concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(nullIf(nullIf(events.mat_key, ''), 'null')), '')) FROM events @@ -306,7 +306,7 @@ /* user_id:0 request:_snapshot_ */ SELECT events.event, events.distinct_id, - nullIf(nullIf(events.mat_key, ''), 'null'), + nullIf(nullIf(events.mat_key, ''), 'null') AS key, 'a%sd', concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(nullIf(nullIf(events.mat_key, ''), 'null')), '')) FROM events @@ -323,7 +323,7 @@ /* user_id:0 request:_snapshot_ */ SELECT events.event, events.distinct_id, - nullIf(nullIf(events.mat_key, ''), 'null'), + nullIf(nullIf(events.mat_key, ''), 'null') AS key, 'a%sd', concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(nullIf(nullIf(events.mat_key, ''), 'null')), '')) FROM events @@ -340,7 +340,7 @@ /* user_id:0 request:_snapshot_ */ SELECT events.event, events.distinct_id, - replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', ''), + replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '') AS key, 'a%sd', concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '')), '')) FROM events @@ -374,7 +374,7 @@ /* user_id:0 request:_snapshot_ */ SELECT events.event, events.distinct_id, - nullIf(nullIf(events.mat_key, ''), 'null'), + nullIf(nullIf(events.mat_key, ''), 'null') AS key, 'a%sd', concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(nullIf(nullIf(events.mat_key, ''), 'null')), '')) FROM events @@ -406,7 +406,7 @@ # name: TestQuery.test_property_filter_aggregations ' /* user_id:0 request:_snapshot_ */ - SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', ''), + SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '') AS key, count() FROM events WHERE and(equals(events.team_id, 2), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))) @@ -421,7 +421,7 @@ # name: TestQuery.test_property_filter_aggregations.1 ' /* user_id:0 request:_snapshot_ */ - SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', ''), + SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '') AS key, count() FROM events WHERE and(equals(events.team_id, 2), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))) @@ -437,7 +437,7 @@ # name: TestQuery.test_property_filter_aggregations_materialized ' /* user_id:0 request:_snapshot_ */ - SELECT nullIf(nullIf(events.mat_key, ''), 'null'), + SELECT nullIf(nullIf(events.mat_key, ''), 'null') AS key, count() FROM events WHERE and(equals(events.team_id, 2), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))) @@ -452,7 +452,7 @@ # name: TestQuery.test_property_filter_aggregations_materialized.1 ' /* user_id:0 request:_snapshot_ */ - SELECT nullIf(nullIf(events.mat_key, ''), 'null'), + SELECT nullIf(nullIf(events.mat_key, ''), 'null') AS key, count() FROM events WHERE and(equals(events.team_id, 2), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))) @@ -483,7 +483,7 @@ # name: TestQuery.test_select_hogql_expressions ' /* user_id:0 request:_snapshot_ */ - SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', ''), + SELECT replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '') AS key, events.event, events.distinct_id, concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'key'), ''), 'null'), '^"|"$', '')), '')) From 2ebd3c08494fcc60119789e7d78f779a891e5e35 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 21 Nov 2023 22:23:10 +0000 Subject: [PATCH 12/15] Update query snapshots --- .../test_clickhouse_experiment_secondary_results.ambr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/clickhouse/views/test/__snapshots__/test_clickhouse_experiment_secondary_results.ambr b/ee/clickhouse/views/test/__snapshots__/test_clickhouse_experiment_secondary_results.ambr index 11cfe7070f2f4..3474ae77b858f 100644 --- a/ee/clickhouse/views/test/__snapshots__/test_clickhouse_experiment_secondary_results.ambr +++ b/ee/clickhouse/views/test/__snapshots__/test_clickhouse_experiment_secondary_results.ambr @@ -1,6 +1,6 @@ # name: ClickhouseTestExperimentSecondaryResults.test_basic_secondary_metric_results ' - /* user_id:133 celery:posthog.celery.sync_insight_caching_state */ + /* user_id:131 celery:posthog.celery.sync_insight_caching_state */ SELECT team_id, date_diff('second', max(timestamp), now()) AS age FROM events From 7a29571827953e2f3641e7d360b902d2bebf1bbf Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 21 Nov 2023 22:23:31 +0000 Subject: [PATCH 13/15] Update query snapshots --- .../test_clickhouse_experiment_secondary_results.ambr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/clickhouse/views/test/__snapshots__/test_clickhouse_experiment_secondary_results.ambr b/ee/clickhouse/views/test/__snapshots__/test_clickhouse_experiment_secondary_results.ambr index 11cfe7070f2f4..3474ae77b858f 100644 --- a/ee/clickhouse/views/test/__snapshots__/test_clickhouse_experiment_secondary_results.ambr +++ b/ee/clickhouse/views/test/__snapshots__/test_clickhouse_experiment_secondary_results.ambr @@ -1,6 +1,6 @@ # name: ClickhouseTestExperimentSecondaryResults.test_basic_secondary_metric_results ' - /* user_id:133 celery:posthog.celery.sync_insight_caching_state */ + /* user_id:131 celery:posthog.celery.sync_insight_caching_state */ SELECT team_id, date_diff('second', max(timestamp), now()) AS age FROM events From 797d17f6e0c2a1e833c4d4adb8801dc7b2fd7124 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 21 Nov 2023 22:26:35 +0000 Subject: [PATCH 14/15] Update query snapshots --- .../test/__snapshots__/test_resolver.ambr | 3928 +++++++++++------ 1 file changed, 2468 insertions(+), 1460 deletions(-) diff --git a/posthog/hogql/test/__snapshots__/test_resolver.ambr b/posthog/hogql/test/__snapshots__/test_resolver.ambr index 78223c03c2b66..03f6a7369d379 100644 --- a/posthog/hogql/test/__snapshots__/test_resolver.ambr +++ b/posthog/hogql/test/__snapshots__/test_resolver.ambr @@ -3,217 +3,360 @@ { select: [ { - chain: [ - "uuid" - ] - type: { - name: "uuid" - table_type: { - aliases: {} - anonymous_tables: [] - columns: { - $group_0: { - name: "$group_0" - table_type: { - table: { - fields: { - $group_0: {}, - $group_1: {}, - $group_2: {}, - $group_3: {}, - $group_4: {}, - $session_id: {}, - created_at: {}, - distinct_id: {}, - elements_chain: {}, - event: {}, - goe_0: {}, - goe_1: {}, - goe_2: {}, - goe_3: {}, - goe_4: {}, - group_0: {}, - group_1: {}, - group_2: {}, - group_3: {}, - group_4: {}, - override: {}, - override_person_id: {}, - pdi: {}, - person: {}, - person_id: {}, - poe: {}, - properties: {}, - session: {}, - team_id: {}, - timestamp: {}, - uuid: {} + alias: "uuid" + expr: { + chain: [ + "uuid" + ] + type: { + name: "uuid" + table_type: { + aliases: {} + anonymous_tables: [] + columns: { + $group_0: { + alias: "$group_0" + type: { + name: "$group_0" + table_type: { + table: { + fields: { + $group_0: {}, + $group_1: {}, + $group_2: {}, + $group_3: {}, + $group_4: {}, + $session_id: {}, + created_at: {}, + distinct_id: {}, + elements_chain: {}, + event: {}, + goe_0: {}, + goe_1: {}, + goe_2: {}, + goe_3: {}, + goe_4: {}, + group_0: {}, + group_1: {}, + group_2: {}, + group_3: {}, + group_4: {}, + override: {}, + override_person_id: {}, + pdi: {}, + person: {}, + person_id: {}, + poe: {}, + properties: {}, + session: {}, + team_id: {}, + timestamp: {}, + uuid: {} + } + } } } + }, + $group_1: { + alias: "$group_1" + type: { + name: "$group_1" + table_type: + } + }, + $group_2: { + alias: "$group_2" + type: { + name: "$group_2" + table_type: + } + }, + $group_3: { + alias: "$group_3" + type: { + name: "$group_3" + table_type: + } + }, + $group_4: { + alias: "$group_4" + type: { + name: "$group_4" + table_type: + } + }, + $session_id: { + alias: "$session_id" + type: { + name: "$session_id" + table_type: + } + }, + created_at: { + alias: "created_at" + type: { + name: "created_at" + table_type: + } + }, + distinct_id: { + alias: "distinct_id" + type: { + name: "distinct_id" + table_type: + } + }, + elements_chain: { + alias: "elements_chain" + type: { + name: "elements_chain" + table_type: + } + }, + event: { + alias: "event" + type: { + name: "event" + table_type: + } + }, + properties: { + alias: "properties" + type: { + name: "properties" + table_type: + } + }, + timestamp: { + alias: "timestamp" + type: { + name: "timestamp" + table_type: + } + }, + uuid: { + alias: "uuid" + type: { + name: "uuid" + table_type: + } } - }, - $group_1: { - name: "$group_1" - table_type: - }, - $group_2: { - name: "$group_2" - table_type: - }, - $group_3: { - name: "$group_3" - table_type: - }, - $group_4: { - name: "$group_4" - table_type: - }, - $session_id: { - name: "$session_id" - table_type: - }, - created_at: { - name: "created_at" - table_type: - }, - distinct_id: { - name: "distinct_id" - table_type: - }, - elements_chain: { - name: "elements_chain" - table_type: - }, - event: { - name: "event" - table_type: - }, - properties: { - name: "properties" - table_type: - }, - timestamp: { - name: "timestamp" - table_type: - }, - uuid: { - name: "uuid" - table_type: } - } - ctes: {} - tables: { - events: + ctes: {} + tables: { + events: + } } } } + hidden: True + type: { + alias: "uuid" + type: + } }, { - chain: [ - "event" - ] + alias: "event" + expr: { + chain: [ + "event" + ] + type: { + name: "event" + table_type: + } + } + hidden: True type: { - name: "event" - table_type: + alias: "event" + type: } }, { - chain: [ - "properties" - ] + alias: "properties" + expr: { + chain: [ + "properties" + ] + type: { + name: "properties" + table_type: + } + } + hidden: True type: { - name: "properties" - table_type: + alias: "properties" + type: } }, { - chain: [ - "timestamp" - ] + alias: "timestamp" + expr: { + chain: [ + "timestamp" + ] + type: { + name: "timestamp" + table_type: + } + } + hidden: True type: { - name: "timestamp" - table_type: + alias: "timestamp" + type: } }, { - chain: [ - "distinct_id" - ] + alias: "distinct_id" + expr: { + chain: [ + "distinct_id" + ] + type: { + name: "distinct_id" + table_type: + } + } + hidden: True type: { - name: "distinct_id" - table_type: + alias: "distinct_id" + type: } }, { - chain: [ - "elements_chain" - ] + alias: "elements_chain" + expr: { + chain: [ + "elements_chain" + ] + type: { + name: "elements_chain" + table_type: + } + } + hidden: True type: { - name: "elements_chain" - table_type: + alias: "elements_chain" + type: } }, { - chain: [ - "created_at" - ] + alias: "created_at" + expr: { + chain: [ + "created_at" + ] + type: { + name: "created_at" + table_type: + } + } + hidden: True type: { - name: "created_at" - table_type: + alias: "created_at" + type: } }, { - chain: [ - "$session_id" - ] + alias: "$session_id" + expr: { + chain: [ + "$session_id" + ] + type: { + name: "$session_id" + table_type: + } + } + hidden: True type: { - name: "$session_id" - table_type: + alias: "$session_id" + type: } }, { - chain: [ - "$group_0" - ] + alias: "$group_0" + expr: { + chain: [ + "$group_0" + ] + type: { + name: "$group_0" + table_type: + } + } + hidden: True type: { - name: "$group_0" - table_type: + alias: "$group_0" + type: } }, { - chain: [ - "$group_1" - ] + alias: "$group_1" + expr: { + chain: [ + "$group_1" + ] + type: { + name: "$group_1" + table_type: + } + } + hidden: True type: { - name: "$group_1" - table_type: + alias: "$group_1" + type: } }, { - chain: [ - "$group_2" - ] + alias: "$group_2" + expr: { + chain: [ + "$group_2" + ] + type: { + name: "$group_2" + table_type: + } + } + hidden: True type: { - name: "$group_2" - table_type: + alias: "$group_2" + type: } }, { - chain: [ - "$group_3" - ] + alias: "$group_3" + expr: { + chain: [ + "$group_3" + ] + type: { + name: "$group_3" + table_type: + } + } + hidden: True type: { - name: "$group_3" - table_type: + alias: "$group_3" + type: } }, { - chain: [ - "$group_4" - ] + alias: "$group_4" + expr: { + chain: [ + "$group_4" + ] + type: { + name: "$group_4" + table_type: + } + } + hidden: True type: { - name: "$group_4" - table_type: + alias: "$group_4" + type: } } ] @@ -221,81 +364,146 @@ table: { select: [ { - chain: [ - "uuid" - ] + alias: "uuid" + expr: { + chain: [ + "uuid" + ] + type: + } + hidden: True type: }, { - chain: [ - "event" - ] + alias: "event" + expr: { + chain: [ + "event" + ] + type: + } + hidden: True type: }, { - chain: [ - "properties" - ] + alias: "properties" + expr: { + chain: [ + "properties" + ] + type: + } + hidden: True type: }, { - chain: [ - "timestamp" - ] + alias: "timestamp" + expr: { + chain: [ + "timestamp" + ] + type: + } + hidden: True type: }, { - chain: [ - "distinct_id" - ] + alias: "distinct_id" + expr: { + chain: [ + "distinct_id" + ] + type: + } + hidden: True type: }, { - chain: [ - "elements_chain" - ] + alias: "elements_chain" + expr: { + chain: [ + "elements_chain" + ] + type: + } + hidden: True type: }, { - chain: [ - "created_at" - ] + alias: "created_at" + expr: { + chain: [ + "created_at" + ] + type: + } + hidden: True type: }, { - chain: [ - "$session_id" - ] + alias: "$session_id" + expr: { + chain: [ + "$session_id" + ] + type: + } + hidden: True type: }, { - chain: [ - "$group_0" - ] + alias: "$group_0" + expr: { + chain: [ + "$group_0" + ] + type: + } + hidden: True type: }, { - chain: [ - "$group_1" - ] + alias: "$group_1" + expr: { + chain: [ + "$group_1" + ] + type: + } + hidden: True type: }, { - chain: [ - "$group_2" - ] + alias: "$group_2" + expr: { + chain: [ + "$group_2" + ] + type: + } + hidden: True type: }, { - chain: [ - "$group_3" - ] + alias: "$group_3" + expr: { + chain: [ + "$group_3" + ] + type: + } + hidden: True type: }, { - chain: [ - "$group_4" - ] + alias: "$group_4" + expr: { + chain: [ + "$group_4" + ] + type: + } + hidden: True type: } ] @@ -340,119 +548,23 @@ --- # name: TestResolver.test_asterisk_expander_select_union ' - { - select: [ - { - chain: [ - "uuid" - ] - type: { - name: "uuid" - table_type: { - types: [ - { - aliases: {} - anonymous_tables: [] - columns: { - $group_0: { - name: "$group_0" - table_type: { - table: { - fields: { - $group_0: {}, - $group_1: {}, - $group_2: {}, - $group_3: {}, - $group_4: {}, - $session_id: {}, - created_at: {}, - distinct_id: {}, - elements_chain: {}, - event: {}, - goe_0: {}, - goe_1: {}, - goe_2: {}, - goe_3: {}, - goe_4: {}, - group_0: {}, - group_1: {}, - group_2: {}, - group_3: {}, - group_4: {}, - override: {}, - override_person_id: {}, - pdi: {}, - person: {}, - person_id: {}, - poe: {}, - properties: {}, - session: {}, - team_id: {}, - timestamp: {}, - uuid: {} - } - } - } - }, - $group_1: { - name: "$group_1" - table_type: - }, - $group_2: { - name: "$group_2" - table_type: - }, - $group_3: { - name: "$group_3" - table_type: - }, - $group_4: { - name: "$group_4" - table_type: - }, - $session_id: { - name: "$session_id" - table_type: - }, - created_at: { - name: "created_at" - table_type: - }, - distinct_id: { - name: "distinct_id" - table_type: - }, - elements_chain: { - name: "elements_chain" - table_type: - }, - event: { - name: "event" - table_type: - }, - properties: { - name: "properties" - table_type: - }, - timestamp: { - name: "timestamp" - table_type: - }, - uuid: { - name: "uuid" - table_type: - } - } - ctes: {} - tables: { - events: - } - }, - { - aliases: {} - anonymous_tables: [] - columns: { - $group_0: { + { + select: [ + { + alias: "uuid" + expr: { + chain: [ + "uuid" + ] + type: { + name: "uuid" + table_type: { + aliases: {} + anonymous_tables: [] + columns: { + $group_0: { + alias: "$group_0" + type: { name: "$group_0" table_type: { table: { @@ -491,171 +603,308 @@ } } } - }, - $group_1: { + } + }, + $group_1: { + alias: "$group_1" + type: { name: "$group_1" table_type: - }, - $group_2: { + } + }, + $group_2: { + alias: "$group_2" + type: { name: "$group_2" table_type: - }, - $group_3: { + } + }, + $group_3: { + alias: "$group_3" + type: { name: "$group_3" table_type: - }, - $group_4: { + } + }, + $group_4: { + alias: "$group_4" + type: { name: "$group_4" table_type: - }, - $session_id: { + } + }, + $session_id: { + alias: "$session_id" + type: { name: "$session_id" table_type: - }, - created_at: { + } + }, + created_at: { + alias: "created_at" + type: { name: "created_at" table_type: - }, - distinct_id: { + } + }, + distinct_id: { + alias: "distinct_id" + type: { name: "distinct_id" table_type: - }, - elements_chain: { + } + }, + elements_chain: { + alias: "elements_chain" + type: { name: "elements_chain" table_type: - }, - event: { + } + }, + event: { + alias: "event" + type: { name: "event" table_type: - }, - properties: { + } + }, + properties: { + alias: "properties" + type: { name: "properties" table_type: - }, - timestamp: { + } + }, + timestamp: { + alias: "timestamp" + type: { name: "timestamp" table_type: - }, - uuid: { + } + }, + uuid: { + alias: "uuid" + type: { name: "uuid" table_type: } } - ctes: {} - tables: { - events: - } } - ] + ctes: {} + tables: { + events: + } + } } } + hidden: True + type: { + alias: "uuid" + type: + } }, { - chain: [ - "event" - ] + alias: "event" + expr: { + chain: [ + "event" + ] + type: { + name: "event" + table_type: + } + } + hidden: True type: { - name: "event" - table_type: + alias: "event" + type: } }, { - chain: [ - "properties" - ] + alias: "properties" + expr: { + chain: [ + "properties" + ] + type: { + name: "properties" + table_type: + } + } + hidden: True type: { - name: "properties" - table_type: + alias: "properties" + type: } }, { - chain: [ - "timestamp" - ] + alias: "timestamp" + expr: { + chain: [ + "timestamp" + ] + type: { + name: "timestamp" + table_type: + } + } + hidden: True type: { - name: "timestamp" - table_type: + alias: "timestamp" + type: } }, { - chain: [ - "distinct_id" - ] + alias: "distinct_id" + expr: { + chain: [ + "distinct_id" + ] + type: { + name: "distinct_id" + table_type: + } + } + hidden: True type: { - name: "distinct_id" - table_type: + alias: "distinct_id" + type: } }, { - chain: [ - "elements_chain" - ] + alias: "elements_chain" + expr: { + chain: [ + "elements_chain" + ] + type: { + name: "elements_chain" + table_type: + } + } + hidden: True type: { - name: "elements_chain" - table_type: + alias: "elements_chain" + type: } }, { - chain: [ - "created_at" - ] + alias: "created_at" + expr: { + chain: [ + "created_at" + ] + type: { + name: "created_at" + table_type: + } + } + hidden: True type: { - name: "created_at" - table_type: + alias: "created_at" + type: } }, { - chain: [ - "$session_id" - ] + alias: "$session_id" + expr: { + chain: [ + "$session_id" + ] + type: { + name: "$session_id" + table_type: + } + } + hidden: True type: { - name: "$session_id" - table_type: + alias: "$session_id" + type: } }, { - chain: [ - "$group_0" - ] + alias: "$group_0" + expr: { + chain: [ + "$group_0" + ] + type: { + name: "$group_0" + table_type: + } + } + hidden: True type: { - name: "$group_0" - table_type: + alias: "$group_0" + type: } }, { - chain: [ - "$group_1" - ] + alias: "$group_1" + expr: { + chain: [ + "$group_1" + ] + type: { + name: "$group_1" + table_type: + } + } + hidden: True type: { - name: "$group_1" - table_type: + alias: "$group_1" + type: } }, { - chain: [ - "$group_2" - ] + alias: "$group_2" + expr: { + chain: [ + "$group_2" + ] + type: { + name: "$group_2" + table_type: + } + } + hidden: True type: { - name: "$group_2" - table_type: + alias: "$group_2" + type: } }, { - chain: [ - "$group_3" - ] + alias: "$group_3" + expr: { + chain: [ + "$group_3" + ] + type: { + name: "$group_3" + table_type: + } + } + hidden: True type: { - name: "$group_3" - table_type: + alias: "$group_3" + type: } }, { - chain: [ - "$group_4" - ] + alias: "$group_4" + expr: { + chain: [ + "$group_4" + ] + type: { + name: "$group_4" + table_type: + } + } + hidden: True type: { - name: "$group_4" - table_type: + alias: "$group_4" + type: } } ] @@ -665,81 +914,146 @@ { select: [ { - chain: [ - "uuid" - ] + alias: "uuid" + expr: { + chain: [ + "uuid" + ] + type: + } + hidden: True type: }, { - chain: [ - "event" - ] + alias: "event" + expr: { + chain: [ + "event" + ] + type: + } + hidden: True type: }, { - chain: [ - "properties" - ] + alias: "properties" + expr: { + chain: [ + "properties" + ] + type: + } + hidden: True type: }, { - chain: [ - "timestamp" - ] + alias: "timestamp" + expr: { + chain: [ + "timestamp" + ] + type: + } + hidden: True type: }, { - chain: [ - "distinct_id" - ] + alias: "distinct_id" + expr: { + chain: [ + "distinct_id" + ] + type: + } + hidden: True type: }, { - chain: [ - "elements_chain" - ] + alias: "elements_chain" + expr: { + chain: [ + "elements_chain" + ] + type: + } + hidden: True type: }, { - chain: [ - "created_at" - ] + alias: "created_at" + expr: { + chain: [ + "created_at" + ] + type: + } + hidden: True type: }, { - chain: [ - "$session_id" - ] + alias: "$session_id" + expr: { + chain: [ + "$session_id" + ] + type: + } + hidden: True type: }, { - chain: [ - "$group_0" - ] + alias: "$group_0" + expr: { + chain: [ + "$group_0" + ] + type: + } + hidden: True type: }, { - chain: [ - "$group_1" - ] + alias: "$group_1" + expr: { + chain: [ + "$group_1" + ] + type: + } + hidden: True type: }, { - chain: [ - "$group_2" - ] + alias: "$group_2" + expr: { + chain: [ + "$group_2" + ] + type: + } + hidden: True type: }, { - chain: [ - "$group_3" - ] + alias: "$group_3" + expr: { + chain: [ + "$group_3" + ] + type: + } + hidden: True type: }, { - chain: [ - "$group_4" - ] + alias: "$group_4" + expr: { + chain: [ + "$group_4" + ] + type: + } + hidden: True type: } ] @@ -757,82 +1071,261 @@ { select: [ { - chain: [ - "uuid" - ] - type: + alias: "uuid" + expr: { + chain: [ + "uuid" + ] + type: { + name: "uuid" + table_type: { + table: { + fields: { + $group_0: {}, + $group_1: {}, + $group_2: {}, + $group_3: {}, + $group_4: {}, + $session_id: {}, + created_at: {}, + distinct_id: {}, + elements_chain: {}, + event: {}, + goe_0: {}, + goe_1: {}, + goe_2: {}, + goe_3: {}, + goe_4: {}, + group_0: {}, + group_1: {}, + group_2: {}, + group_3: {}, + group_4: {}, + override: {}, + override_person_id: {}, + pdi: {}, + person: {}, + person_id: {}, + poe: {}, + properties: {}, + session: {}, + team_id: {}, + timestamp: {}, + uuid: {} + } + } + } + } + } + hidden: True + type: { + alias: "uuid" + type: + } }, { - chain: [ - "event" - ] - type: + alias: "event" + expr: { + chain: [ + "event" + ] + type: { + name: "event" + table_type: + } + } + hidden: True + type: { + alias: "event" + type: + } }, { - chain: [ - "properties" - ] - type: + alias: "properties" + expr: { + chain: [ + "properties" + ] + type: { + name: "properties" + table_type: + } + } + hidden: True + type: { + alias: "properties" + type: + } }, { - chain: [ - "timestamp" - ] - type: + alias: "timestamp" + expr: { + chain: [ + "timestamp" + ] + type: { + name: "timestamp" + table_type: + } + } + hidden: True + type: { + alias: "timestamp" + type: + } }, { - chain: [ - "distinct_id" - ] - type: + alias: "distinct_id" + expr: { + chain: [ + "distinct_id" + ] + type: { + name: "distinct_id" + table_type: + } + } + hidden: True + type: { + alias: "distinct_id" + type: + } }, { - chain: [ - "elements_chain" - ] - type: + alias: "elements_chain" + expr: { + chain: [ + "elements_chain" + ] + type: { + name: "elements_chain" + table_type: + } + } + hidden: True + type: { + alias: "elements_chain" + type: + } }, { - chain: [ - "created_at" - ] - type: + alias: "created_at" + expr: { + chain: [ + "created_at" + ] + type: { + name: "created_at" + table_type: + } + } + hidden: True + type: { + alias: "created_at" + type: + } }, { - chain: [ - "$session_id" - ] - type: + alias: "$session_id" + expr: { + chain: [ + "$session_id" + ] + type: { + name: "$session_id" + table_type: + } + } + hidden: True + type: { + alias: "$session_id" + type: + } }, { - chain: [ - "$group_0" - ] - type: + alias: "$group_0" + expr: { + chain: [ + "$group_0" + ] + type: { + name: "$group_0" + table_type: + } + } + hidden: True + type: { + alias: "$group_0" + type: + } }, { - chain: [ - "$group_1" - ] - type: + alias: "$group_1" + expr: { + chain: [ + "$group_1" + ] + type: { + name: "$group_1" + table_type: + } + } + hidden: True + type: { + alias: "$group_1" + type: + } }, { - chain: [ - "$group_2" - ] - type: + alias: "$group_2" + expr: { + chain: [ + "$group_2" + ] + type: { + name: "$group_2" + table_type: + } + } + hidden: True + type: { + alias: "$group_2" + type: + } }, { - chain: [ - "$group_3" - ] - type: + alias: "$group_3" + expr: { + chain: [ + "$group_3" + ] + type: { + name: "$group_3" + table_type: + } + } + hidden: True + type: { + alias: "$group_3" + type: + } }, { - chain: [ - "$group_4" - ] - type: + alias: "$group_4" + expr: { + chain: [ + "$group_4" + ] + type: { + name: "$group_4" + table_type: + } + } + hidden: True + type: { + alias: "$group_4" + type: + } } ] select_from: { @@ -844,10 +1337,37 @@ } type: } - type: + type: { + aliases: {} + anonymous_tables: [] + columns: { + $group_0: , + $group_1: , + $group_2: , + $group_3: , + $group_4: , + $session_id: , + created_at: , + distinct_id: , + elements_chain: , + event: , + properties: , + timestamp: , + uuid: + } + ctes: {} + tables: { + events: + } + } } ] - type: + type: { + types: [ + , + + ] + } } type: } @@ -882,43 +1402,59 @@ { select: [ { - chain: [ - "a" - ] - type: { - name: "a" - table_type: { - aliases: { - a: { - alias: "a" - type: { - data_type: "int" - } - }, - b: { - alias: "b" - type: { - data_type: "int" + alias: "a" + expr: { + chain: [ + "a" + ] + type: { + name: "a" + table_type: { + aliases: { + a: { + alias: "a" + type: { + data_type: "int" + } + }, + b: { + alias: "b" + type: { + data_type: "int" + } } } + anonymous_tables: [] + columns: { + a: , + b: + } + ctes: {} + tables: {} } - anonymous_tables: [] - columns: { - a: , - b: - } - ctes: {} - tables: {} } } + hidden: True + type: { + alias: "a" + type: + } }, { - chain: [ - "b" - ] + alias: "b" + expr: { + chain: [ + "b" + ] + type: { + name: "b" + table_type: + } + } + hidden: True type: { - name: "b" - table_type: + alias: "b" + type: } } ] @@ -931,6 +1467,7 @@ type: value: 1 } + hidden: False type: }, { @@ -939,6 +1476,7 @@ type: value: 2 } + hidden: False type: } ] @@ -966,46 +1504,62 @@ { select: [ { - chain: [ - "a" - ] - type: { - name: "a" - table_type: { - alias: "x" - select_query_type: { - aliases: { - a: { - alias: "a" - type: { - data_type: "int" - } - }, - b: { - alias: "b" - type: { - data_type: "int" + alias: "a" + expr: { + chain: [ + "a" + ] + type: { + name: "a" + table_type: { + alias: "x" + select_query_type: { + aliases: { + a: { + alias: "a" + type: { + data_type: "int" + } + }, + b: { + alias: "b" + type: { + data_type: "int" + } } } + anonymous_tables: [] + columns: { + a: , + b: + } + ctes: {} + tables: {} } - anonymous_tables: [] - columns: { - a: , - b: - } - ctes: {} - tables: {} } } } + hidden: True + type: { + alias: "a" + type: + } }, { - chain: [ - "b" - ] + alias: "b" + expr: { + chain: [ + "b" + ] + type: { + name: "b" + table_type: + } + } + hidden: True type: { - name: "b" - table_type: + alias: "b" + type: } } ] @@ -1019,6 +1573,7 @@ type: value: 1 } + hidden: False type: }, { @@ -1027,6 +1582,7 @@ type: value: 2 } + hidden: False type: } ] @@ -1053,157 +1609,261 @@ ' { select: [ - { - chain: [ - "uuid" - ] - type: { - name: "uuid" - table_type: { - table: { - fields: { - $group_0: {}, - $group_1: {}, - $group_2: {}, - $group_3: {}, - $group_4: {}, - $session_id: {}, - created_at: {}, - distinct_id: {}, - elements_chain: {}, - event: {}, - goe_0: {}, - goe_1: {}, - goe_2: {}, - goe_3: {}, - goe_4: {}, - group_0: {}, - group_1: {}, - group_2: {}, - group_3: {}, - group_4: {}, - override: {}, - override_person_id: {}, - pdi: {}, - person: {}, - person_id: {}, - poe: {}, - properties: {}, - session: {}, - team_id: {}, - timestamp: {}, - uuid: {} + { + alias: "uuid" + expr: { + chain: [ + "uuid" + ] + type: { + name: "uuid" + table_type: { + table: { + fields: { + $group_0: {}, + $group_1: {}, + $group_2: {}, + $group_3: {}, + $group_4: {}, + $session_id: {}, + created_at: {}, + distinct_id: {}, + elements_chain: {}, + event: {}, + goe_0: {}, + goe_1: {}, + goe_2: {}, + goe_3: {}, + goe_4: {}, + group_0: {}, + group_1: {}, + group_2: {}, + group_3: {}, + group_4: {}, + override: {}, + override_person_id: {}, + pdi: {}, + person: {}, + person_id: {}, + poe: {}, + properties: {}, + session: {}, + team_id: {}, + timestamp: {}, + uuid: {} + } } } } } + hidden: True + type: { + alias: "uuid" + type: + } }, { - chain: [ - "event" - ] + alias: "event" + expr: { + chain: [ + "event" + ] + type: { + name: "event" + table_type: + } + } + hidden: True type: { - name: "event" - table_type: + alias: "event" + type: } }, { - chain: [ - "properties" - ] + alias: "properties" + expr: { + chain: [ + "properties" + ] + type: { + name: "properties" + table_type: + } + } + hidden: True type: { - name: "properties" - table_type: + alias: "properties" + type: } }, { - chain: [ - "timestamp" - ] + alias: "timestamp" + expr: { + chain: [ + "timestamp" + ] + type: { + name: "timestamp" + table_type: + } + } + hidden: True type: { - name: "timestamp" - table_type: + alias: "timestamp" + type: } }, { - chain: [ - "distinct_id" - ] + alias: "distinct_id" + expr: { + chain: [ + "distinct_id" + ] + type: { + name: "distinct_id" + table_type: + } + } + hidden: True type: { - name: "distinct_id" - table_type: + alias: "distinct_id" + type: } }, { - chain: [ - "elements_chain" - ] + alias: "elements_chain" + expr: { + chain: [ + "elements_chain" + ] + type: { + name: "elements_chain" + table_type: + } + } + hidden: True type: { - name: "elements_chain" - table_type: + alias: "elements_chain" + type: } }, { - chain: [ - "created_at" - ] + alias: "created_at" + expr: { + chain: [ + "created_at" + ] + type: { + name: "created_at" + table_type: + } + } + hidden: True type: { - name: "created_at" - table_type: + alias: "created_at" + type: } }, { - chain: [ - "$session_id" - ] + alias: "$session_id" + expr: { + chain: [ + "$session_id" + ] + type: { + name: "$session_id" + table_type: + } + } + hidden: True type: { - name: "$session_id" - table_type: + alias: "$session_id" + type: } }, { - chain: [ - "$group_0" - ] + alias: "$group_0" + expr: { + chain: [ + "$group_0" + ] + type: { + name: "$group_0" + table_type: + } + } + hidden: True type: { - name: "$group_0" - table_type: + alias: "$group_0" + type: } }, { - chain: [ - "$group_1" - ] + alias: "$group_1" + expr: { + chain: [ + "$group_1" + ] + type: { + name: "$group_1" + table_type: + } + } + hidden: True type: { - name: "$group_1" - table_type: + alias: "$group_1" + type: } }, { - chain: [ - "$group_2" - ] + alias: "$group_2" + expr: { + chain: [ + "$group_2" + ] + type: { + name: "$group_2" + table_type: + } + } + hidden: True type: { - name: "$group_2" - table_type: + alias: "$group_2" + type: } }, { - chain: [ - "$group_3" - ] + alias: "$group_3" + expr: { + chain: [ + "$group_3" + ] + type: { + name: "$group_3" + table_type: + } + } + hidden: True type: { - name: "$group_3" - table_type: + alias: "$group_3" + type: } }, { - chain: [ - "$group_4" - ] + alias: "$group_4" + expr: { + chain: [ + "$group_4" + ] + type: { + name: "$group_4" + table_type: + } + } + hidden: True type: { - name: "$group_4" - table_type: + alias: "$group_4" + type: } } ] @@ -1247,159 +1907,263 @@ { select: [ { - chain: [ - "uuid" - ] - type: { - name: "uuid" - table_type: { - alias: "e" + alias: "uuid" + expr: { + chain: [ + "uuid" + ] + type: { + name: "uuid" table_type: { - table: { - fields: { - $group_0: {}, - $group_1: {}, - $group_2: {}, - $group_3: {}, - $group_4: {}, - $session_id: {}, - created_at: {}, - distinct_id: {}, - elements_chain: {}, - event: {}, - goe_0: {}, - goe_1: {}, - goe_2: {}, - goe_3: {}, - goe_4: {}, - group_0: {}, - group_1: {}, - group_2: {}, - group_3: {}, - group_4: {}, - override: {}, - override_person_id: {}, - pdi: {}, - person: {}, - person_id: {}, - poe: {}, - properties: {}, - session: {}, - team_id: {}, - timestamp: {}, - uuid: {} + alias: "e" + table_type: { + table: { + fields: { + $group_0: {}, + $group_1: {}, + $group_2: {}, + $group_3: {}, + $group_4: {}, + $session_id: {}, + created_at: {}, + distinct_id: {}, + elements_chain: {}, + event: {}, + goe_0: {}, + goe_1: {}, + goe_2: {}, + goe_3: {}, + goe_4: {}, + group_0: {}, + group_1: {}, + group_2: {}, + group_3: {}, + group_4: {}, + override: {}, + override_person_id: {}, + pdi: {}, + person: {}, + person_id: {}, + poe: {}, + properties: {}, + session: {}, + team_id: {}, + timestamp: {}, + uuid: {} + } } } } } } + hidden: True + type: { + alias: "uuid" + type: + } }, { - chain: [ - "event" - ] + alias: "event" + expr: { + chain: [ + "event" + ] + type: { + name: "event" + table_type: + } + } + hidden: True type: { - name: "event" - table_type: + alias: "event" + type: } }, { - chain: [ - "properties" - ] + alias: "properties" + expr: { + chain: [ + "properties" + ] + type: { + name: "properties" + table_type: + } + } + hidden: True type: { - name: "properties" - table_type: + alias: "properties" + type: } }, { - chain: [ - "timestamp" - ] + alias: "timestamp" + expr: { + chain: [ + "timestamp" + ] + type: { + name: "timestamp" + table_type: + } + } + hidden: True type: { - name: "timestamp" - table_type: + alias: "timestamp" + type: } }, { - chain: [ - "distinct_id" - ] + alias: "distinct_id" + expr: { + chain: [ + "distinct_id" + ] + type: { + name: "distinct_id" + table_type: + } + } + hidden: True type: { - name: "distinct_id" - table_type: + alias: "distinct_id" + type: } }, { - chain: [ - "elements_chain" - ] + alias: "elements_chain" + expr: { + chain: [ + "elements_chain" + ] + type: { + name: "elements_chain" + table_type: + } + } + hidden: True type: { - name: "elements_chain" - table_type: + alias: "elements_chain" + type: } }, { - chain: [ - "created_at" - ] + alias: "created_at" + expr: { + chain: [ + "created_at" + ] + type: { + name: "created_at" + table_type: + } + } + hidden: True type: { - name: "created_at" - table_type: + alias: "created_at" + type: } }, { - chain: [ - "$session_id" - ] + alias: "$session_id" + expr: { + chain: [ + "$session_id" + ] + type: { + name: "$session_id" + table_type: + } + } + hidden: True type: { - name: "$session_id" - table_type: + alias: "$session_id" + type: } }, { - chain: [ - "$group_0" - ] + alias: "$group_0" + expr: { + chain: [ + "$group_0" + ] + type: { + name: "$group_0" + table_type: + } + } + hidden: True type: { - name: "$group_0" - table_type: + alias: "$group_0" + type: } }, { - chain: [ - "$group_1" - ] + alias: "$group_1" + expr: { + chain: [ + "$group_1" + ] + type: { + name: "$group_1" + table_type: + } + } + hidden: True type: { - name: "$group_1" - table_type: + alias: "$group_1" + type: } }, { - chain: [ - "$group_2" - ] + alias: "$group_2" + expr: { + chain: [ + "$group_2" + ] + type: { + name: "$group_2" + table_type: + } + } + hidden: True type: { - name: "$group_2" - table_type: + alias: "$group_2" + type: } }, { - chain: [ - "$group_3" - ] + alias: "$group_3" + expr: { + chain: [ + "$group_3" + ] + type: { + name: "$group_3" + table_type: + } + } + hidden: True type: { - name: "$group_3" - table_type: + alias: "$group_3" + type: } }, { - chain: [ - "$group_4" - ] + alias: "$group_4" + expr: { + chain: [ + "$group_4" + ] + type: { + name: "$group_4" + table_type: + } + } + hidden: True type: { - name: "$group_4" - table_type: + alias: "$group_4" + type: } } ] @@ -1446,49 +2210,57 @@ { args: [ { - chain: [ - "timestamp" - ] - type: { - name: "timestamp" - table_type: { - table: { - fields: { - $group_0: {}, - $group_1: {}, - $group_2: {}, - $group_3: {}, - $group_4: {}, - $session_id: {}, - created_at: {}, - distinct_id: {}, - elements_chain: {}, - event: {}, - goe_0: {}, - goe_1: {}, - goe_2: {}, - goe_3: {}, - goe_4: {}, - group_0: {}, - group_1: {}, - group_2: {}, - group_3: {}, - group_4: {}, - override: {}, - override_person_id: {}, - pdi: {}, - person: {}, - person_id: {}, - poe: {}, - properties: {}, - session: {}, - team_id: {}, - timestamp: {}, - uuid: {} + alias: "timestamp" + expr: { + chain: [ + "timestamp" + ] + type: { + name: "timestamp" + table_type: { + table: { + fields: { + $group_0: {}, + $group_1: {}, + $group_2: {}, + $group_3: {}, + $group_4: {}, + $session_id: {}, + created_at: {}, + distinct_id: {}, + elements_chain: {}, + event: {}, + goe_0: {}, + goe_1: {}, + goe_2: {}, + goe_3: {}, + goe_4: {}, + group_0: {}, + group_1: {}, + group_2: {}, + group_3: {}, + group_4: {}, + override: {}, + override_person_id: {}, + pdi: {}, + person: {}, + person_id: {}, + poe: {}, + properties: {}, + session: {}, + team_id: {}, + timestamp: {}, + uuid: {} + } } } } } + hidden: True + type: { + alias: "timestamp" + type: + } } ] distinct: False @@ -1678,137 +2450,31 @@ } ] } - value: (1, 2, 3) - } - ] - type: { - aliases: {} - anonymous_tables: [] - columns: {} - ctes: {} - tables: {} - } - } - ' ---- -# name: TestResolver.test_resolve_events_table - ' - { - select: [ - { - chain: [ - "event" - ] - type: { - name: "event" - table_type: { - table: { - fields: { - $group_0: {}, - $group_1: {}, - $group_2: {}, - $group_3: {}, - $group_4: {}, - $session_id: {}, - created_at: {}, - distinct_id: {}, - elements_chain: {}, - event: {}, - goe_0: {}, - goe_1: {}, - goe_2: {}, - goe_3: {}, - goe_4: {}, - group_0: {}, - group_1: {}, - group_2: {}, - group_3: {}, - group_4: {}, - override: {}, - override_person_id: {}, - pdi: {}, - person: {}, - person_id: {}, - poe: {}, - properties: {}, - session: {}, - team_id: {}, - timestamp: {}, - uuid: {} - } - } - } - } - }, - { - chain: [ - "events", - "timestamp" - ] - type: { - name: "timestamp" - table_type: - } - } - ] - select_from: { - table: { - chain: [ - "events" - ] - type: - } - type: - } - type: { - aliases: {} - anonymous_tables: [] - columns: { - event: , - timestamp: - } - ctes: {} - tables: { - events: - } - } - where: { - left: { - chain: [ - "events", - "event" - ] - type: { - name: "event" - table_type: - } - } - op: "==" - right: { - type: { - data_type: "str" - } - value: "test" - } - type: { - data_type: "bool" + value: (1, 2, 3) } + ] + type: { + aliases: {} + anonymous_tables: [] + columns: {} + ctes: {} + tables: {} } } ' --- -# name: TestResolver.test_resolve_events_table_alias +# name: TestResolver.test_resolve_events_table ' { select: [ { - chain: [ - "event" - ] - type: { - name: "event" - table_type: { - alias: "e" + alias: "event" + expr: { + chain: [ + "event" + ] + type: { + name: "event" table_type: { table: { fields: { @@ -1848,20 +2514,32 @@ } } } + hidden: True + type: { + alias: "event" + type: + } }, { - chain: [ - "e", - "timestamp" - ] + alias: "timestamp" + expr: { + chain: [ + "events", + "timestamp" + ] + type: { + name: "timestamp" + table_type: + } + } + hidden: True type: { - name: "timestamp" - table_type: + alias: "timestamp" + type: } } ] select_from: { - alias: "e" table: { chain: [ "events" @@ -1879,18 +2557,26 @@ } ctes: {} tables: { - e: + events: } } where: { left: { - chain: [ - "e", - "event" - ] + alias: "event" + expr: { + chain: [ + "events", + "event" + ] + type: { + name: "event" + table_type: + } + } + hidden: True type: { - name: "event" - table_type: + alias: "event" + type: } } op: "==" @@ -1907,12 +2593,12 @@ } ' --- -# name: TestResolver.test_resolve_events_table_column_alias +# name: TestResolver.test_resolve_events_table_alias ' { select: [ { - alias: "ee" + alias: "event" expr: { chain: [ "event" @@ -1961,39 +2647,29 @@ } } } + hidden: True type: { - alias: "ee" + alias: "event" type: } }, { - chain: [ - "ee" - ] - type: - }, - { - alias: "e" + alias: "timestamp" expr: { chain: [ - "ee" + "e", + "timestamp" ] - type: + type: { + name: "timestamp" + table_type: + } } + hidden: True type: { - alias: "e" + alias: "timestamp" type: } - }, - { - chain: [ - "e", - "timestamp" - ] - type: { - name: "timestamp" - table_type: - } } ] select_from: { @@ -2007,14 +2683,10 @@ type: } type: { - aliases: { - e: , - ee: - } + aliases: {} anonymous_tables: [] columns: { - e: , - ee: , + event: , timestamp: } ctes: {} @@ -2024,13 +2696,21 @@ } where: { left: { - chain: [ - "e", - "event" - ] + alias: "event" + expr: { + chain: [ + "e", + "event" + ] + type: { + name: "event" + table_type: + } + } + hidden: True type: { - name: "event" - table_type: + alias: "event" + type: } } op: "==" @@ -2047,83 +2727,263 @@ } ' --- -# name: TestResolver.test_resolve_events_table_column_alias_inside_subquery +# name: TestResolver.test_resolve_events_table_column_alias ' { select: [ + { + alias: "ee" + expr: { + alias: "event" + expr: { + chain: [ + "event" + ] + type: { + name: "event" + table_type: { + alias: "e" + table_type: { + table: { + fields: { + $group_0: {}, + $group_1: {}, + $group_2: {}, + $group_3: {}, + $group_4: {}, + $session_id: {}, + created_at: {}, + distinct_id: {}, + elements_chain: {}, + event: {}, + goe_0: {}, + goe_1: {}, + goe_2: {}, + goe_3: {}, + goe_4: {}, + group_0: {}, + group_1: {}, + group_2: {}, + group_3: {}, + group_4: {}, + override: {}, + override_person_id: {}, + pdi: {}, + person: {}, + person_id: {}, + poe: {}, + properties: {}, + session: {}, + team_id: {}, + timestamp: {}, + uuid: {} + } + } + } + } + } + } + hidden: True + type: { + alias: "event" + type: + } + } + hidden: False + type: { + alias: "ee" + type: + } + }, { chain: [ - "b" + "ee" ] + type: + }, + { + alias: "e" + expr: { + chain: [ + "ee" + ] + type: + } + hidden: False type: { - name: "b" - table_type: { - alias: "e" - select_query_type: { - aliases: { - b: { - alias: "b" - type: { - name: "event" - table_type: { - table: { - fields: { - $group_0: {}, - $group_1: {}, - $group_2: {}, - $group_3: {}, - $group_4: {}, - $session_id: {}, - created_at: {}, - distinct_id: {}, - elements_chain: {}, - event: {}, - goe_0: {}, - goe_1: {}, - goe_2: {}, - goe_3: {}, - goe_4: {}, - group_0: {}, - group_1: {}, - group_2: {}, - group_3: {}, - group_4: {}, - override: {}, - override_person_id: {}, - pdi: {}, - person: {}, - person_id: {}, - poe: {}, - properties: {}, - session: {}, - team_id: {}, - timestamp: {}, - uuid: {} + alias: "e" + type: + } + }, + { + alias: "timestamp" + expr: { + chain: [ + "e", + "timestamp" + ] + type: { + name: "timestamp" + table_type: + } + } + hidden: True + type: { + alias: "timestamp" + type: + } + } + ] + select_from: { + alias: "e" + table: { + chain: [ + "events" + ] + type: + } + type: + } + type: { + aliases: { + e: , + ee: + } + anonymous_tables: [] + columns: { + e: , + ee: , + timestamp: + } + ctes: {} + tables: { + e: + } + } + where: { + left: { + alias: "event" + expr: { + chain: [ + "e", + "event" + ] + type: { + name: "event" + table_type: + } + } + hidden: True + type: { + alias: "event" + type: + } + } + op: "==" + right: { + type: { + data_type: "str" + } + value: "test" + } + type: { + data_type: "bool" + } + } + } + ' +--- +# name: TestResolver.test_resolve_events_table_column_alias_inside_subquery + ' + { + select: [ + { + alias: "b" + expr: { + chain: [ + "b" + ] + type: { + name: "b" + table_type: { + alias: "e" + select_query_type: { + aliases: { + b: { + alias: "b" + type: { + alias: "event" + type: { + name: "event" + table_type: { + table: { + fields: { + $group_0: {}, + $group_1: {}, + $group_2: {}, + $group_3: {}, + $group_4: {}, + $session_id: {}, + created_at: {}, + distinct_id: {}, + elements_chain: {}, + event: {}, + goe_0: {}, + goe_1: {}, + goe_2: {}, + goe_3: {}, + goe_4: {}, + group_0: {}, + group_1: {}, + group_2: {}, + group_3: {}, + group_4: {}, + override: {}, + override_person_id: {}, + pdi: {}, + person: {}, + person_id: {}, + poe: {}, + properties: {}, + session: {}, + team_id: {}, + timestamp: {}, + uuid: {} + } + } } } } - } - }, - c: { - alias: "c" - type: { - name: "timestamp" - table_type: + }, + c: { + alias: "c" + type: { + alias: "timestamp" + type: { + name: "timestamp" + table_type: + } + } } } - } - anonymous_tables: [] - columns: { - b: , - c: - } - ctes: {} - tables: { - events: + anonymous_tables: [] + columns: { + b: , + c: + } + ctes: {} + tables: { + events: + } } } } } + hidden: True + type: { + alias: "b" + type: + } } ] select_from: { @@ -2133,21 +2993,33 @@ { alias: "b" expr: { - chain: [ - "event" - ] + alias: "event" + expr: { + chain: [ + "event" + ] + type: + } + hidden: True type: } + hidden: False type: }, { alias: "c" expr: { - chain: [ - "timestamp" - ] + alias: "timestamp" + expr: { + chain: [ + "timestamp" + ] + type: + } + hidden: True type: } + hidden: False type: } ] @@ -2177,13 +3049,21 @@ } where: { left: { - chain: [ - "e", - "b" - ] + alias: "b" + expr: { + chain: [ + "e", + "b" + ] + type: { + name: "b" + table_type: + } + } + hidden: True type: { - name: "b" - table_type: + alias: "b" + type: } } op: "==" @@ -2205,95 +3085,249 @@ { select: [ { - chain: [ - "event" - ] - type: { - name: "event" - table_type: { - table: { - fields: { - $group_0: {}, - $group_1: {}, - $group_2: {}, - $group_3: {}, - $group_4: {}, - $session_id: {}, - created_at: {}, - distinct_id: {}, - elements_chain: {}, - event: {}, - goe_0: {}, - goe_1: {}, - goe_2: {}, - goe_3: {}, - goe_4: {}, - group_0: {}, - group_1: {}, - group_2: {}, - group_3: {}, - group_4: {}, - override: {}, - override_person_id: {}, - pdi: {}, - person: {}, - person_id: {}, - poe: {}, - properties: {}, - session: {}, - team_id: {}, - timestamp: {}, - uuid: {} + alias: "event" + expr: { + chain: [ + "event" + ] + type: { + name: "event" + table_type: { + table: { + fields: { + $group_0: {}, + $group_1: {}, + $group_2: {}, + $group_3: {}, + $group_4: {}, + $session_id: {}, + created_at: {}, + distinct_id: {}, + elements_chain: {}, + event: {}, + goe_0: {}, + goe_1: {}, + goe_2: {}, + goe_3: {}, + goe_4: {}, + group_0: {}, + group_1: {}, + group_2: {}, + group_3: {}, + group_4: {}, + override: {}, + override_person_id: {}, + pdi: {}, + person: {}, + person_id: {}, + poe: {}, + properties: {}, + session: {}, + team_id: {}, + timestamp: {}, + uuid: {} + } } } } } + hidden: True + type: { + alias: "event" + type: + } }, { + alias: "id" + expr: { + chain: [ + "pdi", + "person", + "id" + ] + type: { + name: "id" + table_type: { + field: "person" + lazy_join: { + from_field: "person_id", + join_function: , + join_table: { + fields: { + created_at: {}, + id: {}, + is_identified: {}, + pdi: {}, + properties: {}, + team_id: {} + } + } + } + table_type: { + field: "pdi" + lazy_join: { + from_field: "distinct_id", + join_function: , + join_table: { + fields: { + distinct_id: {}, + person: {}, + person_id: {}, + team_id: {} + } + } + } + table_type: + } + } + } + } + hidden: True + type: { + alias: "id" + type: + } + } + ] + select_from: { + table: { chain: [ - "pdi", - "person", - "id" + "events" ] - type: { - name: "id" - table_type: { - field: "person" - lazy_join: { - from_field: "person_id", - join_function: , - join_table: { - fields: { - created_at: {}, - id: {}, - is_identified: {}, - pdi: {}, - properties: {}, - team_id: {} + type: + } + type: + } + type: { + aliases: {} + anonymous_tables: [] + columns: { + event: , + id: + } + ctes: {} + tables: { + events: + } + } + } + ' +--- +# name: TestResolver.test_resolve_lazy_events_pdi_person_table_aliased + ' + { + select: [ + { + alias: "event" + expr: { + chain: [ + "event" + ] + type: { + name: "event" + table_type: { + alias: "e" + table_type: { + table: { + fields: { + $group_0: {}, + $group_1: {}, + $group_2: {}, + $group_3: {}, + $group_4: {}, + $session_id: {}, + created_at: {}, + distinct_id: {}, + elements_chain: {}, + event: {}, + goe_0: {}, + goe_1: {}, + goe_2: {}, + goe_3: {}, + goe_4: {}, + group_0: {}, + group_1: {}, + group_2: {}, + group_3: {}, + group_4: {}, + override: {}, + override_person_id: {}, + pdi: {}, + person: {}, + person_id: {}, + poe: {}, + properties: {}, + session: {}, + team_id: {}, + timestamp: {}, + uuid: {} + } } } } + } + } + hidden: True + type: { + alias: "event" + type: + } + }, + { + alias: "id" + expr: { + chain: [ + "e", + "pdi", + "person", + "id" + ] + type: { + name: "id" table_type: { - field: "pdi" + field: "person" lazy_join: { - from_field: "distinct_id", + from_field: "person_id", join_function: , join_table: { fields: { - distinct_id: {}, - person: {}, - person_id: {}, + created_at: {}, + id: {}, + is_identified: {}, + pdi: {}, + properties: {}, team_id: {} } } } - table_type: + table_type: { + field: "pdi" + lazy_join: { + from_field: "distinct_id", + join_function: , + join_table: { + fields: { + distinct_id: {}, + person: {}, + person_id: {}, + team_id: {} + } + } + } + table_type: + } } } } + hidden: True + type: { + alias: "id" + type: + } } ] select_from: { + alias: "e" table: { chain: [ "events" @@ -2311,24 +3345,24 @@ } ctes: {} tables: { - events: + e: } } } ' --- -# name: TestResolver.test_resolve_lazy_events_pdi_person_table_aliased +# name: TestResolver.test_resolve_lazy_events_pdi_table ' { select: [ { - chain: [ - "event" - ] - type: { - name: "event" - table_type: { - alias: "e" + alias: "event" + expr: { + chain: [ + "event" + ] + type: { + name: "event" table_type: { table: { fields: { @@ -2368,32 +3402,21 @@ } } } + hidden: True + type: { + alias: "event" + type: + } }, { - chain: [ - "e", - "pdi", - "person", - "id" - ] - type: { - name: "id" - table_type: { - field: "person" - lazy_join: { - from_field: "person_id", - join_function: , - join_table: { - fields: { - created_at: {}, - id: {}, - is_identified: {}, - pdi: {}, - properties: {}, - team_id: {} - } - } - } + alias: "person_id" + expr: { + chain: [ + "pdi", + "person_id" + ] + type: { + name: "person_id" table_type: { field: "pdi" lazy_join: { @@ -2412,105 +3435,10 @@ } } } - } - ] - select_from: { - alias: "e" - table: { - chain: [ - "events" - ] - type: - } - type: - } - type: { - aliases: {} - anonymous_tables: [] - columns: { - event: , - id: - } - ctes: {} - tables: { - e: - } - } - } - ' ---- -# name: TestResolver.test_resolve_lazy_events_pdi_table - ' - { - select: [ - { - chain: [ - "event" - ] - type: { - name: "event" - table_type: { - table: { - fields: { - $group_0: {}, - $group_1: {}, - $group_2: {}, - $group_3: {}, - $group_4: {}, - $session_id: {}, - created_at: {}, - distinct_id: {}, - elements_chain: {}, - event: {}, - goe_0: {}, - goe_1: {}, - goe_2: {}, - goe_3: {}, - goe_4: {}, - group_0: {}, - group_1: {}, - group_2: {}, - group_3: {}, - group_4: {}, - override: {}, - override_person_id: {}, - pdi: {}, - person: {}, - person_id: {}, - poe: {}, - properties: {}, - session: {}, - team_id: {}, - timestamp: {}, - uuid: {} - } - } - } - } - }, - { - chain: [ - "pdi", - "person_id" - ] + hidden: True type: { - name: "person_id" - table_type: { - field: "pdi" - lazy_join: { - from_field: "distinct_id", - join_function: , - join_table: { - fields: { - distinct_id: {}, - person: {}, - person_id: {}, - team_id: {} - } - } - } - table_type: - } + alias: "person_id" + type: } } ] @@ -2543,78 +3471,94 @@ { select: [ { - chain: [ - "event" - ] - type: { - name: "event" - table_type: { - alias: "e" + alias: "event" + expr: { + chain: [ + "event" + ] + type: { + name: "event" table_type: { - table: { - fields: { - $group_0: {}, - $group_1: {}, - $group_2: {}, - $group_3: {}, - $group_4: {}, - $session_id: {}, - created_at: {}, - distinct_id: {}, - elements_chain: {}, - event: {}, - goe_0: {}, - goe_1: {}, - goe_2: {}, - goe_3: {}, - goe_4: {}, - group_0: {}, - group_1: {}, - group_2: {}, - group_3: {}, - group_4: {}, - override: {}, - override_person_id: {}, - pdi: {}, - person: {}, - person_id: {}, - poe: {}, - properties: {}, - session: {}, - team_id: {}, - timestamp: {}, - uuid: {} + alias: "e" + table_type: { + table: { + fields: { + $group_0: {}, + $group_1: {}, + $group_2: {}, + $group_3: {}, + $group_4: {}, + $session_id: {}, + created_at: {}, + distinct_id: {}, + elements_chain: {}, + event: {}, + goe_0: {}, + goe_1: {}, + goe_2: {}, + goe_3: {}, + goe_4: {}, + group_0: {}, + group_1: {}, + group_2: {}, + group_3: {}, + group_4: {}, + override: {}, + override_person_id: {}, + pdi: {}, + person: {}, + person_id: {}, + poe: {}, + properties: {}, + session: {}, + team_id: {}, + timestamp: {}, + uuid: {} + } } } } } } + hidden: True + type: { + alias: "event" + type: + } }, { - chain: [ - "e", - "pdi", - "person_id" - ] - type: { - name: "person_id" - table_type: { - field: "pdi" - lazy_join: { - from_field: "distinct_id", - join_function: , - join_table: { - fields: { - distinct_id: {}, - person: {}, - person_id: {}, - team_id: {} + alias: "person_id" + expr: { + chain: [ + "e", + "pdi", + "person_id" + ] + type: { + name: "person_id" + table_type: { + field: "pdi" + lazy_join: { + from_field: "distinct_id", + join_function: , + join_table: { + fields: { + distinct_id: {}, + person: {}, + person_id: {}, + team_id: {} + } } } + table_type: } - table_type: } } + hidden: True + type: { + alias: "person_id" + type: + } } ] select_from: { @@ -2647,49 +3591,65 @@ { select: [ { - chain: [ - "distinct_id" - ] - type: { - name: "distinct_id" - table_type: { - table: { - fields: { - distinct_id: {}, - person: {}, - person_id: {}, - team_id: {} + alias: "distinct_id" + expr: { + chain: [ + "distinct_id" + ] + type: { + name: "distinct_id" + table_type: { + table: { + fields: { + distinct_id: {}, + person: {}, + person_id: {}, + team_id: {} + } } } } } + hidden: True + type: { + alias: "distinct_id" + type: + } }, { - chain: [ - "person", - "id" - ] - type: { - name: "id" - table_type: { - field: "person" - lazy_join: { - from_field: "person_id", - join_function: , - join_table: { - fields: { - created_at: {}, - id: {}, - is_identified: {}, - pdi: {}, - properties: {}, - team_id: {} + alias: "id" + expr: { + chain: [ + "person", + "id" + ] + type: { + name: "id" + table_type: { + field: "person" + lazy_join: { + from_field: "person_id", + join_function: , + join_table: { + fields: { + created_at: {}, + id: {}, + is_identified: {}, + pdi: {}, + properties: {}, + team_id: {} + } } } + table_type: } - table_type: } } + hidden: True + type: { + alias: "id" + type: + } } ] select_from: { @@ -2723,57 +3683,73 @@ { select: [ { - chain: [ - "event" - ] - type: { - name: "event" - table_type: { - table: { - fields: { - $group_0: {}, - $group_1: {}, - $group_2: {}, - $group_3: {}, - $group_4: {}, - $session_id: {}, - created_at: {}, - distinct_id: {}, - elements_chain: {}, - event: {}, - goe_0: {}, - goe_1: {}, - goe_2: {}, - goe_3: {}, - goe_4: {}, - group_0: {}, - group_1: {}, - group_2: {}, - group_3: {}, - group_4: {}, - override: {}, - override_person_id: {}, - pdi: {}, - person: {}, - person_id: {}, - poe: {}, - properties: {}, - session: {}, - team_id: {}, - timestamp: {}, - uuid: {} + alias: "event" + expr: { + chain: [ + "event" + ] + type: { + name: "event" + table_type: { + table: { + fields: { + $group_0: {}, + $group_1: {}, + $group_2: {}, + $group_3: {}, + $group_4: {}, + $session_id: {}, + created_at: {}, + distinct_id: {}, + elements_chain: {}, + event: {}, + goe_0: {}, + goe_1: {}, + goe_2: {}, + goe_3: {}, + goe_4: {}, + group_0: {}, + group_1: {}, + group_2: {}, + group_3: {}, + group_4: {}, + override: {}, + override_person_id: {}, + pdi: {}, + person: {}, + person_id: {}, + poe: {}, + properties: {}, + session: {}, + team_id: {}, + timestamp: {}, + uuid: {} + } } } } } + hidden: True + type: { + alias: "event" + type: + } }, { - chain: [ - "timestamp" - ] + alias: "timestamp" + expr: { + chain: [ + "timestamp" + ] + type: { + name: "timestamp" + table_type: + } + } + hidden: True type: { - name: "timestamp" - table_type: + alias: "timestamp" + type: } } ] @@ -2802,57 +3778,73 @@ { select: [ { - chain: [ - "event" - ] - type: { - name: "event" - table_type: { - table: { - fields: { - $group_0: {}, - $group_1: {}, - $group_2: {}, - $group_3: {}, - $group_4: {}, - $session_id: {}, - created_at: {}, - distinct_id: {}, - elements_chain: {}, - event: {}, - goe_0: {}, - goe_1: {}, - goe_2: {}, - goe_3: {}, - goe_4: {}, - group_0: {}, - group_1: {}, - group_2: {}, - group_3: {}, - group_4: {}, - override: {}, - override_person_id: {}, - pdi: {}, - person: {}, - person_id: {}, - poe: {}, - properties: {}, - session: {}, - team_id: {}, - timestamp: {}, - uuid: {} + alias: "event" + expr: { + chain: [ + "event" + ] + type: { + name: "event" + table_type: { + table: { + fields: { + $group_0: {}, + $group_1: {}, + $group_2: {}, + $group_3: {}, + $group_4: {}, + $session_id: {}, + created_at: {}, + distinct_id: {}, + elements_chain: {}, + event: {}, + goe_0: {}, + goe_1: {}, + goe_2: {}, + goe_3: {}, + goe_4: {}, + group_0: {}, + group_1: {}, + group_2: {}, + group_3: {}, + group_4: {}, + override: {}, + override_person_id: {}, + pdi: {}, + person: {}, + person_id: {}, + poe: {}, + properties: {}, + session: {}, + team_id: {}, + timestamp: {}, + uuid: {} + } } } } } + hidden: True + type: { + alias: "event" + type: + } }, { - chain: [ - "timestamp" - ] + alias: "timestamp" + expr: { + chain: [ + "timestamp" + ] + type: { + name: "timestamp" + table_type: + } + } + hidden: True type: { - name: "timestamp" - table_type: + alias: "timestamp" + type: } } ] @@ -2893,69 +3885,85 @@ { select: [ { - chain: [ - "event" - ] - type: { - name: "event" - table_type: { - table: { - fields: { - $group_0: {}, - $group_1: {}, - $group_2: {}, - $group_3: {}, - $group_4: {}, - $session_id: {}, - created_at: {}, - distinct_id: {}, - elements_chain: {}, - event: {}, - goe_0: {}, - goe_1: {}, - goe_2: {}, - goe_3: {}, - goe_4: {}, - group_0: {}, - group_1: {}, - group_2: {}, - group_3: {}, - group_4: {}, - override: {}, - override_person_id: {}, - pdi: {}, - person: {}, - person_id: {}, - poe: {}, - properties: {}, - session: {}, - team_id: {}, - timestamp: {}, - uuid: {} + alias: "event" + expr: { + chain: [ + "event" + ] + type: { + name: "event" + table_type: { + table: { + fields: { + $group_0: {}, + $group_1: {}, + $group_2: {}, + $group_3: {}, + $group_4: {}, + $session_id: {}, + created_at: {}, + distinct_id: {}, + elements_chain: {}, + event: {}, + goe_0: {}, + goe_1: {}, + goe_2: {}, + goe_3: {}, + goe_4: {}, + group_0: {}, + group_1: {}, + group_2: {}, + group_3: {}, + group_4: {}, + override: {}, + override_person_id: {}, + pdi: {}, + person: {}, + person_id: {}, + poe: {}, + properties: {}, + session: {}, + team_id: {}, + timestamp: {}, + uuid: {} + } } } } } + hidden: True + type: { + alias: "event" + type: + } }, { - chain: [ - "poe", - "id" - ] - type: { - name: "id" - table_type: { - field: "poe" - table_type: - virtual_table: { - fields: { - created_at: {}, - id: {}, - properties: {} + alias: "id" + expr: { + chain: [ + "poe", + "id" + ] + type: { + name: "id" + table_type: { + field: "poe" + table_type: + virtual_table: { + fields: { + created_at: {}, + id: {}, + properties: {} + } } } } } + hidden: True + type: { + alias: "id" + type: + } } ] select_from: { From 82d342ae148c02fed34a36f228ee79a7f79e7342 Mon Sep 17 00:00:00 2001 From: Marius Andra Date: Wed, 22 Nov 2023 09:53:56 +0100 Subject: [PATCH 15/15] more comments --- posthog/hogql/printer.py | 14 ++++++++++++-- posthog/hogql/resolver.py | 10 +++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/posthog/hogql/printer.py b/posthog/hogql/printer.py index 7f5121ec8fab7..ab588239b012d 100644 --- a/posthog/hogql/printer.py +++ b/posthog/hogql/printer.py @@ -236,8 +236,9 @@ def visit_select_query(self, node: ast.SelectQuery): next_join = next_join.next_join if node.select: + # Only for ClickHouse: Gather all visible aliases, and/or the last hidden alias for + # each unique alias name. Then make the last hidden aliases visible. if self.dialect == "clickhouse": - # Gather all visible aliases. Make visible the last occurrence of each unique hidden alias. visible_aliases = {} for alias in reversed(node.select): if isinstance(alias, ast.Alias): @@ -247,6 +248,7 @@ def visit_select_query(self, node: ast.SelectQuery): columns = [] for column in node.select: if isinstance(column, ast.Alias): + # It's either a visible alias, or the last hidden alias for this name. if visible_aliases.get(column.alias) == column: if column.hidden: if ( @@ -254,12 +256,19 @@ def visit_select_query(self, node: ast.SelectQuery): and isinstance(column.expr.type, ast.FieldType) and column.expr.type.name == column.alias ): - # Unhide if really the same name for the field and the alias + # Hide the hidden alias only if it's a simple field, + # and we're using the same name for the field and the alias + # E.g. events.event AS event --> events.evnet. column = column.expr else: + # Make the hidden alias visible column = cast(ast.Alias, clone_expr(column)) column.hidden = False + else: + # Always print visible aliases. + pass else: + # This is not the alias for this unique alias name. Skip it. column = column.expr columns.append(self.visit(column)) else: @@ -842,6 +851,7 @@ def visit_placeholder(self, node: ast.Placeholder): raise HogQLException(f"Placeholders, such as {{{node.field}}}, are not supported in this context") def visit_alias(self, node: ast.Alias): + # Skip hidden aliases completely. if node.hidden: return self.visit(node.expr) expr = node.expr diff --git a/posthog/hogql/resolver.py b/posthog/hogql/resolver.py index a70eefa8ef9dd..315e9c62c1a1d 100644 --- a/posthog/hogql/resolver.py +++ b/posthog/hogql/resolver.py @@ -127,7 +127,7 @@ def visit_select_query(self, node: ast.SelectQuery): else: select_nodes.append(new_expr) - columns_with_explicit_alias = {} + columns_with_visible_alias = {} for new_expr in select_nodes: if isinstance(new_expr.type, ast.FieldAliasType): alias = new_expr.type.alias @@ -139,14 +139,14 @@ def visit_select_query(self, node: ast.SelectQuery): alias = None if alias: - # Remember the first visible or last hidden expr for each alias + # Make a reference of the first visible or last hidden expr for each unique alias name. if isinstance(new_expr, ast.Alias) and new_expr.hidden: - if alias not in node_type.columns or not columns_with_explicit_alias.get(alias, False): + if alias not in node_type.columns or not columns_with_visible_alias.get(alias, False): node_type.columns[alias] = new_expr.type - columns_with_explicit_alias[alias] = False + columns_with_visible_alias[alias] = False else: node_type.columns[alias] = new_expr.type - columns_with_explicit_alias[alias] = True + columns_with_visible_alias[alias] = True # add the column to the new select query new_node.select.append(new_expr)