Commit graph

199 commits

Author SHA1 Message Date
Marios Trivyzas
45677a385b
QL: Eliminate internal type DATETIME_NANOS (#68220)
Moving towards grouping of data types in the field caps API
the internal data type `DATETIME_NANOS` introduced for `date_nanos`
support is eliminated.

Relates: #67722
Follows: #67666
2021-02-10 18:15:54 +01:00
Andrei Stefan
ee5cc5442a
QL: "fields" api implementation in QL (#68802)
* Integrate "fields" API into QL (#68467)
* QL: retry SQL and EQL requests in a mixed-node (rolling upgrade) cluster (#68602)
* Adapt nested fields extraction from "fields" API output to the new un-flattened structure (#68745)
2021-02-10 11:17:10 +02:00
Andras Palinkas
a3dbdae2ef
SQL: Test and fix the NULL handling of the String functions (#68379)
Fixed the inconsistencies regarding NULL argument handling.
NULL literal vs NULL field value as function arguments in some case
resulted in different function return values.

Functions should return with the same value no matter if the argument(s)
came from a field or from a literal.

The introduced integration test tests if function calls with same
argument values (regardless of literal/field) will return with the
same output (also checks if newly added functions are added to the
testcases).

Fixed the following functions:
* Insert: NULL start, length and replacement arguments (as fields) also
result in NULL return value instead of returning the input.
* Locate: NULL pattern results in NULL return value, NULL optional start
argument handled the same as missing start argument
* Replace: NULL pattern and replacement results in NULL instead of
returning the input
* Substring: NULL start or length results in NULL instead of returning
the input

Fixes #58907
2021-02-05 12:30:37 -05:00
James Rodewig
0b4b59c784
[DOCS] Fix typo (#68362) (#68380)
Co-authored-by: Jaskaran Bindra <jskrnbindra@gmail.com>
2021-02-02 09:45:30 -05:00
Marios Trivyzas
bbf3cbfcfa
QL: Implement support for date_nanos ES type. (#67666)
Use an internal new DataType DATETIME_NANOS which is not exposed
and therefore cannot be used for CASTing. DATETIME is used instead
and the precision of both DATETIME and TIME has been promoted from
3 to 9, providing transparency to all datetime functionality regardless
of millis or nanos precision.

Moreover, CURRENT_TIMESTAMP/CURRENT_TIME can now return precision up
to 6 fractional digits of a second with the use of Clock.

Closes: #38562

Co-authored-by: Bogdan Pintea <bogdan.pintea@elastic.co>
2021-01-29 11:07:29 +01:00
Andras Palinkas
f855e5235c
SQL: Implement TO_CHAR() function (#66486)
SQL: Implement the TO_CHAR() function

* The implementation is according to PostgreSQL 13 specs:
https://www.postgresql.org/docs/13/functions-formatting.html
* Tested against actual output from PostgreSQL 13 using randomized inputs
* All the Postgres formats are supported, there is also partial supports
 for the modifiers (`FM` and `TH` are supported)
* Random unit test data generator script in case we need to upgrade the
 formatter in the future
* Documentation
* Integration tests

Co-authored-by: Michał Wąsowicz <mwasowicz7@gmail.com>
Co-authored-by: Andras Palinkas <andras.palinkas@elastic.co>
2021-01-20 18:32:10 -05:00
Bogdan Pintea
638402c387
Abort sorting in case of local agg sort queue overflow (#65687)
In case the local agg sorter queue gets full and no limit has been provided,
the local sorter will now erroneously call the failure callback for every
single row in the original rowset that's left over the local queue limit
(instead for just the first one).  The failure response is dispatched in any
case, so this is relatively harmless.  The sorter continues iterating on the
original response fetching subsequent pages. In case of correct Elasticsearch
behaviour, this is also harmless, it'll just trigger a number of internal
exceptions. However, in case of a pagination defect in Elasticsearch (like
GH#65685, where the same search_after is returned), this will result in an
effective spin loop, potentially rendering eventually the node unresponsive.

This PR simply breaks both the inner loop iterating over the current unsorted
rowset, as well as the outer one, iterating over the left pages.

It also fixes an outdated documentation limitation.
2020-12-03 19:19:15 +01:00
Andras Palinkas
e242eb6a43
SQL: Add method args to PERCENTILE/PERCENTILE_RANK (#65026)
* Adds the capability to have functions with two optional arguments
* Adds two new optional arguments to `PERCENTILE()` and
  `PERCENTILE_RANK()` functions, namely the method and
  method_parameter which can be: 1) `tdigest` and a double `compression`
  parameter or 2) `hdr` and an integer representing the
  `number_of_digits` parameter.
* Integration tests
* Documentation updates

Closes #63567
2020-11-24 14:17:56 -05:00
Bogdan Pintea
6a92b3ec7c
SQL: Remove constant_keyword from SQL docs (#64709)
* Remove constant_keyword from SQL docs

`constant_keyword` removed as distinct type from SQL in #60524.

Co-authored-by: James Rodewig <40268737+jrodewig@users.noreply.github.com>
2020-11-06 20:07:30 +01:00
Andras Palinkas
190d9fe3de
SQL: Escaped wildcard (*) not accepted in LIKE (#63428)
For a query like `SELECT name FROM test WHERE name LIKE ''%c*'` ES SQL
generates an error. `*` is not a special character in a `LIKE` construct
and it's expected to not needing to be escaped, so the previous query
should work as is.
In the LIKE pattern any `*` character was treated as invalid character
and the usage of `%` or `_` was suggested instead. But `*` is a valid,
acceptable non-wildcard on the right side of the `LIKE` operator.

Fix: #55108
2020-10-13 09:38:35 -04:00
Binu R J
da511f4e03
SQL: Implement FORMAT function (#55454)
Implement FORMAT according to the SQL Server spec: https://docs.microsoft.com/en-us/sql/t-sql/functions/format-transact-sql?view=sql-server-ver15#ExampleD by translating to the java.time patterns used in DATETIME_FORMAT.

Closes: #54965

Co-authored-by: Marios Trivyzas <matriv@users.noreply.github.com>
Co-authored-by: Bogdan Pintea <bogdan.pintea@elastic.co>
Co-authored-by: Andrei Stefan <astefan@users.noreply.github.com>
2020-09-21 15:32:11 +02:00
Bogdan Pintea
2bc4d7eb19
SQL: Document Maven Central as a JDBC repository (#62618)
* Add Maven Central as a JDBC repository

Document Maven Central as a JDBC repository.
2020-09-21 12:55:04 +02:00
James Rodewig
f881a695e1
[DOCS] Add redirects for wildcard and constant keyword (#61815) 2020-09-01 15:32:35 -04:00
James Rodewig
a94e5cb7c4
[DOCS] Replace Wikipedia links with attribute (#61171) 2020-08-17 09:44:24 -04:00
Bogdan Pintea
fb6baa85aa
SQL: Update documentation on Tableau integration (#60890)
* Update docs on Tableau Desktop integration

Update the docs on how to integrate with Tableau Desktop, now using the
dedicated connector in conjunction with the JDBC driver.

* Add docs for connecting with Tableau Server

Add the steps required to connecto to Elasticsearch for Tableau Server.

Co-authored-by: James Rodewig <40268737+jrodewig@users.noreply.github.com>
2020-08-17 12:10:15 +02:00
Alexander Reelsen
c7ac9e7073
[DOCS] http -> https, remove outdated plugin docs (#60380)
Plugin discovery documentation contained information about installing
Elasticsearch 2.0 and installing an oracle JDK, both of which is no
longer valid.

While noticing that the instructions used cleartext HTTP to install
packages, this commit replaces HTTPs links instead of HTTP where possible.

In addition a few community links have been removed, as they do not seem
to exist anymore.
2020-07-31 15:58:38 -04:00
James Rodewig
aec26b1a23
[DOCS] Move search pagination content to one page (#60515) 2020-07-31 11:43:06 -04:00
Bogdan Pintea
3a8b00cc74
SQL: Add option to provide the delimiter for the CSV format (#59907)
* Add option to provide the delimiter to the CSV fmt

This adds the option to provide the desired character as the separator
for the CSV format (the default remains comma).
A set of characters are excluded though - like CR, LF, `"` - to avoid
slipping onto the CSV-dialects slope. The tab is also forbidden, the
user needs to choose the "tsv" format explicitely.

Update the doc to make it clear that the textual CSV, TSV and TXT
formats pass the cursor back to the user through the Cursor HTTP header.
2020-07-29 16:08:39 +02:00
James Rodewig
2774cd6938
[DOCS] Swap [float] for [discrete] (#60124)
Changes instances of `[float]` in our docs for `[discrete]`.

Asciidoctor prefers the `[discrete]` tag for floating headings:
https://asciidoctor.org/docs/asciidoc-asciidoctor-diffs/#blocks
2020-07-23 11:48:22 -04:00
Emily Li
8d0cb3b893 Fix grammar mistake in SQL data type docs. (#60028)
Remove an extra 'when'.
2020-07-21 16:15:43 -07:00
James Rodewig
80b674fb25
[DOCS] Reformat snippets to use two-space indents (#59973) 2020-07-21 12:24:26 -04:00
Patrick Jiang(白泽)
647a413d9b
SQL: Implement DATE_PARSE function for parsing strings into DATE values (#57391)
Implement DATE_PARSE(<date_str>, <pattern_str>) function
which allows to parse a date string according to the specified
pattern into a date object. The patterns allowed are those of
java.time.format.DateTimeFormatter.

Closes #54962

Co-authored-by: Marios Trivyzas <matriv@users.noreply.github.com>
2020-07-16 15:33:46 +02:00
Bogdan Pintea
8b29817b49
Add sample versions of standard deviation and variance functions (#59093)
* Add STDDEV_SAMP, VAR_SAMP

This commit adds the sampling variations of the standard deviation and
variance agg functions.
2020-07-09 08:22:01 +02:00
James Rodewig
483bab2281
[DOCS] Add data streams to API conventions (#58695)
Updates the existing API conventions docs to make them aware of data
streams.

Co-authored-by: debadair <debadair@elastic.co>
2020-06-30 17:06:17 -04:00
Bogdan Pintea
94eb5a05e7
SQL: fix handling of escaped chars in JDBC connection string (#58429)
* Fix: preserve URI query and fragment char escaping

This commit fixes an issue emerging when the connection string URI
contains escaped characters.

The original URI is pre-parsed in order to re-assemble a new URI having
the optional elements filled in with defaults. The new URI has been
using however the unescaped query and fragment parts. So if these
contained any escaped `&` or `=` (such as in the password option value),
the unescaping would reveal them and make them later interfere with the
options parsing.

The commit changes that, so that the new URI be built from the unescaped
"raw" parts of the original URI.
2020-06-26 10:19:44 +02:00
Marios Trivyzas
9d6b679a5d
SQL: [Docs] Fix TIME_PARSE documentation (#58182)
TIME_PARSE works correctly if both date and time parts are specified,
and a TIME object (that contains only time is returned).

Adjust docs and add a unit test that validates the behavior.

Follows: #55223
2020-06-18 12:35:58 +02:00
Marios Trivyzas
6c86c919e1
SQL: Implement TRIM function (#57518)
Add `TRIM` function which combines the functionality of both
`LTRIM` and `RTRIM` by stripping both leading and trailing
whitespaces.

Refers to #41195
2020-06-03 14:24:30 +02:00
Marios Trivyzas
2f5ab81b9a
SQL: Implement TOP as an alternative to LIMIT (#57428)
Add basic support for `TOP X` as a synonym to LIMIT X which is used
by [MS-SQL server](https://docs.microsoft.com/en-us/sql/t-sql/queries/top-transact-sql?view=sql-server-ver15),
e.g.:

```
SELECT TOP 5 a, b, c FROM test
```

TOP in SQL server also supports the `PERCENTAGE` and `WITH TIES`
keywords which this implementation doesn't.

Don't allow usage of both TOP and LIMIT in the same query.

Refers to #41195
2020-06-02 09:56:20 +02:00
Patrick Jiang(白泽)
1fe1188d44
SQL: Implement TIME_PARSE function for parsing strings into TIME values (#55223)
Implement TIME_PARSE(<time_str>, <pattern_str>) function
which allows to parse a time string according to the specified
pattern into a time object. The patterns allowed are those of
java.time.format.DateTimeFormatter.

Closes #54963

Co-authored-by: Andrei Stefan <astefan@users.noreply.github.com>
Co-authored-by: Marios Trivyzas <matriv@users.noreply.github.com>
2020-05-29 10:43:49 +02:00
Marios Trivyzas
c09f4a0448
SQL: [Tests] Move JDBC integration tests to new module (#56872)
Move the JDBC functionality integration tests from `:sql:qa` to a separate
module `:sql:qa:jdbc`. This way the tests are isolated from the rest of the 
integration tests and they only depend to the `:sql:jdbc` module, thus 
removing the danger of accidentally pulling in some dependency that may
hide bugs.

Moreover this is a preparation for #56722, so that we can run those tests
between different JDBC and ES node versions and ensure forward
compatibility.

Move the rest of existing tests inside a new `:sql:qa:server` project, so that
the `:sql:qa` becomes the parent project for both and one can run all the integration
tests by using this parent project.
2020-05-22 15:52:41 +02:00
Marios Trivyzas
1a5945c396
SQL: Fix JDBC url pattern in docs and error message (#56612)
The docs pattern url was using `*` which means zero or many instead
of `?` which means zero or one. The pattern url returned in error
messages was not in sync with the one in the docs.

Fixes: #56476
2020-05-13 12:12:23 +02:00
Andrei Stefan
ee5a09ea84
QL: case sensitive support in EQL (#56404)
* * StartsWith is case sensitive aware
* Added case sensitivity to EQL configuration
* case_sensitive parameter can be specified when running queries (default
is case insensitive)
* Added STARTS_WITH function to SQL as well

* Add case sensitive aware queryfolder tests

* Address reviews

* Address review #2
2020-05-12 15:05:43 +03:00
Marios Trivyzas
8810ed03a2
SQL: Fix DATETIME_PARSE behaviour regarding timezones (#56158)
Previously, when the timezone was missing from the datetime string
and the pattern, UTC was used, instead of the session defined timezone.
Moreover, if a timezone was included in the datetime string and the
pattern then this timezone was used. To have a consistent behaviour
the resulting datetime will always be converted to the session defined
timezone, e.g.:
```
SELECT DATETIME_PARSE('2020-05-04 10:20:30.123 +02:00', 'HH:mm:ss dd/MM/uuuu VV') AS datetime;
```
with `time_zone` set to `-03:00` will result in
```
2020-05-04T05:20:40.123-03:00
```

Follows: #54960
2020-05-05 11:13:47 +02:00
James Rodewig
9268574bb4
[DOCS] SQL: Update link for supported regex in RLIKE docs (#55830)
The`RLIKE` function docs points users to [Java’s Pattern class doc][0]
for regular expression syntax. However, these docs include shorthand
character classes, such as `[\d]`, `[\s]`, and `[\w]`. These character
classes are not supported in Elasticsearch, which may confuse users.

This updates the SQL `RLIKE` docs to refer to the ES [regular expression
syntax docs][1], which only documents supported syntax.

[0]: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/regex/Pattern.html
[1]: https://www.elastic.co/guide/en/elasticsearch/reference/master/regexp-syntax.html

Relates to #55231
2020-04-28 09:24:31 -04:00
jmceniery
719fa2735f
[DOCS] Remove Wikipedia link from SUM_OF_SQUARES SQL function docs (#52398)
Removed the link to Wikipedia as the function is not calculating the sum of squares in this way. More can be found here at this issue:

https://github.com/elastic/elasticsearch/issues/50416
2020-04-20 09:58:30 -04:00
Marios Trivyzas
506d1beea7
SQL: Implement scripting inside aggs (#55241)
Implement the use of scalar functions inside aggregate functions.
This allows for complex expressions inside aggregations, with or without
GROUBY as well as with or without a HAVING clause. e.g.:

```
SELECT MAX(CASE WHEN a IS NULL then -1 ELSE abs(a * 10) + 1 END) AS max, b
FROM test
GROUP BY b
HAVING MAX(CASE WHEN a IS NULL then -1 ELSE abs(a * 10) + 1 END) > 5
```

Scalar functions are still not allowed for `KURTOSIS` and `SKEWNESS` as
this is currently not implemented on the ElasticSearch side.

Fixes: #29980
Fixes: #36865
Fixes: #37271
2020-04-17 11:22:06 +02:00
Marios Trivyzas
3febcd8f3c
SQL: Implement DATETIME_PARSE function for parsing strings (#54960)
Implement DATETIME_PARSE(<datetime_str>, <pattern_str>) function
which allows to parse a datetime string according to the specified
pattern into a datetime object. The patterns allowed are those of
java.time.format.DateTimeFormatter.

Relates to #53714
2020-04-10 00:19:31 +02:00
Marios Trivyzas
72be0b54a9
SQL: Implement DATETIME_FORMAT function for date/time formatting (#54832)
Implement DATETIME_FORMAT(<date/datetime/time>, ) function
which allows for formatting a timestamp to the specified format. The 
patterns allowed as those of java.time.format.DateTimeFormatter.

Related to #53714
2020-04-08 11:49:50 +02:00
Bogdan Pintea
f38761631a
ODBC: Document the new VarcharLimit and EarlyExecution params (#54632)
* Document VarcharLimit and EarlyExecution params

Add the documentation for the newly added VarcharLimit and
EarlyExecution DSN attributes.

* Remove obsolete VersionChecking param

This param had been removed already along the #53082 work.

* Update docs/reference/sql/endpoints/odbc/configuration.asciidoc

fix typo

Co-Authored-By: Stuart Cam <stuart@codebrain.co.uk>

* Update docs/reference/sql/endpoints/odbc/configuration.asciidoc

fix typo

Co-Authored-By: Stuart Cam <stuart@codebrain.co.uk>
2020-04-03 14:44:25 +02:00
musteaf
2dc7950582
SQL: Extend DATE_TRUNC to also operate on intervals(elastic - #46632 ) (#47720)
The function is extended to operate on intervals according to the PostgreSQL: https://www.postgresql.org/docs/9.1/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC

Closes : #46632
2020-03-23 12:52:25 +01:00
Andrei Stefan
d6cd4ce784
QL: constant_keyword support (#53241) 2020-03-16 15:22:42 +02:00
James Rodewig
9f641dc07d
[DOCS] Fix several Asciidoctor double arrow replacements (#52827)
Per the [Asciidoctor docs][0], Asciidoctor replaces the following
syntax with double arrows in the rendered HTML:

* => renders as ⇒
* <= renders as ⇐

This escapes several unintended replacements, such as in the Painless
docs.

Where appropriate, it also replaces some double arrow instances with
single arrows for consistency.

[0]: https://asciidoctor.org/docs/user-manual/#replacements
2020-03-04 08:42:37 -05:00
Bogdan Pintea
451c341e01
remove references to the SQL API from ODBC config (#52765)
Remove reference to an "SQL API" which could suggest that one needs to
treat this in a special way when configuring the ODBC driver.
2020-02-26 13:32:22 +01:00
Andrei Stefan
556f5fa33b
SQL: Use calendar_interval of 1d for HISTOGRAMs with 1 DAY intervals (#52749) 2020-02-25 17:33:36 +02:00
Andrei Stefan
928b11a34e
SQL: use a calendar interval for histograms over 1 month intervals (#52586) 2020-02-24 18:02:34 +02:00
Andrei Stefan
477b0eda83
SQL: specify command to run the CLI on a remote machine without Elasticsearch (#52626) 2020-02-21 13:26:31 +02:00
Bogdan Pintea
afa67625e8
SQL: update ODBC docs, cover Cloud ID, latest params (#52291)
* Refresh snapshots with latest look

Add new snapshots with the connection editor to reflect the latest UI.

* Document the effect of the late added params

Add details about the Cloud ID setting, as well as those on the Misc
tab.
2020-02-19 17:33:48 +01:00
debadair
83a94913ec
[DOCS] Clean up links from SQL client app pages. (#52442)
* [DOCS] Clean up links from SQL client app pages.

* Linked to client apps from prereqs.
2020-02-18 12:41:05 -08:00
Andrei Stefan
9fad0b1ac4
SQL: document the use of a filter on _routing (#52355)
* Fix "Description"s for various sections in the functions pages.
* Added a TIP for searching using a routing key.
* Other small polishings
2020-02-14 18:58:45 +02:00
Marios Trivyzas
b847742b23
SQL: [Docs] Fix typo
Add missing closing "`".

Follows: 78a1185549
2020-02-12 21:48:36 +01:00