to_long.asciidoc 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. [discrete]
  2. [[esql-to_long]]
  3. === `TO_LONG`
  4. *Syntax*
  5. [source,esql]
  6. ----
  7. TO_LONG(v)
  8. ----
  9. *Parameters*
  10. `v`::
  11. Input value. The input can be a single- or multi-valued column or an expression.
  12. *Description*
  13. Converts an input value to a long value.
  14. If the input parameter is of a date type, its value will be interpreted as
  15. milliseconds since the {wikipedia}/Unix_time[Unix epoch], converted to long.
  16. Boolean *true* will be converted to long *1*, *false* to *0*.
  17. *Supported types*
  18. The input type must be of a boolean, date, string or numeric type.
  19. *Example*
  20. [source.merge.styled,esql]
  21. ----
  22. include::{esql-specs}/ints.csv-spec[tag=to_long-str]
  23. ----
  24. [%header.monospaced.styled,format=dsv,separator=|]
  25. |===
  26. include::{esql-specs}/ints.csv-spec[tag=to_long-str-result]
  27. |===
  28. Note that in this example, the last conversion of the string isn't
  29. possible. When this happens, the result is a *null* value. In this case a
  30. _Warning_ header is added to the response. The header will provide information
  31. on the source of the failure:
  32. `"Line 1:113: evaluation of [TO_LONG(str3)] failed, treating result as null. Only first 20 failures recorded."`
  33. A following header will contain the failure reason and the offending value:
  34. `"java.lang.NumberFormatException: For input string: \"foo\""`