浏览代码

ESQL: Warn about division (#109716)

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.
Nik Everett 1 年之前
父节点
当前提交
2aade9dd66
共有 1 个文件被更改,包括 3 次插入0 次删除
  1. 3 0
      docs/reference/esql/functions/binary.asciidoc

+ 3 - 0
docs/reference/esql/functions/binary.asciidoc

@@ -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 `%`