Skip to content

Commit 392777d

Browse files
authored
Return unsupported attributes in FORK output (#128508)
1 parent df82c06 commit 392777d

File tree

5 files changed

+37
-17
lines changed

5 files changed

+37
-17
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
import static org.elasticsearch.xpack.esql.CsvTestUtils.isEnabled;
4747
import static org.elasticsearch.xpack.esql.CsvTestsDataLoader.ENRICH_SOURCE_INDICES;
4848
import static org.elasticsearch.xpack.esql.EsqlTestUtils.classpathResources;
49-
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.FORK_V4;
49+
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.FORK_V5;
5050
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.INLINESTATS;
5151
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.INLINESTATS_V2;
5252
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.INLINESTATS_V7;
@@ -132,7 +132,7 @@ protected void shouldSkipTest(String testName) throws IOException {
132132
assumeFalse("LOOKUP JOIN not yet supported in CCS", testCase.requiredCapabilities.contains(JOIN_LOOKUP_V12.capabilityName()));
133133
// Unmapped fields require a coorect capability response from every cluster, which isn't currently implemented.
134134
assumeFalse("UNMAPPED FIELDS not yet supported in CCS", testCase.requiredCapabilities.contains(UNMAPPED_FIELDS.capabilityName()));
135-
assumeFalse("FORK not yet supported in CCS", testCase.requiredCapabilities.contains(FORK_V4.capabilityName()));
135+
assumeFalse("FORK not yet supported in CCS", testCase.requiredCapabilities.contains(FORK_V5.capabilityName()));
136136
}
137137

138138
@Override

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

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//
44

55
simpleFork
6-
required_capability: fork_v4
6+
required_capability: fork_v5
77

88
FROM employees
99
| FORK ( WHERE emp_no == 10001 )
@@ -18,7 +18,7 @@ emp_no:integer | _fork:keyword
1818
;
1919

2020
forkWithWhereSortAndLimit
21-
required_capability: fork_v4
21+
required_capability: fork_v5
2222

2323
FROM employees
2424
| FORK ( WHERE hire_date < "1985-03-01T00:00:00Z" | SORT first_name | LIMIT 5 )
@@ -38,7 +38,7 @@ emp_no:integer | first_name:keyword | _fork:keyword
3838
;
3939

4040
fiveFork
41-
required_capability: fork_v4
41+
required_capability: fork_v5
4242

4343
FROM employees
4444
| FORK ( WHERE emp_no == 10005 )
@@ -59,7 +59,7 @@ fork5 | 10001
5959
;
6060

6161
forkWithWhereSortDescAndLimit
62-
required_capability: fork_v4
62+
required_capability: fork_v5
6363

6464
FROM employees
6565
| FORK ( WHERE hire_date < "1985-03-01T00:00:00Z" | SORT first_name DESC | LIMIT 2 )
@@ -76,7 +76,7 @@ fork2 | 10087 | Xinglin
7676
;
7777

7878
forkWithCommonPrefilter
79-
required_capability: fork_v4
79+
required_capability: fork_v5
8080

8181
FROM employees
8282
| WHERE emp_no > 10050
@@ -94,7 +94,7 @@ fork2 | 10100
9494
;
9595

9696
forkWithSemanticSearchAndScore
97-
required_capability: fork_v4
97+
required_capability: fork_v5
9898
required_capability: semantic_text_field_caps
9999
required_capability: metadata_score
100100

@@ -114,7 +114,7 @@ fork2 | 6.093784261960139E18 | 2 | all we have to decide is w
114114
;
115115

116116
forkWithEvals
117-
required_capability: fork_v4
117+
required_capability: fork_v5
118118

119119
FROM employees
120120
| FORK (WHERE emp_no == 10048 OR emp_no == 10081 | EVAL x = "abc" | EVAL y = 1)
@@ -131,7 +131,7 @@ fork2 | 10087 | def | null | 2
131131
;
132132

133133
forkWithStats
134-
required_capability: fork_v4
134+
required_capability: fork_v5
135135

136136
FROM employees
137137
| FORK (WHERE emp_no == 10048 OR emp_no == 10081)
@@ -152,7 +152,7 @@ fork4 | null | 100 | 10001 | null
152152
;
153153

154154
forkWithDissect
155-
required_capability: fork_v4
155+
required_capability: fork_v5
156156

157157
FROM employees
158158
| WHERE emp_no == 10048 OR emp_no == 10081
@@ -172,7 +172,7 @@ fork2 | 10081 | Rosen | 10081 | null | Zhongwei
172172
;
173173

174174
forkWithMixOfCommands
175-
required_capability: fork_v4
175+
required_capability: fork_v5
176176

177177
FROM employees
178178
| WHERE emp_no == 10048 OR emp_no == 10081
@@ -197,7 +197,7 @@ fork4 | 10081 | abc | aaa | null | null
197197
;
198198

199199
forkWithFiltersOnConstantValues
200-
required_capability: fork_v4
200+
required_capability: fork_v5
201201

202202
FROM employees
203203
| EVAL z = 1
@@ -216,3 +216,17 @@ fork2 | 10081 | null | null | 1
216216
fork2 | 10087 | null | null | 1
217217
fork3 | null | 100 | 10100 | 10001
218218
;
219+
220+
forkWithUnsupportedAttributes
221+
required_capability: fork_v5
222+
223+
FROM heights
224+
| FORK (SORT description DESC | LIMIT 1 | EVAL x = length(description) )
225+
(SORT description ASC | LIMIT 1)
226+
| SORT _fork
227+
;
228+
229+
description:keyword | height_range:unsupported | x:integer | _fork:keyword
230+
Very Tall | null | 9 | fork1
231+
Medium Height | null | null | fork2
232+
;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ public enum Cap {
10191019
/**
10201020
* Support streaming of sub plan results
10211021
*/
1022-
FORK_V4(Build.current().isSnapshot()),
1022+
FORK_V5(Build.current().isSnapshot()),
10231023

10241024
/**
10251025
* Support for the {@code leading_zeros} named parameter.

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,12 +1052,18 @@ private LogicalPlan resolveKeep(Project p, List<Attribute> childOutput) {
10521052
final int priority;
10531053
if (proj instanceof UnresolvedStar) {
10541054
resolved = childOutput;
1055-
priority = 2;
1055+
priority = 4;
10561056
} else if (proj instanceof UnresolvedNamePattern up) {
10571057
resolved = resolveAgainstList(up, childOutput);
1058-
priority = 1;
1058+
priority = 3;
1059+
} else if (proj instanceof UnsupportedAttribute) {
1060+
resolved = List.of(proj.toAttribute());
1061+
priority = 2;
10591062
} else if (proj instanceof UnresolvedAttribute ua) {
10601063
resolved = resolveAgainstList(ua, childOutput);
1064+
priority = 1;
1065+
} else if (proj.resolved()) {
1066+
resolved = List.of(proj.toAttribute());
10611067
priority = 0;
10621068
} else {
10631069
throw new EsqlIllegalArgumentException("unexpected projection: " + proj);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ public final void test() throws Throwable {
310310
);
311311
assumeFalse(
312312
"CSV tests cannot currently handle FORK",
313-
testCase.requiredCapabilities.contains(EsqlCapabilities.Cap.FORK_V4.capabilityName())
313+
testCase.requiredCapabilities.contains(EsqlCapabilities.Cap.FORK_V5.capabilityName())
314314
);
315315
assumeFalse(
316316
"CSV tests cannot currently handle multi_match function that depends on Lucene",

0 commit comments

Comments
 (0)