Skip to content

Commit 1bcb310

Browse files
Merge branch 'main' into remove-some-copies
2 parents 56916cf + ce8dc14 commit 1bcb310

File tree

8 files changed

+79
-112
lines changed

8 files changed

+79
-112
lines changed

docs/changelog/127199.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 127199
2+
summary: Disable a bugged commit
3+
area: ES|QL
4+
type: bug
5+
issues:
6+
- 127197

server/src/main/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolver.java

Lines changed: 2 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -691,26 +691,6 @@ private static void resolveIndicesForDataStreamRelatedAbstraction(
691691
}
692692
}
693693

694-
private static void resolveWriteIndexForDataStreams(
695-
Context context,
696-
DataStream dataStream,
697-
Set<Index> concreteIndicesResult,
698-
IndexComponentSelector selector
699-
) {
700-
if (shouldIncludeRegularIndices(context.getOptions(), selector)) {
701-
Index writeIndex = dataStream.getWriteIndex();
702-
if (addIndex(writeIndex, null, context)) {
703-
concreteIndicesResult.add(writeIndex);
704-
}
705-
}
706-
if (shouldIncludeFailureIndices(context.getOptions(), selector)) {
707-
Index failureStoreWriteIndex = dataStream.getWriteFailureIndex();
708-
if (failureStoreWriteIndex != null && addIndex(failureStoreWriteIndex, null, context)) {
709-
concreteIndicesResult.add(failureStoreWriteIndex);
710-
}
711-
}
712-
}
713-
714694
public static boolean shouldIncludeRegularIndices(IndicesOptions indicesOptions, IndexComponentSelector expressionSelector) {
715695
if (indicesOptions.allowSelectors()) {
716696
return expressionSelector == null || expressionSelector.shouldIncludeData();
@@ -873,19 +853,6 @@ public Index concreteSingleIndex(ProjectMetadata project, IndicesRequest request
873853
return indices[0];
874854
}
875855

876-
/**
877-
* Utility method that allows to resolve an index expression to its corresponding single write index.
878-
*
879-
* @param state the cluster state containing all the data to resolve to expression to a concrete index
880-
* @param request The request that defines how an alias or an index need to be resolved to a concrete index
881-
* and the expression that can be resolved to an alias or an index name.
882-
* @throws IllegalArgumentException if the index resolution does not lead to an index, or leads to more than one index
883-
* @return the write index obtained as a result of the index resolution
884-
*/
885-
public Index concreteWriteIndex(ClusterState state, IndicesRequest request) {
886-
return concreteWriteIndex(projectResolver.getProjectMetadata(state), request);
887-
}
888-
889856
/**
890857
* Utility method that allows to resolve an index expression to its corresponding single write index.
891858
*
@@ -977,14 +944,6 @@ public Index concreteWriteIndex(
977944
return indices[0];
978945
}
979946

980-
/**
981-
* @return whether the specified index, data stream or alias exists.
982-
* If the data stream, index or alias contains date math then that is resolved too.
983-
*/
984-
public boolean hasIndexAbstraction(String indexAbstraction, ClusterState state) {
985-
return hasIndexAbstraction(indexAbstraction, projectResolver.getProjectMetadata(state));
986-
}
987-
988947
/**
989948
* @return whether the specified index, data stream or alias exists.
990949
* If the data stream, index or alias contains date math then that is resolved too.
@@ -1041,34 +1000,13 @@ public static void assertExpressionHasNullOrDataSelector(String expression) {
10411000
}
10421001
}
10431002

1044-
/**
1045-
* Resolve an array of expressions to the set of indices and aliases that these expressions match.
1046-
*/
1047-
public Set<ResolvedExpression> resolveExpressions(ClusterState state, String... expressions) {
1048-
return resolveExpressions(projectResolver.getProjectMetadata(state), expressions);
1049-
}
1050-
10511003
/**
10521004
* Resolve an array of expressions to the set of indices and aliases that these expressions match.
10531005
*/
10541006
public Set<ResolvedExpression> resolveExpressions(ProjectMetadata project, String... expressions) {
10551007
return resolveExpressions(project, IndicesOptions.lenientExpandOpen(), false, expressions);
10561008
}
10571009

1058-
/**
1059-
* Resolve the expression to the set of indices, aliases, and, optionally, datastreams that the expression matches.
1060-
* If {@param preserveDataStreams} is {@code true}, datastreams that are covered by the wildcards from the
1061-
* {@param expressions} are returned as-is, without expanding them further to their respective backing indices.
1062-
*/
1063-
public Set<ResolvedExpression> resolveExpressions(
1064-
ClusterState state,
1065-
IndicesOptions indicesOptions,
1066-
boolean preserveDataStreams,
1067-
String... expressions
1068-
) {
1069-
return resolveExpressions(projectResolver.getProjectMetadata(state), indicesOptions, preserveDataStreams, expressions);
1070-
}
1071-
10721010
/**
10731011
* Resolve the expression to the set of indices, aliases, and, optionally, datastreams that the expression matches.
10741012
* If {@param preserveDataStreams} is {@code true}, datastreams that are covered by the wildcards from the
@@ -1101,17 +1039,6 @@ public Set<ResolvedExpression> resolveExpressions(
11011039
}
11021040
}
11031041

1104-
/**
1105-
* Iterates through the list of indices and selects the effective list of filtering aliases for the
1106-
* given index.
1107-
* <p>Only aliases with filters are returned. If the indices list contains a non-filtering reference to
1108-
* the index itself - null is returned. Returns {@code null} if no filtering is required.
1109-
* <b>NOTE</b>: The provided expressions must have been resolved already via {@link #resolveExpressionsToResources(Context, String...)}.
1110-
*/
1111-
public String[] filteringAliases(ClusterState state, String index, Set<ResolvedExpression> resolvedExpressions) {
1112-
return filteringAliases(projectResolver.getProjectMetadata(state), index, resolvedExpressions);
1113-
}
1114-
11151042
/**
11161043
* Iterates through the list of indices and selects the effective list of filtering aliases for the
11171044
* given index.
@@ -1140,31 +1067,6 @@ boolean iterateIndexAliases(int indexAliasesSize, int resolvedExpressionsSize) {
11401067
return indexAliasesSize <= resolvedExpressionsSize;
11411068
}
11421069

1143-
/**
1144-
* Iterates through the list of indices and selects the effective list of required aliases for the given index.
1145-
* <p>Only aliases where the given predicate tests successfully are returned. If the indices list contains a non-required reference to
1146-
* the index itself - null is returned. Returns {@code null} if no filtering is required.
1147-
* <p><b>NOTE</b>: the provided expressions must have been resolved already via
1148-
* {@link #resolveExpressionsToResources(Context, String...)}.
1149-
*/
1150-
public String[] indexAliases(
1151-
ClusterState state,
1152-
String index,
1153-
Predicate<AliasMetadata> requiredAlias,
1154-
Predicate<DataStreamAlias> requiredDataStreamAlias,
1155-
boolean skipIdentity,
1156-
Set<ResolvedExpression> resolvedExpressions
1157-
) {
1158-
return indexAliases(
1159-
projectResolver.getProjectMetadata(state),
1160-
index,
1161-
requiredAlias,
1162-
requiredDataStreamAlias,
1163-
skipIdentity,
1164-
resolvedExpressions
1165-
);
1166-
}
1167-
11681070
/**
11691071
* Iterates through the list of indices and selects the effective list of required aliases for the given index.
11701072
* <p>Only aliases where the given predicate tests successfully are returned. If the indices list contains a non-required reference to
@@ -1827,9 +1729,9 @@ private static IndexMetadata.State excludeState(IndicesOptions options) {
18271729
final IndexMetadata.State excludeState;
18281730
if (options.expandWildcardsOpen() && options.expandWildcardsClosed()) {
18291731
excludeState = null;
1830-
} else if (options.expandWildcardsOpen() && options.expandWildcardsClosed() == false) {
1732+
} else if (options.expandWildcardsOpen()) {
18311733
excludeState = IndexMetadata.State.CLOSE;
1832-
} else if (options.expandWildcardsClosed() && options.expandWildcardsOpen() == false) {
1734+
} else if (options.expandWildcardsClosed()) {
18331735
excludeState = IndexMetadata.State.OPEN;
18341736
} else {
18351737
assert false : "this shouldn't get called if wildcards expand to none";

x-pack/plugin/core/template-resources/src/main/resources/fleet-enrollment-api-keys.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
},
3737
"namespaces": {
3838
"type": "keyword"
39+
},
40+
"hidden": {
41+
"type": "boolean"
3942
}
4043
}
4144
}

x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/PushQueriesIT.java

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,31 +52,48 @@ public void testPushEqualityOnDefaults() throws IOException {
5252
testPushQuery(value, """
5353
FROM test
5454
| WHERE test == "%value"
55-
""", "#test.keyword:%value -_ignored:test.keyword", false);
55+
""", "*:*", true, true);
5656
}
5757

5858
public void testPushEqualityOnDefaultsTooBigToPush() throws IOException {
5959
String value = "a".repeat(between(257, 1000));
6060
testPushQuery(value, """
6161
FROM test
6262
| WHERE test == "%value"
63-
""", "*:*", true);
63+
""", "*:*", true, true);
64+
}
65+
66+
public void testPushInequalityOnDefaults() throws IOException {
67+
String value = "v".repeat(between(0, 256));
68+
testPushQuery(value, """
69+
FROM test
70+
| WHERE test != "%different_value"
71+
""", "*:*", true, true);
72+
}
73+
74+
public void testPushInequalityOnDefaultsTooBigToPush() throws IOException {
75+
String value = "a".repeat(between(257, 1000));
76+
testPushQuery(value, """
77+
FROM test
78+
| WHERE test != "%value"
79+
""", "*:*", true, false);
6480
}
6581

6682
public void testPushCaseInsensitiveEqualityOnDefaults() throws IOException {
6783
String value = "a".repeat(between(0, 256));
6884
testPushQuery(value, """
6985
FROM test
7086
| WHERE TO_LOWER(test) == "%value"
71-
""", "*:*", true);
87+
""", "*:*", true, true);
7288
}
7389

74-
private void testPushQuery(String value, String esqlQuery, String luceneQuery, boolean filterInCompute) throws IOException {
90+
private void testPushQuery(String value, String esqlQuery, String luceneQuery, boolean filterInCompute, boolean found)
91+
throws IOException {
7592
indexValue(value);
93+
String differentValue = randomValueOtherThan(value, () -> randomAlphaOfLength(value.length()));
7694

77-
RestEsqlTestCase.RequestObjectBuilder builder = requestObjectBuilder().query(
78-
esqlQuery.replaceAll("%value", value) + "\n| KEEP test"
79-
);
95+
String replacedQuery = esqlQuery.replaceAll("%value", value).replaceAll("%different_value", differentValue);
96+
RestEsqlTestCase.RequestObjectBuilder builder = requestObjectBuilder().query(replacedQuery + "\n| KEEP test");
8097
builder.profile(true);
8198
Map<String, Object> result = runEsql(builder, new AssertWarnings.NoWarnings(), RestEsqlTestCase.Mode.SYNC);
8299
assertResultMap(
@@ -88,7 +105,7 @@ private void testPushQuery(String value, String esqlQuery, String luceneQuery, b
88105
.entry("query", matchesMap().extraOk())
89106
),
90107
matchesList().item(matchesMap().entry("name", "test").entry("type", "text")),
91-
equalTo(List.of(List.of(value)))
108+
equalTo(found ? List.of(List.of(value)) : List.of())
92109
);
93110

94111
@SuppressWarnings("unchecked")
@@ -100,7 +117,7 @@ private void testPushQuery(String value, String esqlQuery, String luceneQuery, b
100117
@SuppressWarnings("unchecked")
101118
List<Map<String, Object>> operators = (List<Map<String, Object>>) p.get("operators");
102119
for (Map<String, Object> o : operators) {
103-
sig.add(checkOperatorProfile(o, luceneQuery.replaceAll("%value", value)));
120+
sig.add(checkOperatorProfile(o, luceneQuery.replaceAll("%value", value).replaceAll("%different_value", differentValue)));
104121
}
105122
String description = p.get("description").toString();
106123
switch (description) {

x-pack/plugin/esql/qa/testFixtures/src/main/resources/string.csv-spec

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2332,3 +2332,40 @@ warning:Line 2:9: java.lang.IllegalArgumentException: single-value function enco
23322332
@timestamp:date | message:text
23332333
2023-10-23T13:55:01.546Z|More than one hundred characters long so it isn't indexed by the sub keyword field with ignore_above:100
23342334
;
2335+
2336+
mvStringNotEquals
2337+
FROM mv_text
2338+
| WHERE message != "Connected to 10.1.0.2"
2339+
| KEEP @timestamp, message
2340+
;
2341+
warning:Line 2:9: evaluation of [message != \"Connected to 10.1.0.2\"] failed, treating result as null. Only first 20 failures recorded.
2342+
warning:Line 2:9: java.lang.IllegalArgumentException: single-value function encountered multi-value
2343+
2344+
@timestamp:date | message:text
2345+
2023-10-23T13:55:01.544Z|Connected to 10.1.0.1
2346+
2023-10-23T13:55:01.546Z|More than one hundred characters long so it isn't indexed by the sub keyword field with ignore_above:100
2347+
;
2348+
2349+
mvStringNotEqualsFound
2350+
FROM mv_text
2351+
| WHERE message != "Connected to 10.1.0.1"
2352+
| KEEP @timestamp, message
2353+
;
2354+
warning:Line 2:9: evaluation of [message != \"Connected to 10.1.0.1\"] failed, treating result as null. Only first 20 failures recorded.
2355+
warning:Line 2:9: java.lang.IllegalArgumentException: single-value function encountered multi-value
2356+
2357+
@timestamp:date | message:text
2358+
2023-10-23T13:55:01.546Z|More than one hundred characters long so it isn't indexed by the sub keyword field with ignore_above:100
2359+
;
2360+
2361+
mvStringNotEqualsLong
2362+
FROM mv_text
2363+
| WHERE message != "More than one hundred characters long so it isn't indexed by the sub keyword field with ignore_above:100"
2364+
| KEEP @timestamp, message
2365+
;
2366+
warning:Line 2:9: evaluation of [message != \"More than one hundred characters long so it isn't indexed by the sub keyword field with ignore_above:100\"] failed, treating result as null. Only first 20 failures recorded.
2367+
warning:Line 2:9: java.lang.IllegalArgumentException: single-value function encountered multi-value
2368+
2369+
@timestamp:date | message:text
2370+
2023-10-23T13:55:01.544Z|Connected to 10.1.0.1
2371+
;

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/Equals.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public Equals(Source source, Expression left, Expression right, ZoneId zoneId) {
130130
@Override
131131
public boolean translatable(LucenePushdownPredicates pushdownPredicates) {
132132
if (right() instanceof Literal lit) {
133-
if (left().dataType() == DataType.TEXT && left() instanceof FieldAttribute fa) {
133+
if (false && left().dataType() == DataType.TEXT && left() instanceof FieldAttribute fa) {
134134
if (pushdownPredicates.canUseEqualityOnSyntheticSourceDelegate(fa, ((BytesRef) lit.value()).utf8ToString())) {
135135
return true;
136136
}
@@ -142,7 +142,8 @@ public boolean translatable(LucenePushdownPredicates pushdownPredicates) {
142142
@Override
143143
public Query asQuery(LucenePushdownPredicates pushdownPredicates, TranslatorHandler handler) {
144144
if (right() instanceof Literal lit) {
145-
if (left().dataType() == DataType.TEXT && left() instanceof FieldAttribute fa) {
145+
// Disabled because it cased a bug with !=. Fix incoming shortly.
146+
if (false && left().dataType() == DataType.TEXT && left() instanceof FieldAttribute fa) {
146147
String value = ((BytesRef) lit.value()).utf8ToString();
147148
if (pushdownPredicates.canUseEqualityOnSyntheticSourceDelegate(fa, value)) {
148149
String name = handler.nameOf(fa);

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/PhysicalPlanOptimizerTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7793,6 +7793,7 @@ public void testReductionPlanForAggs() {
77937793
}
77947794

77957795
public void testEqualsPushdownToDelegate() {
7796+
assumeFalse("disabled from bug", true);
77967797
var optimized = optimizedPlan(physicalPlan("""
77977798
FROM test
77987799
| WHERE job == "v"

x-pack/plugin/fleet/src/main/java/org/elasticsearch/xpack/fleet/Fleet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public class Fleet extends Plugin implements SystemIndexPlugin {
8080
private static final List<String> ALLOWED_PRODUCTS = List.of("kibana", "fleet");
8181
private static final int FLEET_ACTIONS_MAPPINGS_VERSION = 2;
8282
private static final int FLEET_AGENTS_MAPPINGS_VERSION = 2;
83-
private static final int FLEET_ENROLLMENT_API_KEYS_MAPPINGS_VERSION = 2;
83+
private static final int FLEET_ENROLLMENT_API_KEYS_MAPPINGS_VERSION = 3;
8484
private static final int FLEET_SECRETS_MAPPINGS_VERSION = 1;
8585
private static final int FLEET_POLICIES_MAPPINGS_VERSION = 2;
8686
private static final int FLEET_POLICIES_LEADER_MAPPINGS_VERSION = 1;

0 commit comments

Comments
 (0)