Skip to content

Commit

Permalink
fix(hogql): use correct toDecimal function (#26826)
Browse files Browse the repository at this point in the history
  • Loading branch information
timgl authored Dec 11, 2024
1 parent 182bb05 commit 65077a3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion posthog/hogql/functions/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def compare_types(arg_types: list[ConstantType], sig_arg_types: tuple[ConstantTy
"_toUInt64": HogQLFunctionMeta("toUInt64", 1, 1, signatures=[((UnknownType(),), IntegerType())]),
"_toUInt128": HogQLFunctionMeta("toUInt128", 1, 1),
"toFloat": HogQLFunctionMeta("accurateCastOrNull", 1, 1, suffix_args=[ast.Constant(value="Float64")]),
"toDecimal": HogQLFunctionMeta("accurateCastOrNull", 1, 1, suffix_args=[ast.Constant(value="Decimal64")]),
"toDecimal": HogQLFunctionMeta("toDecimal64OrNull", 2, 2),
"toDate": HogQLFunctionMeta(
"toDateOrNull",
1,
Expand Down
4 changes: 1 addition & 3 deletions posthog/hogql/test/test_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -846,9 +846,7 @@ def test_functions(self):
self._expr("toUUID('470f9b15-ff43-402a-af9f-2ed7c526a6cf')", context),
"accurateCastOrNull(%(hogql_val_4)s, %(hogql_val_5)s)",
)
self.assertEqual(
self._expr("toDecimal('3.14')", context), "accurateCastOrNull(%(hogql_val_6)s, %(hogql_val_7)s)"
)
self.assertEqual(self._expr("toDecimal('3.14', 2)", context), "toDecimal64OrNull(%(hogql_val_6)s, 2)")
self.assertEqual(self._expr("quantile(0.95)( event )"), "quantile(0.95)(events.event)")

def test_expr_parse_errors(self):
Expand Down

0 comments on commit 65077a3

Please sign in to comment.