Skip to content

Commit dec9eac

Browse files
authored
Add back snapshot build restriction for match and qstr functions (#115253)
1 parent 767ca73 commit dec9eac

File tree

21 files changed

+1561
-1471
lines changed

21 files changed

+1561
-1471
lines changed

docs/changelog/114482.yaml

Lines changed: 0 additions & 5 deletions
This file was deleted.

docs/reference/esql/functions/kibana/definition/match.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/esql/functions/kibana/definition/qstr.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/plugin/QueryStringIT.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
import org.elasticsearch.xpack.esql.VerificationException;
1515
import org.elasticsearch.xpack.esql.action.AbstractEsqlIntegTestCase;
1616
import org.elasticsearch.xpack.esql.action.ColumnInfoImpl;
17+
import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
18+
import org.elasticsearch.xpack.esql.action.EsqlQueryRequest;
19+
import org.elasticsearch.xpack.esql.action.EsqlQueryResponse;
1720
import org.elasticsearch.xpack.esql.core.type.DataType;
1821
import org.junit.Before;
1922

@@ -33,6 +36,12 @@ public void setupIndex() {
3336
createAndPopulateIndex();
3437
}
3538

39+
@Override
40+
protected EsqlQueryResponse run(EsqlQueryRequest request) {
41+
assumeTrue("qstr function available in snapshot builds only", EsqlCapabilities.Cap.QSTR_FUNCTION.isEnabled());
42+
return super.run(request);
43+
}
44+
3645
public void testSimpleQueryString() {
3746
var query = """
3847
FROM test

x-pack/plugin/esql/src/main/antlr/EsqlBaseLexer.g4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ ASTERISK : '*';
208208
SLASH : '/';
209209
PERCENT : '%';
210210

211-
MATCH : 'match';
211+
DEV_MATCH : {this.isDevVersion()}? 'match';
212212
NESTED_WHERE : WHERE -> type(WHERE);
213213

214214
NAMED_OR_POSITIONAL_PARAM

x-pack/plugin/esql/src/main/antlr/EsqlBaseLexer.tokens

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/src/main/antlr/EsqlBaseParser.g4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ regexBooleanExpression
7777
;
7878

7979
matchBooleanExpression
80-
: valueExpression MATCH queryString=string
80+
: valueExpression DEV_MATCH queryString=string
8181
;
8282

8383
valueExpression
@@ -106,7 +106,7 @@ functionExpression
106106

107107
functionName
108108
// Additional function identifiers that are already a reserved word in the language
109-
: MATCH
109+
: {this.isDevVersion()}? DEV_MATCH
110110
| identifierOrParameter
111111
;
112112

x-pack/plugin/esql/src/main/antlr/EsqlBaseParser.tokens

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,12 @@ public enum Cap {
360360
/**
361361
* QSTR function
362362
*/
363-
QSTR_FUNCTION,
363+
QSTR_FUNCTION(true),
364364

365365
/**
366366
* MATCH function
367367
*/
368-
MATCH_FUNCTION,
368+
MATCH_FUNCTION(true),
369369

370370
/**
371371
* Don't optimize CASE IS NOT NULL function by not requiring the fields to be not null as well.

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/EsqlFunctionRegistry.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,17 +388,18 @@ private FunctionDefinition[][] functions() {
388388
def(MvSlice.class, MvSlice::new, "mv_slice"),
389389
def(MvZip.class, MvZip::new, "mv_zip"),
390390
def(MvSum.class, MvSum::new, "mv_sum"),
391-
def(Split.class, Split::new, "split") },
392-
// fulltext functions
393-
new FunctionDefinition[] { def(Match.class, Match::new, "match"), def(QueryString.class, QueryString::new, "qstr") } };
391+
def(Split.class, Split::new, "split") } };
394392

395393
}
396394

397395
private static FunctionDefinition[][] snapshotFunctions() {
398396
return new FunctionDefinition[][] {
399397
new FunctionDefinition[] {
398+
def(Rate.class, Rate::withUnresolvedTimestamp, "rate"),
400399
def(Categorize.class, Categorize::new, "categorize"),
401-
def(Rate.class, Rate::withUnresolvedTimestamp, "rate") } };
400+
// Full text functions
401+
def(QueryString.class, QueryString::new, "qstr"),
402+
def(Match.class, Match::new, "match") } };
402403
}
403404

404405
public EsqlFunctionRegistry snapshotRegistry() {

0 commit comments

Comments
 (0)