From 46eee2f69217aaafdc8b5eab1456bcf388956c4c Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Wed, 10 Jul 2024 11:51:42 +0400 Subject: [PATCH 1/6] Add drop_null_columns parameter to /_query --- specification/esql/query/QueryRequest.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/specification/esql/query/QueryRequest.ts b/specification/esql/query/QueryRequest.ts index fe4e8d2308..5d60e95197 100644 --- a/specification/esql/query/QueryRequest.ts +++ b/specification/esql/query/QueryRequest.ts @@ -38,6 +38,12 @@ export interface Request extends RequestBase { * The character to use between values within a CSV row. Only valid for the CSV format. */ delimiter?: string + /** + * Should columns that are entirely `null` be removed from the `columns` and `values` portion of the results? + * Defaults to `false`. If `true` then the response will include an extra section under the name `all_columns` which has the name of all columns. + * @server_default false + */ + drop_null_columns?: boolean } /** * Use the `query` element to start a query. Use `time_zone` to specify an execution time zone and `columnar` to format the answer. From 3646cd60df159d1c447b0c4fbe5420420dd1ab81 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Wed, 10 Jul 2024 11:46:22 +0400 Subject: [PATCH 2/6] Add undocumented profile parameter --- specification/esql/query/QueryRequest.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/specification/esql/query/QueryRequest.ts b/specification/esql/query/QueryRequest.ts index 5d60e95197..6c0e60685b 100644 --- a/specification/esql/query/QueryRequest.ts +++ b/specification/esql/query/QueryRequest.ts @@ -63,6 +63,7 @@ export interface Request extends RequestBase { * @doc_id esql-query-params */ params?: Array + profile?: boolean /** * The ES|QL query API accepts an ES|QL query string in the query parameter, runs it, and returns the results. */ From 9771a0b3de2fe8d3f286d2e8b845508917c7438d Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Wed, 10 Jul 2024 11:49:06 +0400 Subject: [PATCH 3/6] Fix params to accept any values Values can look like {"n1": "5"}, for example, with `n1` being an arbitrary key. --- specification/esql/query/QueryRequest.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specification/esql/query/QueryRequest.ts b/specification/esql/query/QueryRequest.ts index 6c0e60685b..ff93179e3b 100644 --- a/specification/esql/query/QueryRequest.ts +++ b/specification/esql/query/QueryRequest.ts @@ -19,7 +19,7 @@ import { RequestBase } from '@_types/Base' import { QueryContainer } from '@_types/query_dsl/abstractions' -import { ScalarValue } from '@_types/common' +import { UserDefinedValue } from '@spec_utils/UserDefinedValue' /** * Executes an ES|QL request @@ -62,7 +62,7 @@ export interface Request extends RequestBase { * To avoid any attempts of hacking or code injection, extract the values in a separate list of parameters. Use question mark placeholders (?) in the query string for each of the parameters. * @doc_id esql-query-params */ - params?: Array + params?: Array profile?: boolean /** * The ES|QL query API accepts an ES|QL query string in the query parameter, runs it, and returns the results. From 7a98c64d1e054705848d43858014e912aad9b255 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Wed, 10 Jul 2024 11:51:02 +0400 Subject: [PATCH 4/6] Document /_query locale parameter --- specification/_doc_ids/table.csv | 1 + specification/esql/query/QueryRequest.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/specification/_doc_ids/table.csv b/specification/_doc_ids/table.csv index def9c4b73f..63879dec52 100644 --- a/specification/_doc_ids/table.csv +++ b/specification/_doc_ids/table.csv @@ -148,6 +148,7 @@ eql-syntax,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/eql- eql,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/eql.html esql-query,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/esql-rest.html esql-query-params,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/esql-rest.html#esql-rest-params +esql-returning-localized-results,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/esql-rest.html#esql-locale-param evaluate-dfanalytics,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/evaluate-dfanalytics.html execute-enrich-policy-api,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/execute-enrich-policy-api.html expected-reciprocal,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-rank-eval.html#_expected_reciprocal_rank_err diff --git a/specification/esql/query/QueryRequest.ts b/specification/esql/query/QueryRequest.ts index ff93179e3b..31bb2d633e 100644 --- a/specification/esql/query/QueryRequest.ts +++ b/specification/esql/query/QueryRequest.ts @@ -57,6 +57,10 @@ export interface Request extends RequestBase { * Specify a Query DSL query in the filter parameter to filter the set of documents that an ES|QL query runs on. */ filter?: QueryContainer + /* + * Returns results (especially dates) formatted per the conventions of the locale. + * @doc_id esql-returning-localized-results + */ locale?: string /** * To avoid any attempts of hacking or code injection, extract the values in a separate list of parameters. Use question mark placeholders (?) in the query string for each of the parameters. From ab8dd7d2e008c32028753190b35f9b728657a971 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Wed, 10 Jul 2024 11:53:49 +0400 Subject: [PATCH 5/6] Run make contrib --- output/openapi/elasticsearch-openapi.json | 15 ++++++++- .../elasticsearch-serverless-openapi.json | 15 ++++++++- output/schema/schema-serverless.json | 32 +++++++++++++++---- output/schema/schema.json | 32 +++++++++++++++---- output/schema/validation-errors.json | 4 +-- output/typescript/types.ts | 4 ++- 6 files changed, 84 insertions(+), 18 deletions(-) diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index 7f0699111e..ed8622fce1 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -8018,6 +8018,16 @@ "type": "string" }, "style": "form" + }, + { + "in": "query", + "name": "drop_null_columns", + "description": "Should columns that are entirely `null` be removed from the `columns` and `values` portion of the results?\nDefaults to `false`. If `true` then the response will include an extra section under the name `all_columns` which has the name of all columns.", + "deprecated": false, + "schema": { + "type": "boolean" + }, + "style": "form" } ], "requestBody": { @@ -8043,9 +8053,12 @@ "description": "To avoid any attempts of hacking or code injection, extract the values in a separate list of parameters. Use question mark placeholders (?) in the query string for each of the parameters.", "type": "array", "items": { - "$ref": "#/components/schemas/_types:ScalarValue" + "type": "object" } }, + "profile": { + "type": "boolean" + }, "query": { "description": "The ES|QL query API accepts an ES|QL query string in the query parameter, runs it, and returns the results.", "type": "string" diff --git a/output/openapi/elasticsearch-serverless-openapi.json b/output/openapi/elasticsearch-serverless-openapi.json index e7ed0dac47..c42004010e 100644 --- a/output/openapi/elasticsearch-serverless-openapi.json +++ b/output/openapi/elasticsearch-serverless-openapi.json @@ -5340,6 +5340,16 @@ "type": "string" }, "style": "form" + }, + { + "in": "query", + "name": "drop_null_columns", + "description": "Should columns that are entirely `null` be removed from the `columns` and `values` portion of the results?\nDefaults to `false`. If `true` then the response will include an extra section under the name `all_columns` which has the name of all columns.", + "deprecated": false, + "schema": { + "type": "boolean" + }, + "style": "form" } ], "requestBody": { @@ -5365,9 +5375,12 @@ "description": "To avoid any attempts of hacking or code injection, extract the values in a separate list of parameters. Use question mark placeholders (?) in the query string for each of the parameters.", "type": "array", "items": { - "$ref": "#/components/schemas/_types:ScalarValue" + "type": "object" } }, + "profile": { + "type": "boolean" + }, "query": { "description": "The ES|QL query API accepts an ES|QL query string in the query parameter, runs it, and returns the results.", "type": "string" diff --git a/output/schema/schema-serverless.json b/output/schema/schema-serverless.json index 695a935e37..b953df7dda 100644 --- a/output/schema/schema-serverless.json +++ b/output/schema/schema-serverless.json @@ -18556,11 +18556,18 @@ "type": { "kind": "array_of", "value": { - "kind": "instance_of", - "type": { - "name": "ScalarValue", - "namespace": "_types" - } + "kind": "user_defined_value" + } + } + }, + { + "name": "profile", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "boolean", + "namespace": "_builtins" } } }, @@ -18615,9 +18622,22 @@ "namespace": "_builtins" } } + }, + { + "description": "Should columns that are entirely `null` be removed from the `columns` and `values` portion of the results?\nDefaults to `false`. If `true` then the response will include an extra section under the name `all_columns` which has the name of all columns.", + "name": "drop_null_columns", + "required": false, + "serverDefault": false, + "type": { + "kind": "instance_of", + "type": { + "name": "boolean", + "namespace": "_builtins" + } + } } ], - "specLocation": "esql/query/QueryRequest.ts#L24-L65" + "specLocation": "esql/query/QueryRequest.ts#L24-L76" }, { "body": { diff --git a/output/schema/schema.json b/output/schema/schema.json index e3a38537c1..8131e9e0b4 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -114254,11 +114254,18 @@ "type": { "kind": "array_of", "value": { - "kind": "instance_of", - "type": { - "name": "ScalarValue", - "namespace": "_types" - } + "kind": "user_defined_value" + } + } + }, + { + "name": "profile", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "boolean", + "namespace": "_builtins" } } }, @@ -114313,9 +114320,22 @@ "namespace": "_builtins" } } + }, + { + "description": "Should columns that are entirely `null` be removed from the `columns` and `values` portion of the results?\nDefaults to `false`. If `true` then the response will include an extra section under the name `all_columns` which has the name of all columns.", + "name": "drop_null_columns", + "required": false, + "serverDefault": false, + "type": { + "kind": "instance_of", + "type": { + "name": "boolean", + "namespace": "_builtins" + } + } } ], - "specLocation": "esql/query/QueryRequest.ts#L24-L65" + "specLocation": "esql/query/QueryRequest.ts#L24-L76" }, { "body": { diff --git a/output/schema/validation-errors.json b/output/schema/validation-errors.json index 6ac8eadcba..21f7565ed4 100644 --- a/output/schema/validation-errors.json +++ b/output/schema/validation-errors.json @@ -652,9 +652,7 @@ "response": [] }, "esql.query": { - "request": [ - "Request: missing json spec query parameter 'drop_null_columns'" - ], + "request": [], "response": [ "type_alias definition _types:EsqlColumns / instance_of - No type definition for '_builtins:binary'" ] diff --git a/output/typescript/types.ts b/output/typescript/types.ts index 7013c70d4d..39073996b4 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -9886,11 +9886,13 @@ export type EqlSearchResultPosition = 'tail' | 'head' export interface EsqlQueryRequest extends RequestBase { format?: string delimiter?: string + drop_null_columns?: boolean body?: { columnar?: boolean filter?: QueryDslQueryContainer locale?: string - params?: ScalarValue[] + params?: any[] + profile?: boolean query: string } } From 6f442ea227cbdd314222c174c1e1a33154df45ff Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Wed, 10 Jul 2024 15:24:56 +0400 Subject: [PATCH 6/6] Switch params to FieldValue[] --- output/openapi/elasticsearch-openapi.json | 2 +- output/openapi/elasticsearch-serverless-openapi.json | 2 +- output/schema/schema-serverless.json | 6 +++++- output/schema/schema.json | 6 +++++- output/typescript/types.ts | 2 +- specification/esql/query/QueryRequest.ts | 4 ++-- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index ed8622fce1..c19c5bc1d2 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -8053,7 +8053,7 @@ "description": "To avoid any attempts of hacking or code injection, extract the values in a separate list of parameters. Use question mark placeholders (?) in the query string for each of the parameters.", "type": "array", "items": { - "type": "object" + "$ref": "#/components/schemas/_types:FieldValue" } }, "profile": { diff --git a/output/openapi/elasticsearch-serverless-openapi.json b/output/openapi/elasticsearch-serverless-openapi.json index c42004010e..a7cde64ea0 100644 --- a/output/openapi/elasticsearch-serverless-openapi.json +++ b/output/openapi/elasticsearch-serverless-openapi.json @@ -5375,7 +5375,7 @@ "description": "To avoid any attempts of hacking or code injection, extract the values in a separate list of parameters. Use question mark placeholders (?) in the query string for each of the parameters.", "type": "array", "items": { - "type": "object" + "$ref": "#/components/schemas/_types:FieldValue" } }, "profile": { diff --git a/output/schema/schema-serverless.json b/output/schema/schema-serverless.json index b953df7dda..49f0c33227 100644 --- a/output/schema/schema-serverless.json +++ b/output/schema/schema-serverless.json @@ -18556,7 +18556,11 @@ "type": { "kind": "array_of", "value": { - "kind": "user_defined_value" + "kind": "instance_of", + "type": { + "name": "FieldValue", + "namespace": "_types" + } } } }, diff --git a/output/schema/schema.json b/output/schema/schema.json index 8131e9e0b4..780af57a81 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -114254,7 +114254,11 @@ "type": { "kind": "array_of", "value": { - "kind": "user_defined_value" + "kind": "instance_of", + "type": { + "name": "FieldValue", + "namespace": "_types" + } } } }, diff --git a/output/typescript/types.ts b/output/typescript/types.ts index 39073996b4..8c06bf05d6 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -9891,7 +9891,7 @@ export interface EsqlQueryRequest extends RequestBase { columnar?: boolean filter?: QueryDslQueryContainer locale?: string - params?: any[] + params?: FieldValue[] profile?: boolean query: string } diff --git a/specification/esql/query/QueryRequest.ts b/specification/esql/query/QueryRequest.ts index 31bb2d633e..a9eae673b6 100644 --- a/specification/esql/query/QueryRequest.ts +++ b/specification/esql/query/QueryRequest.ts @@ -19,7 +19,7 @@ import { RequestBase } from '@_types/Base' import { QueryContainer } from '@_types/query_dsl/abstractions' -import { UserDefinedValue } from '@spec_utils/UserDefinedValue' +import { FieldValue } from '@_types/common' /** * Executes an ES|QL request @@ -66,7 +66,7 @@ export interface Request extends RequestBase { * To avoid any attempts of hacking or code injection, extract the values in a separate list of parameters. Use question mark placeholders (?) in the query string for each of the parameters. * @doc_id esql-query-params */ - params?: Array + params?: Array profile?: boolean /** * The ES|QL query API accepts an ES|QL query string in the query parameter, runs it, and returns the results.