Skip to content

Commit

Permalink
ESQL: Remove remaining IT_tests_only (#108434)
Browse files Browse the repository at this point in the history
This moves examples from files marked to run in integration tests only
to the files where they belong and disables this pattern matching. We
now use supported features.
  • Loading branch information
nik9000 committed May 9, 2024
1 parent 06a0758 commit 5a612d4
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 82 deletions.
16 changes: 8 additions & 8 deletions docs/reference/esql/processing-commands/enrich.asciidoc
Expand Up @@ -57,23 +57,23 @@ in this example). `ENRICH` will look for records in the

[source.merge.styled,esql]
----
include::{esql-specs}/docs-IT_tests_only.csv-spec[tag=enrich]
include::{esql-specs}/enrich.csv-spec[tag=enrich]
----
[%header.monospaced.styled,format=dsv,separator=|]
|===
include::{esql-specs}/docs-IT_tests_only.csv-spec[tag=enrich-result]
include::{esql-specs}/enrich.csv-spec[tag=enrich-result]
|===

To use a column with a different name than the `match_field` defined in the
policy as the match field, use `ON <column-name>`:

[source.merge.styled,esql]
----
include::{esql-specs}/docs-IT_tests_only.csv-spec[tag=enrich_on]
include::{esql-specs}/enrich.csv-spec[tag=enrich_on]
----
[%header.monospaced.styled,format=dsv,separator=|]
|===
include::{esql-specs}/docs-IT_tests_only.csv-spec[tag=enrich_on-result]
include::{esql-specs}/enrich.csv-spec[tag=enrich_on-result]
|===

By default, each of the enrich fields defined in the policy is added as a
Expand All @@ -82,22 +82,22 @@ column. To explicitly select the enrich fields that are added, use

[source.merge.styled,esql]
----
include::{esql-specs}/docs-IT_tests_only.csv-spec[tag=enrich_with]
include::{esql-specs}/enrich.csv-spec[tag=enrich_with]
----
[%header.monospaced.styled,format=dsv,separator=|]
|===
include::{esql-specs}/docs-IT_tests_only.csv-spec[tag=enrich_with-result]
include::{esql-specs}/enrich.csv-spec[tag=enrich_with-result]
|===

You can rename the columns that are added using `WITH new_name=<field1>`:

[source.merge.styled,esql]
----
include::{esql-specs}/docs-IT_tests_only.csv-spec[tag=enrich_rename]
include::{esql-specs}/enrich.csv-spec[tag=enrich_rename]
----
[%header.monospaced.styled,format=dsv,separator=|]
|===
include::{esql-specs}/docs-IT_tests_only.csv-spec[tag=enrich_rename-result]
include::{esql-specs}/enrich.csv-spec[tag=enrich_rename-result]
|===

In case of name collisions, the newly created columns will override existing
Expand Down

This file was deleted.

Expand Up @@ -34,12 +34,31 @@ median_duration:double | env:keyword
simple
required_feature: esql.enrich_load

row language_code = "1"
| enrich languages_policy
// tag::enrich[]
ROW language_code = "1"
| ENRICH languages_policy
// end::enrich[]
;

// tag::enrich-result[]
language_code:keyword | language_name:keyword
1 | English
// end::enrich-result[]
;

enrichOnSimple
required_feature: esql.enrich_load

// tag::enrich_on[]
ROW a = "1"
| ENRICH languages_policy ON a
// end::enrich_on[]
;

// tag::enrich_on-result[]
a:keyword | language_name:keyword
1 | English
// end::enrich_on-result[]
;


Expand Down Expand Up @@ -83,6 +102,22 @@ emp_no:integer | x:keyword | language_name:keyword
;


withSimple
required_feature: esql.enrich_load

// tag::enrich_with[]
ROW a = "1"
| ENRICH languages_policy ON a WITH language_name
// end::enrich_with[]
;

// tag::enrich_with-result[]
a:keyword | language_name:keyword
1 | English
// end::enrich_with-result[]
;


withAlias
required_feature: esql.enrich_load

Expand All @@ -95,6 +130,21 @@ emp_no:integer | x:keyword | lang:keyword
10003 | 4 | German
;

withAliasSimple
required_feature: esql.enrich_load

// tag::enrich_rename[]
ROW a = "1"
| ENRICH languages_policy ON a WITH name = language_name
// end::enrich_rename[]
;

// tag::enrich_rename-result[]
a:keyword | name:keyword
1 | English
// end::enrich_rename-result[]
;


withAliasSort
required_feature: esql.enrich_load
Expand Down
Expand Up @@ -110,6 +110,8 @@
import static org.elasticsearch.xpack.ql.CsvSpecReader.specParser;
import static org.elasticsearch.xpack.ql.TestUtils.classpathResources;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;

Expand Down Expand Up @@ -144,7 +146,6 @@
public class CsvTests extends ESTestCase {

private static final Logger LOGGER = LogManager.getLogger(CsvTests.class);
private static final String IGNORED_CSV_FILE_NAMES_PATTERN = "-IT_tests_only";

private final String fileName;
private final String groupName;
Expand All @@ -164,10 +165,8 @@ public class CsvTests extends ESTestCase {

@ParametersFactory(argumentFormatting = "%2$s.%3$s")
public static List<Object[]> readScriptSpec() throws Exception {
List<URL> urls = classpathResources("/*.csv-spec").stream()
.filter(x -> x.toString().contains(IGNORED_CSV_FILE_NAMES_PATTERN) == false)
.toList();
assertTrue("Not enough specs found " + urls, urls.size() > 0);
List<URL> urls = classpathResources("/*.csv-spec");
assertThat("Not enough specs found " + urls, urls, hasSize(greaterThan(0)));
return SpecReader.readScriptSpec(urls, specParser());
}

Expand Down

0 comments on commit 5a612d4

Please sign in to comment.