Commit graph

192 commits

Author SHA1 Message Date
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
Marios Trivyzas
78a1185549
SQL: [Docs] Add limitation for sorting on aggs (#52210)
Add a section to point out that when ordering by an aggregate
only plain aggregate functions are allowed, no scalars/operators
can be used on top of them.

Fixes: #52204
2020-02-12 12:54:42 +01:00
Marios Trivyzas
f41efd6753
SQL: Fix ORDER BY YEAR() function (#51562)
Previously, if YEAR() was used as and ORDER BY argument without being
wrapped with another scalar (e.g. YEAR(birth_date) + 10), no script
ordering was used but instead the underlying field (e.g. birth_date)
was used instead as a performance optimisation. This works correctly if
YEAR() is the only ORDER BY arg but if further args are used as tie
breakers for the ordering wrong results are produced. This is because
2 rows with the different birth_date but on the same year are not tied
as the underlying ordering is on birth_date and not on the
YEAR(birth_date), and the following ORDER BY args are ignored.

Remove this optimisation for YEAR() to avoid incorrect results in
such cases.

As a consequence another bug is revealed: scalar functions on top
of nested fields produce scripted sorting/filtering which is not yet
supported. In such cases no error was thrown but instead all values for
such nested fields were null and were passed to the script implementing
the sorting/filtering, producing incorrect results.

Detect such cases and throw a validation exception.

Fixes: #51224
2020-01-30 14:48:34 +01:00
Andrei Stefan
45b8bf619a
SQL: add support for passing query parameters in REST API calls (#51029)
* REST PreparedStatement-like query parameters are now supported in the form of an array of non-object, non-array values where ES SQL parser will try to infer the data type of the value being passed as parameter.
2020-01-20 15:29:53 +02:00
James Rodewig
a5b6242aa5
[DOCS] Update SQL REST API pages for new structure (#50690)
#43007 restructured the SQL REST API docs so they display across several pages.

This updates up a reference that assumes a single page in the "Paginating through a large response" section. It also reformats a tip for the Kibana console.

Closes #50688
2020-01-07 09:17:54 -06:00
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