{es-sql} provides a number of built-in operators and functions.
{es-sql} supports the following comparison operators:
-
Equality (
=
)
include-tagged::{sql-specs}/filter.sql-spec[whereFieldEquality]
-
Inequality (
<>
or!=
or<⇒
)
include-tagged::{sql-specs}/filter.sql-spec[whereFieldNonEquality]
-
Comparison (
<
,⇐
,>
,>=
)
include-tagged::{sql-specs}/filter.sql-spec[whereFieldLessThan]
-
BETWEEN
include-tagged::{sql-specs}/filter.sql-spec[whereBetween]
-
IS NULL
/IS NOT NULL
include-tagged::{sql-specs}/filter.sql-spec[whereIsNotNullAndIsNull]
{es-sql} supports the following logical operators:
-
AND
include-tagged::{sql-specs}/filter.sql-spec[whereFieldAndComparison]
-
OR
include-tagged::{sql-specs}/filter.sql-spec[whereFieldOrComparison]
-
NOT
include-tagged::{sql-specs}/filter.sql-spec[whereFieldEqualityNot]
{es-sql} supports the following math operators:
-
Add (
+
)
include-tagged::{sql-specs}/arithmetic.sql-spec[plus]
-
Subtract (infix
-
)
include-tagged::{sql-specs}/arithmetic.sql-spec[minus]
-
Negate (unary
-
)
include-tagged::{sql-specs}/arithmetic.sql-spec[unaryMinus]
-
Multiply (
*
)
include-tagged::{sql-specs}/arithmetic.sql-spec[multiply]
-
Divide (
/
)
include-tagged::{sql-specs}/arithmetic.sql-spec[divide]
-
Modulo or Reminder(
%
)
include-tagged::{sql-specs}/arithmetic.sql-spec[mod]
All math and trigonometric functions require their input (where applicable) to be numeric.
-
ABS
Absolute value, returns \[same type as input]
include-tagged::{sql-specs}/math.sql-spec[abs]
-
CBRT
Cube root, returns double
-
CEIL
Ceiling, returns double
-
CEILING
Same as CEIL
-
E
Euler’s number, returns 2.7182818284590452354
-
Round (
ROUND
)
Note
|
This rounds "half up" meaning that ROUND(-1.5) results in -1 .
|
-
Floor (
FLOOR
)
-
Natural logarithm (
LOG
)
include-tagged::{sql-specs}/math.sql-spec[log]
-
Logarithm base 10 (
LOG10
)
include-tagged::{sql-specs}/math.sql-spec[log10]
-
Square root (
SQRT
)
include-tagged::{sql-specs}/math.sql-spec[sqrt]
-
ex (
EXP
)
include-tagged::{sql-specs}/math.sql-spec[exp]
-
ex - 1 (
EXPM1
)
include-tagged::{sql-specs}/math.sql-spec[expm1]
include-tagged::{sql-specs}/math.sql-spec[degrees]
include-tagged::{sql-specs}/math.sql-spec[degrees]
-
Sine (
SIN
)
include-tagged::{sql-specs}/math.sql-spec[sin]
-
Cosine (
COS
)
include-tagged::{sql-specs}/math.sql-spec[cos]
-
Tangent (
TAN
)
include-tagged::{sql-specs}/math.sql-spec[tan]
-
Arc sine (
ASIN
)
include-tagged::{sql-specs}/math.sql-spec[asin]
-
Arc cosine (
ACOS
)
include-tagged::{sql-specs}/math.sql-spec[acos]
-
Arc tangent (
ATAN
)
include-tagged::{sql-specs}/math.sql-spec[atan]
-
Hyperbolic sine (
SINH
)
include-tagged::{sql-specs}/math.sql-spec[sinh]
-
Hyperbolic cosine (
COSH
)
include-tagged::{sql-specs}/math.sql-spec[cosh]
-
Extract the year from a date (
YEAR
)
include-tagged::{sql-specs}/datetime.csv-spec[year]
-
Extract the month of the year from a date (
MONTH_OF_YEAR
orMONTH
)
include-tagged::{sql-specs}/datetime.csv-spec[monthOfYear]
-
Extract the week of the year from a date (
WEEK_OF_YEAR
orWEEK
)
include-tagged::{sql-specs}/datetime.csv-spec[weekOfYear]
-
Extract the day of the year from a date (
DAY_OF_YEAR
orDOY
)
include-tagged::{sql-specs}/datetime.csv-spec[dayOfYear]
-
Extract the day of the month from a date (
DAY_OF_MONTH
,DOM
, orDAY
)
include-tagged::{sql-specs}/datetime.csv-spec[dayOfMonth]
-
Extract the day of the week from a date (
DAY_OF_WEEK
orDOW
). Monday is1
, Tuesday is2
, etc.
include-tagged::{sql-specs}/datetime.csv-spec[dayOfWeek]
-
Extract the hour of the day from a date (
HOUR_OF_DAY
orHOUR
). Monday is1
, Tuesday is2
, etc.
include-tagged::{sql-specs}/datetime.csv-spec[hourOfDay]
-
Extract the minute of the day from a date (
MINUTE_OF_DAY
).
include-tagged::{sql-specs}/datetime.csv-spec[minuteOfDay]
-
Extract the minute of the hour from a date (
MINUTE_OF_HOUR
,MINUTE
).
include-tagged::{sql-specs}/datetime.csv-spec[minuteOfHour]
-
Extract the second of the minute from a date (
SECOND_OF_MINUTE
,SECOND
).
include-tagged::{sql-specs}/datetime.csv-spec[secondOfMinute]
-
Extract
As an alternative, one can support EXTRACT
to extract fields from datetimes.
You can run any datetime function
with EXTRACT(<datetime_function> FROM <expression>)
. So
include-tagged::{sql-specs}/datetime.csv-spec[extractDayOfYear]
is the equivalent to
include-tagged::{sql-specs}/datetime.csv-spec[dayOfYear]
-
Average (
AVG
)
include-tagged::{sql-specs}/agg.sql-spec[avg]
-
Count the number of matching fields (
COUNT
)
include-tagged::{sql-specs}/agg.sql-spec[countStar]
-
Count the number of distinct values in matching documents (
COUNT(DISTINCT
)
include-tagged::{sql-specs}/agg.sql-spec[countDistinct]
-
Find the maximum value in matching documents (
MAX
)
include-tagged::{sql-specs}/agg.sql-spec[max]
-
Find the minimum value in matching documents (
MIN
)
include-tagged::{sql-specs}/agg.sql-spec[min]
-
Sum all values of matching documents (
SUM
).
include-tagged::{sql-specs}/agg.csv-spec[sum]