Skip to content

Commit

Permalink
ESQL: Warn about division (elastic#109716)
Browse files Browse the repository at this point in the history
When you divide two integers or two longs we round towards 0. Like
Postgres or Java or Rust or C. Other systems, like MySQL or SPL or
Javascript or Python always produce a floating point number. We should
warn folks about this. It's genuinely unexpected for some folks. OTOH,
converting into a floating point number would be unexpected for other
folks. Oh well, let's document what we've got.
  • Loading branch information
nik9000 authored Jun 14, 2024
1 parent 0dc56ab commit 2aade9d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/reference/esql/functions/binary.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ include::types/mul.asciidoc[]
[.text-center]
image::esql/functions/signature/div.svg[Embedded,opts=inline]

NOTE: Division of two integer types will yield an integer result, rounding towards 0.
If you need floating point division, <<esql-cast-operator>> one of the arguments to a `DOUBLE`.

include::types/div.asciidoc[]

==== Modulus `%`
Expand Down

0 comments on commit 2aade9d

Please sign in to comment.