SQL: Add CCS SQL documentation (#81545)

This adds the documentation for CCS SQL.

Co-authored-by: James Rodewig <james.rodewig@elastic.co>
This commit is contained in:
Bogdan Pintea 2022-01-05 20:01:01 +01:00 committed by GitHub
parent 9dc8aea1cb
commit 13a0e420a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 134 additions and 34 deletions

View file

@ -54,6 +54,12 @@ precedence.
[[sql-search-api-request-body]]
==== {api-request-body-title}
`catalog`::
(Optional, string) Default catalog (cluster) for queries. If unspecified, the
queries execute on the data in the local cluster only.
+
experimental:[] See <<modules-cross-cluster-search,{ccs}>>.
`columnar`::
(Optional, Boolean) If `true`, returns results in a columnar format. Defaults to
`false`. The API only supports this parameter for CBOR, JSON, SMILE, and YAML

View file

@ -148,6 +148,13 @@ will be - typically the first in natural ascending order) for fields with multip
==== Index
`index.include.frozen` (default `false`):: Whether to include frozen indices in the query execution or not (default).
[discrete]
==== Cluster
`catalog`:: Default catalog (cluster) for queries. If unspecified, the
queries execute on the data in the local cluster only.
+
experimental:[] See <<modules-cross-cluster-search,{ccs}>>.
[discrete]
==== Additional

View file

@ -34,6 +34,19 @@ include-tagged::{sql-specs}/docs/docs.csv-spec[fromTablePatternQuoted]
NOTE: There is the restriction that all resolved concrete tables have the exact same mapping.
experimental:[] To run a <<modules-cross-cluster-search,{ccs}>>, specify a
cluster name using the `<remote_cluster>:<target>` syntax, where
`<remote_cluster>` maps to a SQL catalog (cluster) and `<target>` to a table
(index or data stream). The `<remote_cluster>` supports wildcards (`*`)
and `<target>` can be an index pattern.
For example:
[source, sql]
----
include-tagged::{sql-specs}/multi-cluster-with-security/multi-cluster-docs.csv-spec[fromQualifiedTableQuoted]
----
[[sql-index-patterns-like]]
[discrete]
==== SQL `LIKE` notation

View file

@ -5,25 +5,17 @@
.Synopsis:
[source, sql]
----
DESCRIBE
[table identifier | <1>
[LIKE pattern]] <2>
DESCRIBE | DESC
[CATALOG identifier]? <1>
[INCLUDE FROZEN]? <2>
[table_identifier | <3>
LIKE pattern] <4>
----
<1> single table identifier or double quoted es multi index
<2> SQL LIKE pattern
or
[source, sql]
----
DESC
[table identifier | <1>
[LIKE pattern]] <2>
----
<1> single table identifier or double quoted es multi index
<2> SQL LIKE pattern
<1> Catalog (cluster) identifier. Supports wildcards (`*`).
<2> Whether or not to include frozen indices.
<3> Single table (index or data stream) identifier or double-quoted multi-target pattern.
<4> SQL LIKE pattern matching table names.
*Description*: `DESC` and `DESCRIBE` are aliases to <<sql-syntax-show-columns>>.

View file

@ -6,12 +6,14 @@ This section contains the list of SQL commands supported by {es-sql} along with
<<sql-syntax-describe-table>>:: Describe a table.
<<sql-syntax-select>>:: Retrieve rows from zero or more tables.
<<sql-syntax-show-catalogs>>:: List available catalogs.
<<sql-syntax-show-columns>>:: List columns in table.
<<sql-syntax-show-functions>>:: List supported functions.
<<sql-syntax-show-tables>>:: List tables available.
include::describe-table.asciidoc[]
include::select.asciidoc[]
include::show-catalogs.asciidoc[]
include::show-columns.asciidoc[]
include::show-functions.asciidoc[]
include::show-tables.asciidoc[]

View file

@ -123,6 +123,17 @@ The name can be a <<multi-index, pattern>> pointing to multiple indices (likely
include-tagged::{sql-specs}/docs/docs.csv-spec[fromTablePatternQuoted]
----
experimental:[] To run a <<modules-cross-cluster-search,{ccs}>>, specify a
cluster name using the `<remote_cluster>:<target>` syntax, where
`<remote_cluster>` maps to a SQL catalog (cluster) and `<target>` to a table
(index or data stream). The `<remote_cluster>` supports wildcards (`*`)
and `<target>` can be an <<sql-index-patterns, index pattern>>.
[source, sql]
----
include-tagged::{sql-specs}/multi-cluster-with-security/multi-cluster-docs.csv-spec[fromQualifiedTableQuoted]
----
`alias`::
A substitute name for the `FROM` item containing the alias. An alias is used for brevity or to eliminate ambiguity. When an alias is provided, it completely hides the actual name of the table and must be used in its place.
@ -334,7 +345,7 @@ include-tagged::{sql-specs}/docs/docs.csv-spec[orderByBasic]
[[sql-syntax-order-by-grouping]]
==== Order By and Grouping
For queries that perform grouping, ordering can be applied either on the grouping columns (by default ascending) or on aggregate functions.
For queries that perform grouping, ordering can be applied either on the grouping columns (by default ascending) or on aggregate functions.
NOTE: With `GROUP BY`, make sure the ordering targets the resulting group - applying it to individual elements inside the group will have no impact on the results since regardless of the order, values inside the group are aggregated.
@ -370,7 +381,7 @@ When doing full-text queries in the `WHERE` clause, results can be returned base
NOTE: When doing multiple text queries in the `WHERE` clause then, their scores will be
combined using the same rules as {es}'s
<<query-dsl-bool-query,bool query>>.
<<query-dsl-bool-query,bool query>>.
To sort based on the `score`, use the special function `SCORE()`:

View file

@ -0,0 +1,17 @@
[role="xpack"]
[[sql-syntax-show-catalogs]]
=== SHOW CATALOGS
.Synopsis:
[source, sql]
----
SHOW CATALOGS
----
*Description*: List the available catalogs and their types.
[source, sql]
----
include-tagged::{sql-specs}/multi-cluster-with-security/multi-cluster-command.csv-spec[showCatalogs]
----

View file

@ -5,13 +5,18 @@
.Synopsis:
[source, sql]
----
SHOW COLUMNS [ FROM | IN ]?
[table identifier | <1>
[LIKE pattern] ] <2>
SHOW COLUMNS
[CATALOG identifier]? <1>
[INCLUDE FROZEN]? <2>
[FROM | IN]
[table_identifier | <3>
LIKE pattern] <4>
----
<1> single table identifier or double quoted es multi index
<2> SQL LIKE pattern
<1> Catalog (cluster) identifier. Supports wildcards (`*`).
<2> Whether or not to include frozen indices.
<3> Single table (index or data stream) identifier or double-quoted multi-target pattern.
<4> SQL LIKE pattern matching table names.
See <<sql-index-patterns, index patterns>> for more information about
patterns.

View file

@ -5,7 +5,7 @@
.Synopsis:
[source, sql]
----
SHOW FUNCTIONS [LIKE pattern?]? <1>
SHOW FUNCTIONS [LIKE pattern]? <1>
----
<1> SQL match pattern

View file

@ -6,14 +6,18 @@
[source, sql]
----
SHOW TABLES
[INCLUDE FROZEN]? <1>
[table identifier | <2>
[LIKE pattern ]]? <3>
[CATALOG [catalog_identifier | <1>
LIKE pattern]]? <2>
[INCLUDE FROZEN]? <3>
[table_identifier | <4>
LIKE pattern]? <5>
----
<1> Whether or not to include frozen indices
<2> single table identifier or double quoted es multi index
<3> SQL LIKE pattern
<1> Catalog (cluster) identifier. Supports wildcards (`*`).
<2> SQL LIKE pattern matching catalog names.
<3> Whether or not to include frozen indices.
<4> Single table (index or data stream) identifier or double-quoted multi-target pattern.
<5> SQL LIKE pattern matching table names.
See <<sql-index-patterns, index patterns>> for more information about
patterns.
@ -60,3 +64,9 @@ Or a mixture of single and multiple chars:
----
include-tagged::{sql-specs}/docs/docs.csv-spec[showTablesLikeMixed]
----
List tables within remote clusters whose names are matched by a wildcard:
[source, sql]
----
include-tagged::{sql-specs}/multi-cluster-with-security/multi-cluster-command.csv-spec[showTablesCatalogPatternMultiLike]
----