Skip to content

Commit bd1f56c

Browse files
committed
fixup
1 parent 3aaa248 commit bd1f56c

File tree

7 files changed

+30
-22
lines changed

7 files changed

+30
-22
lines changed

x-pack/plugin/esql/qa/server/multi-clusters/src/javaRestTest/java/org/elasticsearch/xpack/esql/ccq/MultiClustersIT.java

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.util.List;
3434
import java.util.Map;
3535
import java.util.Set;
36+
import java.util.function.Predicate;
3637
import java.util.stream.Collectors;
3738
import java.util.stream.IntStream;
3839
import java.util.stream.Stream;
@@ -476,12 +477,8 @@ public void testNotLikeIndex() throws Exception {
476477
}
477478

478479
public void testLikeListIndex() throws Exception {
479-
List<String> requiredCapabilities = new ArrayList<>(List.of("like_list_on_index_fields"));
480480
// the feature is completely supported if both local and remote clusters support it
481-
if (capabilitiesSupportedNewAndOld(requiredCapabilities) == false) {
482-
logger.info("--> skipping testNotLikeListIndex, due to missing capability");
483-
return;
484-
}
481+
assumeTrue("not supported", capabilitiesSupportedNewAndOld(List.of("like_list_on_index_fields")));
485482
boolean includeCCSMetadata = includeCCSMetadata();
486483
Map<String, Object> result = run("""
487484
FROM test-local-index,*:test-remote-index METADATA _index
@@ -495,12 +492,7 @@ public void testLikeListIndex() throws Exception {
495492
}
496493

497494
public void testNotLikeListIndex() throws Exception {
498-
List<String> requiredCapabilities = new ArrayList<>(List.of("like_list_on_index_fields"));
499-
// the feature is completely supported if both local and remote clusters support it
500-
if (capabilitiesSupportedNewAndOld(requiredCapabilities) == false) {
501-
logger.info("--> skipping testNotLikeListIndex, due to missing capability");
502-
return;
503-
}
495+
assumeTrue("not supported", capabilitiesSupportedNewAndOld(List.of("like_list_on_index_fields")));
504496
boolean includeCCSMetadata = includeCCSMetadata();
505497
Map<String, Object> result = run("""
506498
FROM test-local-index,*:test-remote-index METADATA _index
@@ -513,13 +505,8 @@ public void testNotLikeListIndex() throws Exception {
513505
assertResultMapForLike(includeCCSMetadata, result, columns, values, false, true);
514506
}
515507

516-
public void testNotLikeListKeyWord() throws Exception {
517-
List<String> requiredCapabilities = new ArrayList<>(List.of("like_list_on_index_fields"));
518-
// the feature is completely supported if both local and remote clusters support it
519-
if (capabilitiesSupportedNewAndOld(requiredCapabilities) == false) {
520-
logger.info("--> skipping testNotLikeListIndex, due to missing capability");
521-
return;
522-
}
508+
public void testNotLikeListKeyword() throws Exception {
509+
assumeTrue("not supported", capabilitiesSupportedNewAndOld(List.of("like_with_list_of_patterns")));
523510
boolean includeCCSMetadata = includeCCSMetadata();
524511
Map<String, Object> result = run("""
525512
FROM test-local-index,*:test-remote-index METADATA _index
@@ -528,7 +515,11 @@ public void testNotLikeListKeyWord() throws Exception {
528515
| SORT _index ASC
529516
""", includeCCSMetadata);
530517
var columns = List.of(Map.of("name", "c", "type", "long"), Map.of("name", "_index", "type", "keyword"));
531-
var values = List.of(List.of(localDocs.size(), localIndex));
518+
Predicate<Doc> filter = d -> false == (d.color.contains("blue") || d.color.contains("red"));
519+
var values = List.of(
520+
List.of((int) remoteDocs.stream().filter(filter).count(), REMOTE_CLUSTER_NAME + ":" + remoteIndex),
521+
List.of((int) localDocs.stream().filter(filter).count(), localIndex)
522+
);
532523
assertResultMapForLike(includeCCSMetadata, result, columns, values, false, true);
533524
}
534525

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,8 @@ public enum Cap {
11991199

12001200
LIKE_WITH_LIST_OF_PATTERNS,
12011201

1202+
LIKE_LIST_ON_INDEX_FIELDS,
1203+
12021204
/**
12031205
* Support parameters for SAMPLE command.
12041206
*/

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/regex/WildcardLikeList.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
import org.apache.lucene.search.MultiTermQuery.RewriteMethod;
1111
import org.apache.lucene.util.automaton.Automaton;
12+
import org.elasticsearch.TransportVersion;
13+
import org.elasticsearch.TransportVersions;
1214
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
1315
import org.elasticsearch.common.io.stream.StreamInput;
1416
import org.elasticsearch.common.io.stream.StreamOutput;
@@ -96,10 +98,10 @@ protected WildcardLikeList replaceChild(Expression newLeft) {
9698
*/
9799
@Override
98100
public Translatable translatable(LucenePushdownPredicates pushdownPredicates) {
99-
if (pushdownPredicates.minTransportVersion() == null) {
101+
if (supportsPushdown(pushdownPredicates.minTransportVersion())) {
100102
return pushdownPredicates.isPushableAttribute(field()) ? Translatable.YES : Translatable.NO;
101103
} else {
102-
// The AutomatonQuery that we use right now isn't serializable.
104+
// The ExpressionQuery we use isn't serializable to all nodes in the cluster.
103105
return Translatable.NO;
104106
}
105107
}
@@ -119,6 +121,10 @@ public Query asQuery(LucenePushdownPredicates pushdownPredicates, TranslatorHand
119121
return translateField(targetFieldName);
120122
}
121123

124+
private boolean supportsPushdown(TransportVersion version) {
125+
return version == null || version.onOrAfter(TransportVersions.ESQL_FIXED_INDEX_LIKE);
126+
}
127+
122128
@Override
123129
public org.apache.lucene.search.Query asLuceneQuery(
124130
MappedFieldType fieldType,

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/io/stream/PlanStreamWrapperQueryBuilder.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.elasticsearch.common.io.stream.StreamOutput;
1616
import org.elasticsearch.index.query.QueryBuilder;
1717
import org.elasticsearch.index.query.SearchExecutionContext;
18+
import org.elasticsearch.logging.LogManager;
1819
import org.elasticsearch.xcontent.XContentBuilder;
1920
import org.elasticsearch.xpack.esql.session.Configuration;
2021

@@ -35,20 +36,23 @@ public class PlanStreamWrapperQueryBuilder implements QueryBuilder {
3536
private final QueryBuilder next;
3637

3738
public PlanStreamWrapperQueryBuilder(Configuration configuration, QueryBuilder next) {
39+
LogManager.getLogger(PlanStreamWrapperQueryBuilder.class).error("ASFAFDSAFDSF wrap {}", next);
3840
this.configuration = configuration;
3941
this.next = next;
4042
}
4143

4244
public PlanStreamWrapperQueryBuilder(StreamInput in) throws IOException {
4345
configuration = Configuration.readWithoutTables(in);
46+
LogManager.getLogger(PlanStreamWrapperQueryBuilder.class).error("ASFAFDSAFDSF streamread {}", configuration);
4447
PlanStreamInput planStreamInput = new PlanStreamInput(in, in.namedWriteableRegistry(), configuration);
4548
next = planStreamInput.readNamedWriteable(QueryBuilder.class);
49+
LogManager.getLogger(PlanStreamWrapperQueryBuilder.class).error("ASFAFDSAFDSF stream {}", next);
4650
}
4751

4852
@Override
4953
public void writeTo(StreamOutput out) throws IOException {
5054
configuration.withoutTables().writeTo(out);
51-
next.writeTo(new PlanStreamOutput(out, configuration));
55+
new PlanStreamOutput(out, configuration).writeNamedWriteable(next);
5256
}
5357

5458
@Override

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/PlannerUtils.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.elasticsearch.index.query.CoordinatorRewriteContext;
2121
import org.elasticsearch.index.query.QueryBuilder;
2222
import org.elasticsearch.index.query.SearchExecutionContext;
23+
import org.elasticsearch.logging.LogManager;
2324
import org.elasticsearch.xpack.esql.EsqlIllegalArgumentException;
2425
import org.elasticsearch.xpack.esql.capabilities.TranslationAware;
2526
import org.elasticsearch.xpack.esql.core.expression.AttributeSet;
@@ -262,6 +263,7 @@ && translatable(exp, ctx).finish() == TranslationAware.FinishedTranslatable.YES)
262263
if (matches.isEmpty() == false) {
263264
Query qlQuery = TRANSLATOR_HANDLER.asQuery(ctx, Predicates.combineAnd(matches));
264265
QueryBuilder builder = qlQuery.toQueryBuilder();
266+
LogManager.getLogger(PlannerUtils.class).error("ASFAFDSAFDSF {} {}", qlQuery, qlQuery.containsPlan());
265267
if (qlQuery.containsPlan()) {
266268
builder = new PlanStreamWrapperQueryBuilder(configuration, builder);
267269
}

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/EsqlPlugin.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
import org.elasticsearch.xpack.esql.execution.PlanExecutor;
7474
import org.elasticsearch.xpack.esql.expression.ExpressionWritables;
7575
import org.elasticsearch.xpack.esql.io.stream.ExpressionQueryBuilder;
76+
import org.elasticsearch.xpack.esql.io.stream.PlanStreamWrapperQueryBuilder;
7677
import org.elasticsearch.xpack.esql.plan.PlanWritables;
7778
import org.elasticsearch.xpack.esql.querydsl.query.SingleValueQuery;
7879
import org.elasticsearch.xpack.esql.querylog.EsqlQueryLog;
@@ -335,6 +336,7 @@ public List<NamedWriteableRegistry.Entry> getNamedWriteables() {
335336
entries.add(EnrichLookupOperator.Status.ENTRY);
336337
entries.add(LookupFromIndexOperator.Status.ENTRY);
337338
entries.add(ExpressionQueryBuilder.ENTRY);
339+
entries.add(PlanStreamWrapperQueryBuilder.ENTRY);
338340

339341
entries.addAll(ExpressionWritables.getNamedWriteables());
340342
entries.addAll(PlanWritables.getNamedWriteables());

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session/Configuration.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ public Configuration(BlockStreamInput in) throws IOException {
120120
this.allowPartialResults = false;
121121
}
122122
if (in.getTransportVersion().onOrAfter(TransportVersions.ESQL_FIXED_INDEX_LIKE)) {
123+
// NOCOMMIT can we look this up without putting it in Configuration?
123124
this.stringLikeOnIndex = in.readBoolean();
124125
} else {
125126
this.stringLikeOnIndex = false;

0 commit comments

Comments
 (0)