Commit graph

145 commits

Author SHA1 Message Date
Xiang Dai
432bd0e92c Fix docs typos (#50365)
Fixes a few typos in the docs.

Signed-off-by: Xiang Dai 764524258@qq.com
2019-12-23 10:35:14 -05:00
Andrei Stefan
ce727615c0
SQL: handle NULL arithmetic operations with INTERVALs (#49633) 2019-12-02 16:05:05 +02:00
Marios Trivyzas
f2aa7f0779
SQL: Add TRUNC alias for TRUNCATE (#49571)
Add TRUNC as alias to already implemented TRUNCATE
numeric function which is the flavour supported by
Oracle and PostgreSQL.

Relates to: #41195
2019-11-26 12:30:49 +01:00
Bogdan Pintea
a55b36065e
SQL:Docs: add the PIVOT clause to SELECT section (#49129)
The PR adds the documentation on the PIVOT clause.
2019-11-20 16:53:16 +01:00
Marios Trivyzas
124cd18e20
SQL: Fix issue with mins & hours for DATEDIFF (#49252)
Previously, DATEDIFF for minutes and hours was doing a
rounding calculation using all the time fields (secs, msecs/micros/nanos).
Instead it should first truncate the 2 dates to the respective field (mins or hours)
zeroing out all the more detailed time fields and then make the subtraction.
2019-11-19 13:40:34 +01:00
Daniel Andion
9d505dc3db SQL: [Docs] Typo in HAVING section (#48609)
`HAVING` section code states `GROUP BY`  instead of the appropriate keyword.
2019-10-29 16:36:08 +01:00
Marios Trivyzas
745699f38d
SQL: Implement DATEDIFF function (#47920)
Implement DATEDIFF/TIMESTAMPDIFF function as per the MS-SQL spec:
https://docs.microsoft.com/en-us/sql/t-sql/functions/datediff-transact-sql?view=sql-server-2017
which allows a user to substract two date/datetime fields and return the
difference in the date/time unit specified.

Closes: #47919
2019-10-15 14:42:20 +02:00
Marios Trivyzas
0516b6eaf5
SQL: Fix arg verification for DateAddProcessor (#48041)
Previously, the safety check for the 2nd argument of the DateAddProcessor was
restricting it to Integer which was wrong since we allow all non-rational
numbers, so it's changed to a Number check as it's done in other cases.

Enhanced some tests regarding the check for an integer (non-rational
argument).
2019-10-15 12:25:04 +02:00
Marios Trivyzas
e624bc281b
SQL: Implement DATEADD function (#47747)
Implement DATEADD/TIMESTAMPADD function as per the MS-SQL spec:
https://docs.microsoft.com/en-us/sql/t-sql/functions/dateadd-transact-sql?view=sql-server-2017
which allows a user to add/subtract specified number of specified units
to/from a date/datetime field/expression.

Closes: #47746
2019-10-10 15:24:36 +02:00
Andrei Stefan
55f5463eee
SQL: use calendar interval of 1y instead of fixed interval for grouping by YEAR and HISTOGRAMs (#47558) 2019-10-09 11:22:41 +03:00
Alan Woodward
7a622f024f
Remove types from BulkRequest (#46983)
This commit removes types entirely from BulkRequest, both as a global
parameter and as individual entries on update/index/delete lines.

Relates to #41059
2019-10-07 13:29:12 +01:00
Lisa Cawley
4e4990c6a0
[DOCS] Cleans up links to security content (#47610) 2019-10-04 16:10:26 -07:00
Marios Trivyzas
ead743d357
SQL: Implement DATE_PART function (#47206)
]DATE_PART(<datetime unit>, <date/datetime>) is a function that allows
the user to extract the specified unit from a date/datetime field
similar to the EXTRACT (<datetime unit> FROM <date/datetime>) but
with different names and aliases for the units and it also provides more
options like `DATE_PART('tzoffset', datetimeField)`.

Implemented following the SQL server's spec: https://docs.microsoft.com/en-us/sql/t-sql/functions/datepart-transact-sql?view=sql-server-2017
with the difference that the <datetime unit> argument is either a
literal single quoted string or gets a value from a table field, whereas
in SQL server keywords are used (unquoted identifiers) and it's not
possible to use a value coming for a table column.

Closes: #46372
2019-10-01 15:59:25 +03:00
Marios Trivyzas
9ac223cb1f
SQL: Add alias DATETRUNC to DATE_TRUNC function (#47173)
To be on the safe side in terms of use cases also add the alias
DATETRUNC to the DATE_TRUNC function.

Follows: #46473
2019-09-27 15:38:03 +03:00
Igor Motov
76de93c258
SQL: Add support for shape type (#46464)
Enables support for Cartesian geometries shape type. We still need to
decide how to handle the distance function since it is currently using
the haversine distance formula and returns results in meters, which
doesn't make any sense for Cartesian geometries.

Closes #46412
Relates to #43644
2019-09-25 13:43:05 -04:00
Costin Leau
d874f1139e DOC: Fix typo 2019-09-16 12:33:58 +03:00
Costin Leau
3aa417ed74
DOC: Update section for SQuirrel SQL 4.0.0 (#46726)
The just released SQuirrel SQL 4.0.0 provides an Elasticsearch driver
definition out of the box; update the documentation to reflect that.
2019-09-16 12:26:48 +03:00
James Rodewig
e355759086
[DOCS] Replace "// CONSOLE" comments with [source,console] (#46679) 2019-09-13 11:23:53 -04:00
Marios Trivyzas
b37e96712d
SQL: Implement DATE_TRUNC function (#46473)
DATE_TRUNC(<truncate field>, <date/datetime>) is a function that allows
the user to truncate a timestamp to the specified field by zeroing out
the rest of the fields. The function is implemented according to the
spec from PostgreSQL: https://www.postgresql.org/docs/current/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC

Closes: #46319
2019-09-11 21:09:40 +03:00
James Rodewig
e43be90e6c
[DOCS] [5 of 5] Change // TESTRESPONSE comments to [source,console-results] (#46449) 2019-09-06 14:05:36 -04:00
James Rodewig
466c59a4a7
[DOCS] Replace "// TESTRESPONSE" magic comments with "[source,console-result] (#46295) 2019-09-05 16:47:18 -04:00
James Rodewig
f5827ba0ae
[DOCS] Replace "// CONSOLE" comments with [source,console] (#46159) 2019-09-04 12:51:02 -04:00
Costin Leau
6d257194c1
DOC: Update SQL docs for DbVis and Workbench/J (#45981)
Refresh the setup for the new versions of DbVisualizer and SQL
Workbench/J which have Elasticsearch JDBC support out of the box.
2019-08-29 11:13:18 +03:00
James Rodewig
fbbd749182
[DOCS] Correct IIF conditional section title (#45979) 2019-08-26 11:13:18 -04:00
Bogdan Pintea
e18ac10c6e
SQL: ODBC: document newest connection string parameters (#44185)
* SQL: ODBC: document newest conn string parameters

This commit adds the documentation for two newly added connection string
parameters: AutoEscapePVA and IndexIncludeFrozen.

It also removes the recommended OSes from the prerequisites list and
places the recommendation distinctively: the unmet prerequisites will
fail the installation, while the driver would install on other OSes than
those recommended.

* address review suggestions.

- adjust phrasing for clearer message.
2019-08-12 13:42:08 +02:00
Andrei Stefan
8bf8a055e3
Switch from using docvalue_fields to extracting values from _source (#44062)
* Switch from using docvalue_fields to extracting values from _source
where applicable. Doing this means parsing the _source and handling the
numbers parsing just like Elasticsearch is doing it when it's indexing
a document.
* This also introduces a minor limitation: aliases type of fields that
are NOT part of a tree of sub-fields will not be able to be retrieved
anymore. field_caps API doesn't shed any light into a field being an
alias or not and at _source parsing time there is no way to know if a
root field is an alias or not. Fields of the type "a.b.c.alias" can be
extracted from docvalue_fields, only if the field they point to can be
extracted from docvalue_fields. Also, not all fields in a hierarchy of
fields can be evaluated to being an alias.
2019-07-24 13:59:02 +03:00
James Rodewig
ea1adb61c2
[DOCS] Update anchors and links for Elasticsearch API relocation (#44500) 2019-07-19 09:16:35 -04:00
Igor Motov
3960e1507b
Docs: fix WKTToSQL function example (#44377)
Fixes wrong example snippet in WKTToSQL documentation.

Closes #44299
2019-07-17 12:23:34 -04:00
Andrei Stefan
d589dcad18
SQL: double quotes escaping bug fix (#43829) 2019-07-10 16:03:44 +03:00
Christoph Büscher
7cf84f9943
Yet another the the cleanup (#43815) 2019-07-01 16:25:40 +02:00
Marios Trivyzas
079e012fde
SQL: Increase hard limit for sorting on aggregates (#43220)
To be consistent with the `search.max_buckets` default setting,
set the hard limit of the PriorityQueue used for in memory sorting,
when sorting on an aggregate function, to 10000.

Fixes: #43168
2019-06-14 13:26:18 +02:00
Andrei Stefan
897b24e056
Rename TESTRESPONSE[_cat] to TESTRESPONSE[non_json] (#43087) 2019-06-11 12:38:26 +03:00
Andrei Stefan
309bd691ff
Restructure the SQL Language section to have proper sub-sections (#43007)
Rest docs page update
- have the section be on separate pages
- add an Overview page
- add other formats examples
2019-06-11 12:04:00 +03:00
Andrei Stefan
406d5281bd
SQL: Clarify that the connections the jdbc driver creates are not pooled (#42992) 2019-06-11 12:02:46 +03:00
James Rodewig
655032b07e
[DOCS] Change // TESTRESPONSE[_cat] to // TESTRESPONSE[non_json] (#43006) 2019-06-10 09:33:32 -04:00
Marios Trivyzas
4e0c652515
SQL: [Docs] Fix links syntax (#42806)
Fix a couple of wrong links because of the order of the anchor
and the usage of backquotes.
2019-06-03 17:50:49 +02:00
James Rodewig
d6ad874613
[DOCS] Remove unneeded options from [source,sql] code blocks (#42759)
In AsciiDoc, `subs="attributes,callouts,macros"` options were required
to render `include-tagged::` in a code block.

With elastic/docs#827, Elasticsearch Reference documentation migrated
from AsciiDoc to Asciidoctor.

In Asciidoctor, the `subs="attributes,callouts,macros"` options are no
longer needed to render `include-tagged::` in a code block. This commit
removes those unneeded options.

Resolves #41589
2019-05-31 13:03:41 -04:00
Marios Trivyzas
6dd4d2b7a6
Remove CommonTermsQuery and cutoff_frequency param (#42654)
Remove `common` query and `cutoff_frequency` parameter of
`match` and `multi_match` queries. Both have already been
deprecated for the next 7.x version.

Closes: #37096
2019-05-31 17:06:06 +02:00
James Rodewig
8f03033635
[DOCS] Move callouts to end of line for Asciidoctor migration (#42356) 2019-05-24 15:03:11 -04:00
Igor Motov
3ac6d527a1
Docs: Mark SQL Geo functionality as beta (#42138)
Adds beta marker to geosql documentation
2019-05-15 10:50:54 -04:00
Igor Motov
0b94416cc1
SQL: Add initial geo support (#42031)
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
2019-05-13 22:17:10 -04:00
Costin Leau
f42dcf2ffd Docs: Tweak list formatting 2019-05-10 17:08:00 +03:00
Costin Leau
a3cc03eb15
Docs: Documentation for the upcoming SQL support of frozen indices (#41863)
Add docs for SQL Frozen indices support
2019-05-10 14:19:26 +03:00
Marios Trivyzas
091d43c494
SQL: Remove CircuitBreaker from parser (#41835)
The CircuitBreaker was introduced as means of preventing a
`StackOverflowException` during the build of the AST by the parser.

The ANTLR4 grammar causes a weird behaviour for a Parser Listener.
The `enterEveryRule()` method is often called with a different parsing
context than the respective `exitEveryRule()`. This makes it difficult
to keep track of the tree's depth, and a custom Map was used as an
attempt of matching the contextes as they are encounter during `enter`
and during `exit` of the rules.

This approach had 2 important drawbacks:
1. It's hard to maintain this custom Map as the grammar changes.
2. The CircuitBreaker could often lead to false positives which caused
valid queries to return an Exception and prevent them from executing.

So, this removes completely the CircuitBreaker which is replaced be
a simple handling of the `StackOverflowException`

Fixes: #41471
2019-05-07 19:06:06 -04:00
Marios Trivyzas
eb5f5d4553
SQL: [Docs] Add example for custom bucketing with CASE (#41787)
* SQL: [Docs] Add example for custom bucketing with CASE

Add a TIP on how to use CASE to achieve custom bucketing
with GROUP BY.

Follows: #41349

* address comments

* address comment
2019-05-06 18:00:50 +03:00
James Rodewig
adf67053f4
[DOCS] Add anchors for Asciidoctor migration (#41648) 2019-04-30 10:19:09 -04:00
James Rodewig
3a1606bc60
[DOCS] Remove inline callouts for Asciidoctor migration (#41460) 2019-04-24 08:44:01 -04:00
Marios Trivyzas
add02f4f55
SQL: Implement IIF(<cond>, <result1>, <result2>) (#41420)
Implement a more trivial case of the CASE expression which is
expressed as a traditional function with 2 or 3 arguments. e.g.:

IIF(a = 1, 'one', 'many')
IIF(a > 0, 'positive')
Closes: #40917
2019-04-23 16:30:37 +03:00
Marios Trivyzas
8b2577406f
SQL: Implement CASE... WHEN... THEN... ELSE... END (#41349)
Implement the ANSI SQL CASE expression which provides the if/else
functionality common to most programming languages.

The CASE expression can have multiple WHEN branches and becomes a
powerful tool for SQL queries as it can be used in SELECT, WHERE,
GROUP BY, HAVING and ORDER BY clauses.

Closes: #36200
2019-04-22 19:26:15 +03:00
James Rodewig
9982888f4e
[DOCS] Remove inline callouts for Asciidoctor migration (#41309) 2019-04-22 06:33:55 -07:00