Commit Graph

136 Commits

Author SHA1 Message Date
Costin Leau b8c9c5325c SQL: add catalog filter to SYS COLUMNS command (elastic/x-pack-elasticsearch#3978)
Add basic support for catalog parameters in SYS COLUMN
Pass an empty string instead of a null inside the prepared statement
Don't use pattern for catalog in getColumns

Original commit: elastic/x-pack-elasticsearch@17e9e851a0
2018-02-25 05:08:48 +02:00
Ryan Ernst d7c097e2b4 Build: Remove specifying zip distribution in qa tests (elastic/x-pack-elasticsearch#4037)
This is the xpack side of https://github.com/elastic/elasticsearch/pull/28805

Original commit: elastic/x-pack-elasticsearch@48cbe6623f
2018-02-23 18:17:59 -08:00
Lee Hinman 6728912c87 Handle removing log4j dependency from elasticsearch-core jar (elastic/x-pack-elasticsearch#3976)
This handles the removal of the log4j dependency from our elasticsearch-core
project. It was originally necessary only for our jar classpath checking. It is
now replaced by a `Consumer<String>`.

This is the x-pack side of https://github.com/elastic/elasticsearch/pull/28705

Original commit: elastic/x-pack-elasticsearch@1186a7eaf6
2018-02-20 09:15:56 -07:00
Costin Leau bc150c2521 SQL: Fix failing percentiles in JdbcCsvSpecIT
Original commit: elastic/x-pack-elasticsearch@da332afa9a
2018-02-15 22:34:13 +02:00
Costin Leau 844c485e0d SQL: introduce SYS CATALOGS and TABLE TYPES commands (elastic/x-pack-elasticsearch#3941)
These are the equivalent of JDBC/ODBC getCatalogs and getTableTypes on
the server side.

Original commit: elastic/x-pack-elasticsearch@a6fa733680
2018-02-15 21:51:23 +02:00
Andy Bristol b042afdfdc [TEST] AwaitsFix JdbcCsvSpecIT
For elastic/x-pack-elasticsearch#3960

Original commit: elastic/x-pack-elasticsearch@c0c1ff7d07
2018-02-15 11:25:57 -08:00
Costin Leau f04036a1bd SQL: update percentile tests to reflect the t-digest upgrade
The commit to t-digest 3.2 elastic/x-pack-elasticsearch#28305, changed the results of percentiles
(more information https://github.com/elastic/elasticsearch/pull/28305
#issuecomment-362542140)
This commit updates the tests accordingly.

Original commit: elastic/x-pack-elasticsearch@f2351ce747
2018-02-15 17:44:03 +02:00
Costin Leau a5b129c10c SQL: Introduce the catalog concept inside the grammar (elastic/x-pack-elasticsearch#3911)
Indices can now specify the catalog (the cluster) in which they belong.
This is a first step in supporting both CCS and BI tools which tend to
be explicit

Original commit: elastic/x-pack-elasticsearch@0b4633facc
2018-02-14 12:30:32 +02:00
Tim Brooks 5dbbe8fef8 Default to basic license at startup (elastic/x-pack-elasticsearch#3878)
This is related to elastic/x-pack-elasticsearch#3877. This commit modifies the license settings to
default to self generating a basic license.

Original commit: elastic/x-pack-elasticsearch@cd6ee8e06f
2018-02-12 12:57:04 -07:00
Ryan Ernst 7d71c3f1cc Build: Remove refs to x-pack-elasticsearch (elastic/x-pack-elasticsearch#3863)
These were removed before, but sql added a bunch of new hard references
to the project name.

Original commit: elastic/x-pack-elasticsearch@2eb156fd67
2018-02-07 20:50:12 -08:00
Nik Everett c53e1f4b1c SQL: More tests and docs for permissions (elastic/x-pack-elasticsearch#3679)
Adds tests for what works and what doesn't when we're missing some of
SQL's required permissions.

Adds required permissions to the documentation of each SQL access
method.

relates elastic/x-pack-elasticsearch#3552

Original commit: elastic/x-pack-elasticsearch@971dabb3b4
2018-02-01 17:20:44 -05:00
Costin Leau 07658cc04f SQL: replace JDBC transport meta columns with SQL call (elastic/x-pack-elasticsearch#3740)
Replace meta column endpoint with SYS COLUMNS command

Original commit: elastic/x-pack-elasticsearch@819874bc5b
2018-01-29 19:18:24 +02:00
Costin Leau e929d16d76 SQL: Replace ListTable transport with SQL command (elastic/x-pack-elasticsearch#3675)
Introduce system commands as alternative to meta HTTP endpoints
Pass in cluster name
Use 'BASE TABLE' instead of 'INDEX' when describing a table to stick
with the SQL terminology

Original commit: elastic/x-pack-elasticsearch@600312b8f7
2018-01-27 11:54:19 +02:00
Igor Motov de15f7123b Merge remote-tracking branch 'elastic/master' into feature/sql_2
Original commit: elastic/x-pack-elasticsearch@bbabfb1328
2018-01-23 15:41:59 -05:00
Nik Everett 52f7ba8c5d SQL: Docs for basic aggregations
Adds documentation for basic aggregate functions supported by
Elasticsearch SQL.

Relates to elastic/x-pack-elasticsearch#2898

Original commit: elastic/x-pack-elasticsearch@ddc71165f2
2018-01-23 11:32:21 -05:00
Nik Everett d2ea36416b SQL: Expose WEEK function and document datetime functions (elastic/x-pack-elasticsearch#3680)
Adds documentation for all of the date time functions using the new
cli-like format extracted from the csv spec. In the process of doing
this I noticed that the `WEEK` function isn't exposed as a function.
This exposes it for consistency.

Relates to elastic/x-pack-elasticsearch#2898

Original commit: elastic/x-pack-elasticsearch@0459b24cb9
2018-01-23 07:11:43 -05:00
Igor Motov 6330209e7d Merge remote-tracking branch 'elastic/master' into feature/sql_2
Original commit: elastic/x-pack-elasticsearch@95cbd93803
2018-01-22 16:03:56 -05:00
Nik Everett 51a6285ba1 SQL: Allow CSV tests to look more like the CLI (elastic/x-pack-elasticsearch#3640)
This allows CSV tests to include a line between the header and the
values that is ignored by the test framework. This optional line can be
added to the tests to make them a little easier to read which is useful
when they are included in the documentation. As a side effect they also
closely mimick the output of the CLI. To the point where you can copy
directly from the CLI and paste into the CSV tests.

Example:
```
constantYear
// tag::year
SELECT YEAR(CAST('2018-01-19T10:23:27Z' AS TIMESTAMP)) as year;
     year
---------------
2018
// end::year
;
```

This can be extracted with a construct like this in the docs:
```
["source","sql",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{sql-specs}/datetime.csv-spec[year]
--------------------------------------------------
```

Which makes documentation that looks like this:
```
SELECT YEAR(CAST('2018-01-19T10:23:27Z' AS TIMESTAMP)) as year;
     year
---------------
2018
```

Which is fairly nice.

Original commit: elastic/x-pack-elasticsearch@8c10b5cb10
2018-01-19 16:24:42 -05:00
Nik Everett b165f1c71e SQL: Fix constant folding of datetime functions (elastic/x-pack-elasticsearch#3637)
I went to write some docs for datetime functions that look like:
```
SELECT YEAR(CAST('2018-01-19T10:23:27Z' AS TIMESTAMP)) as year;

  year
2018

```
because I figured they'd be pretty easy to read because they didn't
require any knowledge of a data set. But it turns out that constant
folding doesn't work properly for date time functions because they don't
actually apply the extraction.

Original commit: elastic/x-pack-elasticsearch@aa9c66b2c7
2018-01-19 15:11:37 -05:00
Nik Everett b9dbb6d204 SQL: Run fewer tests against multiple nodes (elastic/x-pack-elasticsearch#3625)
Rather than run every SQL test against multiple nodes we instead run a
subset of the tests simply for speed. The subset is both small but
exercises the CLI, JDBC, and REST interface and a few special "these
might be different in against multiple nodes" cases.

This drops the run time from of `gradle clean check` of these tests from
```
BUILD SUCCESSFUL in 4m 49s
```

To:
```
BUILD SUCCESSFUL in 2m 49s
```

Original commit: elastic/x-pack-elasticsearch@dcd99bcd82
2018-01-18 15:59:40 -05:00
Costin Leau e48589aa65 Fix CLI test
Original commit: elastic/x-pack-elasticsearch@8a31108b09
2018-01-18 22:33:47 +02:00
Nik Everett 9b6f417df6 SQL: Move the jdbc directory into plugin/sql (elastic/x-pack-elasticsearch#3617)
This is the next step in removing the top level `sql` directory.

Related to elastic/x-pack-elasticsearch#3363

Original commit: elastic/x-pack-elasticsearch@948c3e3583
2018-01-18 09:33:16 -05:00
Costin Leau 1dd98eab83 SQL: Fix show tables as admin (elastic/x-pack-elasticsearch#3597)
Fix show tables as JDBC with security enabled
This commit fixes the test SqlSecurityTestCase.testShowTablesWorksAsAdmin to
skip over any indices/aliases that exist starting with `.security`.
Use value comparison instead of the result sets
Fix an offset bug while at it (columns start at 1 not 0)
Resolves elastic/x-pack-elasticsearch#3423

Original commit: elastic/x-pack-elasticsearch@6fffda6070
2018-01-18 16:13:01 +02:00
Nik Everett 753d21f3c6 SQL: Move CLI into plugin/sql directory (elastic/x-pack-elasticsearch#3606)
This is the next step in removing the top level sql directory.

I named the directory `sql-cli` instead of `cli` because that puts it at
the maven coordinates `org.elasticsearch.plugin:sql-cli` instead of
`org.elasticsearch.plugin:cli`.

Relates to elastic/x-pack-elasticsearch#3363

Original commit: elastic/x-pack-elasticsearch@d41a57a136
2018-01-18 08:39:02 -05:00
Nik Everett 310d1d2302 SQL: Move `sql:server` to `plugin:sql` (elastic/x-pack-elasticsearch#3604)
This moves SQL's server project into `plugin:sql` without modifying how the integration is performed. I know that it is not correct with regards to the x-pack modularization but I think it is a good first step.

Original commit: elastic/x-pack-elasticsearch@2f40d02e4d
2018-01-17 15:48:58 -05:00
Costin Leau 41c1c5fdd1 SQL: close ResultSet after asserting (elastic/x-pack-elasticsearch#3601)
The on-closing Connection is closed so there's no leak however closing
the ResultSet is good practice and tests another piece of code as well

Original commit: elastic/x-pack-elasticsearch@3a9cee70a3
2018-01-17 22:14:07 +02:00
Nik Everett d6e292087b SQL: Drop embedded qa mode (elastic/x-pack-elasticsearch#3602)
It will conflict with moving the `sql:server` project to `plugin:sql`
and we're fairly sure we need to rework or remove it anyway.

relates elastic/x-pack-elasticsearch#3557

Original commit: elastic/x-pack-elasticsearch@763072c182
2018-01-17 15:04:14 -05:00
Igor Motov c3b82e5ee1 SQL: Remove test-utils project (elastic/x-pack-elasticsearch#3583)
Makes Sql Translate Action consistent with other SQL Actions and removes test-utils project

Follow up for elastic/x-pack-elasticsearch#3543

Original commit: elastic/x-pack-elasticsearch@8ff2148d67
2018-01-17 12:18:25 -05:00
Lee Hinman f53a19374b SQL: Wrap coercion in JdbcResultSet to throw SQLException (elastic/x-pack-elasticsearch#3559)
* SQL: Wrap coercion in JdbcResultSet to throw SQLException

This catches the `ClassCastException` that could be thrown when retrieving data
from a result set, instead converting it into a `SQLException`.

Resolves elastic/x-pack-elasticsearch#3207

* Add simple test for incorrect coercion

Original commit: elastic/x-pack-elasticsearch@5480a48d95
2018-01-16 14:39:20 -07:00
Igor Motov 9401569195 SQL: Adapt to compile and runtime Java home distinction
Relates elastic/x-pack-elasticsearch#3477

Original commit: elastic/x-pack-elasticsearch@5791617988
2018-01-16 14:53:49 -05:00
Igor Motov 12d4f10faa SQL: Switch JDBC to REST protocol (elastic/x-pack-elasticsearch#3543)
Replaces binary serialization protocol in JDBC driver with the common REST protocol.

relates elastic/x-pack-elasticsearch#3419

Original commit: elastic/x-pack-elasticsearch@532c106658
2018-01-16 13:26:06 -05:00
Costin Leau 7d3c6a778f SQL: update support for nested docs (elastic/x-pack-elasticsearch#3546)
* SQL: update support for nested docs

Expand sample data with nested docs
Optimize source generation for nested parents
Nested objects fields are specified in inner-hits and don't need to be
specified at the top-level query. Further more disable parent source if
not needed.
ComputingFieldRef needs to return the hitName of its wrapped children
otherwise nested values cannot be extracted
Disable GROUP BY/HAVING on nested fields
Update FieldAttribute requirements in the random tests

Original commit: elastic/x-pack-elasticsearch@e44951b5f6
2018-01-16 16:59:22 +02:00
Igor Motov ce81a34467 SQL: Add jdbc mode to REST API (elastic/x-pack-elasticsearch#3499)
Adds a mode parameter to all SQL-related requests. The mode parameter is used for license checks as well as to define the response content. For now only two modes are supported plain (default) and jdbc. We will add other modes in the future as we add more clients.

Relates elastic/x-pack-elasticsearch#3419 

Original commit: elastic/x-pack-elasticsearch@b49ca38d4b
2018-01-10 09:41:36 -05:00
Lee Hinman 0865063740 SQL: Fix multi-line CLI commands to join correctly (elastic/x-pack-elasticsearch#3516)
Previously multi-line CLI SQL statements were joined, but the space command was
missing, so a command like:

```
sql> SHOW
   | functions;
```

Would incorrectly parse as "showfunctions" and throw an error.

This fixes the behavior and adds a test for multi-line commands.

Resolves elastic/x-pack-elasticsearch#3410

Original commit: elastic/x-pack-elasticsearch@3870924ccd
2018-01-09 16:55:30 -07:00
Costin Leau 8257d8d76a SQL: Extend grammar to allow wildcard in the grammar without quotes (elastic/x-pack-elasticsearch#3501)
Tweak the grammar to differentiate between table and normal identifier.
The table one allows wildcard while the normal one (for fields) does not.

Original commit: elastic/x-pack-elasticsearch@a714e950db
2018-01-09 19:30:50 +02:00
Costin Leau 25a00a3b55 SQL: Check null in processor (elastic/x-pack-elasticsearch#3494)
Make Processors resilient to NULL values
Check null only in functions not constants

Original commit: elastic/x-pack-elasticsearch@dd8bd16d49
2018-01-09 16:18:16 +02:00
Costin Leau aa85496090 Make debug tests abstract again
Original commit: elastic/x-pack-elasticsearch@1c9b60d556
2018-01-07 00:12:44 +02:00
Costin Leau ba81321d0d SQL: Support aliases and indices pattern (elastic/x-pack-elasticsearch#3438)
Add support for aliases and indices pattern
Enhance ShowTable info to differentiate between aliases and indices
Add regex filtering of index names
Handle security exceptions (in case of no privileges or no matching)

Original commit: elastic/x-pack-elasticsearch@91e3674ca7
2018-01-06 23:08:16 +02:00
Igor Motov 9f71100bac SQL: Fix CLI tests with security on Windows
We test on Windows with the terminal in unix mode, so we need to make sure we send `\n` instead of `\r\n`. In this case the extra `\n` after password was causing an extra new line in tests breaking them on Windows.

Original commit: elastic/x-pack-elasticsearch@721ba32bd6
2017-12-28 21:40:03 -05:00
Igor Motov 178d6ca6b3 SQL: Move shared REST client methods to shared-client (elastic/x-pack-elasticsearch#3428)
* SQL: Move shared REST client methods to shared-client

This commit is a preliminary step for moving JDBC to the REST client. It extracts the common REST clients from CLI and moves it to shared-client. This will allow us to move to the 5 project setup: rest-proto, shared-client, server, jdbc, cli with the following dependencies:

server <-- rest-proto
shared-client <-- rest-proto
jdbc <-- shared-client
cli <-- shared-client

Relates to elastic/x-pack-elasticsearch#3419

Original commit: elastic/x-pack-elasticsearch@2e6a134de0
2017-12-28 11:10:18 -05:00
Igor Motov 292506526e Merge remote-tracking branch 'elastic/master' into feature/sql_2
Original commit: elastic/x-pack-elasticsearch@79e7b1b953
2017-12-27 21:46:00 -05:00
Igor Motov 3892da7a3d SQL: Suppress testShowTablesWorksAsAdmin() tests
These tests are relying on existence of an internal index that might or might not be present when we run this test.

Tracked by elastic/x-pack-elasticsearch#3423

Original commit: elastic/x-pack-elasticsearch@26a7795759
2017-12-26 12:53:21 -05:00
Costin Leau 5a25213db9 Update security tests
Original commit: elastic/x-pack-elasticsearch@732a4c5850
2017-12-23 15:44:27 +02:00
Costin Leau b437341ddc Remove old class
Original commit: elastic/x-pack-elasticsearch@e075c3b972
2017-12-23 13:35:42 +02:00
Costin Leau 368099dcbd SQL: Add support for object/inner/dotted fields (elastic/x-pack-elasticsearch#3368)
* SQL: Add support for object/inner/dotted fields

Improve validation when selecting compound fields
Improve fallback to exact field for text fields
Consolidate various field attributes into one
Consolidate various field HitExtractors into one
Improve grammar for column declaration
Update response of embedded server
Improve index validation to allow use of internal indices
Add clean-up of scroll in case of server errors
By default thrown an exception on multi-valued fields

Original commit: elastic/x-pack-elasticsearch@45b73fe0dc
2017-12-23 13:19:54 +02:00
Igor Motov e18c7e92fa SQL: Switch CLI to REST protocol (elastic/x-pack-elasticsearch#3342)
Removes custom binary protocol used for CLI communication and switches CLI to REST.

relates elastic/x-pack-elasticsearch#3063

Original commit: elastic/x-pack-elasticsearch@b42bdcdc35
2017-12-22 20:42:13 -10:00
Nik Everett 1cf9d6e3f3 SQL: Document a few functions (elastic/x-pack-elasticsearch#3390)
* Starts to build the list of supported functions, adding links to
wikipedia when there is any doubt what the functions mean.
* Extracts an example of using the function from the test suite.
* Explicitly calls out how we round (half up) because there are
lots of ways to round.

Original commit: elastic/x-pack-elasticsearch@5fb64ba869
2017-12-20 17:42:29 -05:00
Lee Hinman c26f039207 SQL: Add all QUERY() query options (elastic/x-pack-elasticsearch#3389)
This adds support for (almost) all of the options that the `query_string` query
supports.

Additionally, it reverts back to the default operator of `OR` rather than `AND`
for the `QUERY()` query.

Relates to elastic/x-pack-elasticsearch#3361

Original commit: elastic/x-pack-elasticsearch@da8b29b53c
2017-12-20 15:05:40 -07:00
Lee Hinman 5b47c67dec SQL: Add all MATCH() query options (elastic/x-pack-elasticsearch#3387)
* SQL: Add all MATCH() query options

This adds support for (almost) all of the options that the `match` query
supports.

Additionally, it reverts back to the default operator of `OR` rather than `AND`
for the `MATCH()` query.

Relates to elastic/x-pack-elasticsearch#3361

* Add getters required for Node usage

Original commit: elastic/x-pack-elasticsearch@144e2bec02
2017-12-20 12:35:32 -07:00
Nik Everett 42d1c62d03 SQL: Nicer failure message one EXISTS (elastic/x-pack-elasticsearch#3384)
We don't support the SQL `EXISTS` keyword. It looks like:
```
SELECT * FROM test WHERE EXISTS (SELECT * FROM foo WHERE test.id =
foo.id)
```

It is basically a `JOIN` that doesn't return columns. Since we don't
support `JOIN`, we don't support `EXISTS`.

This PR improves the error message from "unresolved blah blah blah" to
"EXISTS is not yet supported".

relates elastic/x-pack-elasticsearch#3176

Original commit: elastic/x-pack-elasticsearch@548d57c8c1
2017-12-20 12:04:46 -05:00