You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When building HogQL queries backend-side we need to choose wether we want to build up the query from strings that are then parsed into a query or from ast nodes. Often it makes sense to choose ast nodes e.g. when building the select param for an ast.SelectQuery. Now it can happen that other statements also need to use these ast nodes, but are better built as strings e.g. when building the ast would be a complex nested thing and the string would be much more readable.
Describe the solution you'd like
It would be great if these parts could be passed into parse_select and parse_expr as placeholders.
The following things currently don't work:
parse_select('SELECT {columns} FROM events', placeholders={"columns": [ast.Constant(value=1), ast.Constant(value=2)]}) (doesn't support list-type columns)
parse_expr("max(steps) over (PARTITION BY aggregation_target {placeholder}) as max_steps", placeholders={"placeholder": ast.Field(chain=['some_col'])}) (doesn't support the placeholder sibling)
parse_select('SELECT event FROM events WHERE {where}', placeholders={"where": None})(doesn't support nullable placeholder)
Is your feature request related to a problem?
When building HogQL queries backend-side we need to choose wether we want to build up the query from strings that are then parsed into a query or from ast nodes. Often it makes sense to choose ast nodes e.g. when building the
select
param for anast.SelectQuery
. Now it can happen that other statements also need to use these ast nodes, but are better built as strings e.g. when building the ast would be a complex nested thing and the string would be much more readable.Describe the solution you'd like
It would be great if these parts could be passed into
parse_select
andparse_expr
as placeholders.The following things currently don't work:
parse_select('SELECT {columns} FROM events', placeholders={"columns": [ast.Constant(value=1), ast.Constant(value=2)]})
(doesn't support list-type columns)parse_expr("max(steps) over (PARTITION BY aggregation_target {placeholder}) as max_steps", placeholders={"placeholder": ast.Field(chain=['some_col'])})
(doesn't support the placeholder sibling)parse_select('SELECT event FROM events WHERE {where}', placeholders={"where": None})
(doesn't support nullable placeholder)Additional context
#19961
The text was updated successfully, but these errors were encountered: