OpenSearch/docs/reference/sql/functions/index.asciidoc

163 lines
5.2 KiB
Plaintext
Raw Normal View History

2018-06-22 18:40:25 -04:00
[role="xpack"]
[testenv="basic"]
[[sql-functions]]
== Functions and Operators
{es-sql} provides a comprehensive set of built-in operators and functions:
* <<sql-operators, Operators>>
** <<sql-operators-equality>>
** <<sql-operators-null-safe-equality>>
** <<sql-operators-inequality>>
** <<sql-operators-comparison>>
** <<sql-operators-between>>
** <<sql-operators-is-null>>
** <<sql-operators-in>>
** <<sql-operators-and>>
** <<sql-operators-or>>
** <<sql-operators-not>>
** <<sql-operators-plus>>
** <<sql-operators-subtract>>
** <<sql-operators-negate>>
** <<sql-operators-multiply>>
** <<sql-operators-divide>>
** <<sql-operators-remainder>>
** <<sql-operators-cast-cast>>
* <<sql-like-rlike-operators>>
** <<sql-like-operator>>
** <<sql-rlike-operator>>
* <<sql-functions-aggs>>
** <<sql-functions-aggs-avg>>
** <<sql-functions-aggs-count>>
** <<sql-functions-aggs-count-all>>
** <<sql-functions-aggs-count-distinct>>
** <<sql-functions-aggs-first>>
** <<sql-functions-aggs-last>>
** <<sql-functions-aggs-max>>
** <<sql-functions-aggs-min>>
** <<sql-functions-aggs-sum>>
** <<sql-functions-aggs-kurtosis>>
** <<sql-functions-aggs-mad>>
** <<sql-functions-aggs-percentile>>
** <<sql-functions-aggs-percentile-rank>>
** <<sql-functions-aggs-skewness>>
** <<sql-functions-aggs-stddev-pop>>
** <<sql-functions-aggs-sum-squares>>
** <<sql-functions-aggs-var-pop>>
* <<sql-functions-grouping>>
** <<sql-functions-grouping-histogram>>
* <<sql-functions-datetime-interval, Date-Time Operators>>
* <<sql-functions-current-date, Date-Time Functions>>
** <<sql-functions-current-date>>
** <<sql-functions-current-time>>
** <<sql-functions-current-timestamp>>
** <<sql-functions-datetime-day>>
** <<sql-functions-datetime-dow>>
** <<sql-functions-datetime-doy>>
** <<sql-functions-datetime-dayname>>
** <<sql-functions-datetime-hour>>
** <<sql-functions-datetime-isodow>>
** <<sql-functions-datetime-isoweek>>
** <<sql-functions-datetime-minuteofday>>
** <<sql-functions-datetime-minute>>
** <<sql-functions-datetime-month>>
** <<sql-functions-datetime-monthname>>
** <<sql-functions-now>>
** <<sql-functions-datetime-second>>
** <<sql-functions-datetime-quarter>>
** <<sql-functions-today>>
** <<sql-functions-datetime-week>>
** <<sql-functions-datetime-year>>
** <<sql-functions-datetime-extract>>
* <<sql-functions-search>>
** <<sql-functions-search-match>>
** <<sql-functions-search-query>>
** <<sql-functions-search-score>>
* <<sql-functions-math>>
** <<sql-functions-math-abs>>
** <<sql-functions-math-cbrt>>
** <<sql-functions-math-ceil>>
** <<sql-functions-math-e>>
** <<sql-functions-math-exp>>
** <<sql-functions-math-expm1>>
** <<sql-functions-math-floor>>
** <<sql-functions-math-log>>
** <<sql-functions-math-log10>>
** <<sql-functions-math-pi>>
** <<sql-functions-math-power>>
** <<sql-functions-math-random>>
** <<sql-functions-math-round>>
** <<sql-functions-math-sign>>
** <<sql-functions-math-sqrt>>
** <<sql-functions-math-truncate>>
** <<sql-functions-math-acos>>
** <<sql-functions-math-asin>>
** <<sql-functions-math-atan>>
** <<sql-functions-math-atan2>>
** <<sql-functions-math-cos>>
** <<sql-functions-math-cosh>>
** <<sql-functions-math-cot>>
** <<sql-functions-math-degrees>>
** <<sql-functions-math-radians>>
** <<sql-functions-math-sin>>
** <<sql-functions-math-sinh>>
** <<sql-functions-math-tan>>
* <<sql-functions-string>>
** <<sql-functions-string-ascii>>
** <<sql-functions-string-bit-length>>
** <<sql-functions-string-char>>
** <<sql-functions-string-char-length>>
** <<sql-functions-string-concat>>
** <<sql-functions-string-insert>>
** <<sql-functions-string-lcase>>
** <<sql-functions-string-left>>
** <<sql-functions-string-length>>
** <<sql-functions-string-locate>>
** <<sql-functions-string-ltrim>>
** <<sql-functions-string-octet-length>>
** <<sql-functions-string-position>>
** <<sql-functions-string-repeat>>
** <<sql-functions-string-replace>>
** <<sql-functions-string-right>>
** <<sql-functions-string-rtrim>>
** <<sql-functions-string-space>>
** <<sql-functions-string-substring>>
** <<sql-functions-string-ucase>>
* <<sql-functions-type-conversion>>
** <<sql-functions-type-conversion-cast>>
** <<sql-functions-type-conversion-convert>>
* <<sql-functions-conditional>>
** <<sql-functions-conditional-case>>
** <<sql-functions-conditional-coalesce>>
** <<sql-functions-conditional-greatest>>
** <<sql-functions-conditional-ifnull>>
** <<sql-functions-conditional-iif>>
** <<sql-functions-conditional-isnull>>
** <<sql-functions-conditional-least>>
** <<sql-functions-conditional-nullif>>
** <<sql-functions-conditional-nvl>>
SQL: Add initial geo support (#42031) (#42135) Adds an initial limited implementations of geo features to SQL. This implementation is based on the [OpenGIS® Implementation Standard for Geographic information - Simple feature access](http://www.opengeospatial.org/standards/sfs), which is the current standard for GIS system implementation. This effort is concentrate on SQL option AKA ISO 19125-2. Queries that are supported as a result of this initial implementation Metadata commands - `DESCRIBE table` - returns the correct column types `GEOMETRY` for geo shapes and geo points. - `SHOW FUNCTIONS` - returns a list that includes supported `ST_` functions - `SYS TYPES` and `SYS COLUMNS` display correct types `GEO_SHAPE` and `GEO_POINT` for geo shapes and geo points accordingly. Returning geoshapes and geopoints from elasticsearch - `SELECT geom FROM table` - returns the geoshapes and geo_points as libs/geo objects in JDBC or as WKT strings in console. - `SELECT ST_AsWKT(geom) FROM table;` and `SELECT ST_AsText(geom) FROM table;`- returns the geoshapes ang geopoints in their WKT representation; Using geopoints to elasticsearch - The following functions will be supported for geopoints in queries, sorting and aggregations: `ST_GeomFromText`, `ST_X`, `ST_Y`, `ST_Z`, `ST_GeometryType`, and `ST_Distance`. In most cases when used in queries, sorting and aggregations, these function are translated into script. These functions can be used in the SELECT clause for both geopoints and geoshapes. - `SELECT * FROM table WHERE ST_Distance(ST_GeomFromText(POINT(1 2), point) < 10;` - returns all records for which `point` is located within 10m from the `POINT(1 2)`. In this case the WHERE clause is translated into a range query. Limitations: Geoshapes cannot be used in queries, sorting and aggregations as part of this initial effort. In order to fully take advantage of geoshapes we would need to have access to geoshape doc values, which is coming in #37206. `ST_Z` cannot be used on geopoints in queries, sorting and aggregations since we don't store altitude in geo_point doc values. Relates to #29872 Backport of #42031
2019-05-14 19:57:12 -04:00
* <<sql-functions-geo>>
** <<sql-functions-geo-st-as-wkt>>
** <<sql-functions-geo-st-distance>>
** <<sql-functions-geo-st-geometrytype>>
** <<sql-functions-geo-st-wkt-to-sql>>
** <<sql-functions-geo-st-x>>
** <<sql-functions-geo-st-y>>
** <<sql-functions-geo-st-z>>
* <<sql-functions-system>>
** <<sql-functions-system-database>>
** <<sql-functions-system-user>>
include::operators.asciidoc[]
include::like-rlike.asciidoc[]
include::aggs.asciidoc[]
include::grouping.asciidoc[]
include::date-time.asciidoc[]
include::search.asciidoc[]
include::math.asciidoc[]
include::string.asciidoc[]
include::type-conversion.asciidoc[]
SQL: Add initial geo support (#42031) (#42135) Adds an initial limited implementations of geo features to SQL. This implementation is based on the [OpenGIS® Implementation Standard for Geographic information - Simple feature access](http://www.opengeospatial.org/standards/sfs), which is the current standard for GIS system implementation. This effort is concentrate on SQL option AKA ISO 19125-2. Queries that are supported as a result of this initial implementation Metadata commands - `DESCRIBE table` - returns the correct column types `GEOMETRY` for geo shapes and geo points. - `SHOW FUNCTIONS` - returns a list that includes supported `ST_` functions - `SYS TYPES` and `SYS COLUMNS` display correct types `GEO_SHAPE` and `GEO_POINT` for geo shapes and geo points accordingly. Returning geoshapes and geopoints from elasticsearch - `SELECT geom FROM table` - returns the geoshapes and geo_points as libs/geo objects in JDBC or as WKT strings in console. - `SELECT ST_AsWKT(geom) FROM table;` and `SELECT ST_AsText(geom) FROM table;`- returns the geoshapes ang geopoints in their WKT representation; Using geopoints to elasticsearch - The following functions will be supported for geopoints in queries, sorting and aggregations: `ST_GeomFromText`, `ST_X`, `ST_Y`, `ST_Z`, `ST_GeometryType`, and `ST_Distance`. In most cases when used in queries, sorting and aggregations, these function are translated into script. These functions can be used in the SELECT clause for both geopoints and geoshapes. - `SELECT * FROM table WHERE ST_Distance(ST_GeomFromText(POINT(1 2), point) < 10;` - returns all records for which `point` is located within 10m from the `POINT(1 2)`. In this case the WHERE clause is translated into a range query. Limitations: Geoshapes cannot be used in queries, sorting and aggregations as part of this initial effort. In order to fully take advantage of geoshapes we would need to have access to geoshape doc values, which is coming in #37206. `ST_Z` cannot be used on geopoints in queries, sorting and aggregations since we don't store altitude in geo_point doc values. Relates to #29872 Backport of #42031
2019-05-14 19:57:12 -04:00
include::geo.asciidoc[]
include::conditional.asciidoc[]
include::system.asciidoc[]