elasticsearch/docs/reference/esql/processing-commands/eval.asciidoc
Nik Everett 1256a49c3a
ESQL: Move description of commands in docs (#110714)
This copies the first line of the description of each command to just
under the syntax so that it's "in order", before the `Parameters`
section. That way if you are reading from top to bottom you see:
```
syntax
short description
parameter names and descriptions
long description
examples
```

I've also removed the `Description` section entirely if the description
was just one sentence. So in some cases that just isn't `long
description`.
2024-07-11 08:31:35 -04:00

76 lines
1.9 KiB
Text

[discrete]
[[esql-eval]]
=== `EVAL`
The `EVAL` processing command enables you to append new columns with calculated
values.
**Syntax**
[source,esql]
----
EVAL [column1 =] value1[, ..., [columnN =] valueN]
----
*Parameters*
`columnX`::
The column name.
`valueX`::
The value for the column. Can be a literal, an expression, or a
<<esql-functions,function>>.
*Description*
The `EVAL` processing command enables you to append new columns with calculated
values. `EVAL` supports various functions for calculating values. Refer to
<<esql-functions,Functions>> for more information.
*Examples*
[source.merge.styled,esql]
----
include::{esql-specs}/eval.csv-spec[tag=eval]
----
[%header.monospaced.styled,format=dsv,separator=|]
|===
include::{esql-specs}/eval.csv-spec[tag=eval-result]
|===
If the specified column already exists, the existing column will be dropped, and
the new column will be appended to the table:
[source.merge.styled,esql]
----
include::{esql-specs}/eval.csv-spec[tag=evalReplace]
----
[%header.monospaced.styled,format=dsv,separator=|]
|===
include::{esql-specs}/eval.csv-spec[tag=evalReplace-result]
|===
Specifying the output column name is optional. If not specified, the new column
name is equal to the expression. The following query adds a column named
`height*3.281`:
[source.merge.styled,esql]
----
include::{esql-specs}/eval.csv-spec[tag=evalUnnamedColumn]
----
[%header.monospaced.styled,format=dsv,separator=|]
|===
include::{esql-specs}/eval.csv-spec[tag=evalUnnamedColumn-result]
|===
Because this name contains special characters, <<esql-identifiers,it needs to be
quoted>> with backticks (+{backtick}+) when using it in subsequent commands:
[source.merge.styled,esql]
----
include::{esql-specs}/eval.csv-spec[tag=evalUnnamedColumnStats]
----
[%header.monospaced.styled,format=dsv,separator=|]
|===
include::{esql-specs}/eval.csv-spec[tag=evalUnnamedColumnStats-result]
|===