diff --git a/posthog/hogql/parser.py b/posthog/hogql/parser.py index 132755d01026c..cacae5eefec95 100644 --- a/posthog/hogql/parser.py +++ b/posthog/hogql/parser.py @@ -2,6 +2,7 @@ from antlr4 import CommonTokenStream, InputStream, ParseTreeVisitor, ParserRuleContext from antlr4.error.ErrorListener import ErrorListener +from django.conf import settings from posthog.hogql import ast from posthog.hogql.base import AST @@ -38,8 +39,11 @@ def parse_expr( start: Optional[int] = 0, timings: Optional[HogQLTimings] = None, *, - backend: Literal["python", "cpp"] = "python", + backend: Optional[Literal["python", "cpp"]] = None, ) -> ast.Expr: + if not backend: + # TODO: Switch over to C++ in production once we are confident there are no issues + backend = "cpp" if settings.DEBUG else "python" if timings is None: timings = HogQLTimings() with timings.measure(f"parse_expr_{backend}"): @@ -55,8 +59,11 @@ def parse_order_expr( placeholders: Optional[Dict[str, ast.Expr]] = None, timings: Optional[HogQLTimings] = None, *, - backend: Literal["python", "cpp"] = "python", + backend: Optional[Literal["python", "cpp"]] = None, ) -> ast.Expr: + if not backend: + # TODO: Switch over to C++ in production once we are confident there are no issues + backend = "cpp" if settings.DEBUG else "python" if timings is None: timings = HogQLTimings() with timings.measure(f"parse_order_expr_{backend}"): @@ -72,8 +79,11 @@ def parse_select( placeholders: Optional[Dict[str, ast.Expr]] = None, timings: Optional[HogQLTimings] = None, *, - backend: Literal["python", "cpp"] = "python", + backend: Optional[Literal["python", "cpp"]] = None, ) -> ast.SelectQuery | ast.SelectUnionQuery: + if not backend: + # TODO: Switch over to C++ in production once we are confident there are no issues + backend = "cpp" if settings.DEBUG else "python" if timings is None: timings = HogQLTimings() with timings.measure(f"parse_select_{backend}"):