mv_first.asciidoc 1.0 KB

123456789101112131415161718192021222324252627
  1. [discrete]
  2. [[esql-mv_first]]
  3. === `MV_FIRST`
  4. [.text-center]
  5. image::esql/functions/signature/mv_first.svg[Embedded,opts=inline]
  6. Converts a multivalued field into a single valued field containing the first value. This is most
  7. useful when reading from a function that emits multivalued fields in a known order like <<esql-split>>:
  8. [source.merge.styled,esql]
  9. ----
  10. include::{esql-specs}/string.csv-spec[tag=mv_first]
  11. ----
  12. [%header.monospaced.styled,format=dsv,separator=|]
  13. |===
  14. include::{esql-specs}/string.csv-spec[tag=mv_first-result]
  15. |===
  16. The order that <<esql-multivalued-fields, multivalued fields>> are read from underlying storage is not
  17. guaranteed. It is *frequently* ascending, but don't rely on that. If you need the minimum field value
  18. use <<esql-mv_min>> instead of `MV_FIRST`. `MV_MIN` has optimizations for sorted values so there isn't
  19. a performance benefit to `MV_FIRST`. `MV_FIRST` is mostly useful with functions that create multivalued
  20. fields like `SPLIT`.
  21. Supported types:
  22. include::types/mv_first.asciidoc[]