snuba
snuba copied to clipboard
draft(MQL): Parse multi-entity type formulas
This is a draft PR for implementing what parsing multi-entity type formulas might look like in snuba.
Depends on:
- https://github.com/getsentry/snuba-sdk/pull/169
This change breaks up the parsing pipeline into multiple sub-tasks:
-
parse_mql_query_body()
: Parses the MQL into theInitialParseResult
tree -
populate_query_ast_initial()
: CreatesLogicalQuery | CompositeQuery
objects with the appropriate expressions. If multi-type formula query, calls some processing function (process_table_names_in_selected_expressions()
) which traverses AST and adds the appropriate join table names to the expressions. -
populate_query_from_mql_context
Parses MQL Context and transforms fields into expressions that inject into the AST. If multi-type formula query, patch the appropriate join table names.
To see preview of CompositeQuery AST (with joins), run pytest tests/query/parser/test_formula_mql_query.py::test_multi_type_formula -s -vv