Skip to content

Commit

Permalink
Add back snapshot build restriction for match and qstr functions
Browse files Browse the repository at this point in the history
This reverts commit 581894a
  • Loading branch information
carlosdelest committed Oct 21, 2024
1 parent 8c37875 commit def4601
Show file tree
Hide file tree
Showing 21 changed files with 1,548 additions and 1,535 deletions.
5 changes: 0 additions & 5 deletions docs/changelog/114482.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion docs/reference/esql/functions/kibana/definition/match.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/esql/functions/kibana/definition/qstr.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
import org.elasticsearch.xpack.esql.VerificationException;
import org.elasticsearch.xpack.esql.action.AbstractEsqlIntegTestCase;
import org.elasticsearch.xpack.esql.action.ColumnInfoImpl;
import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
import org.elasticsearch.xpack.esql.action.EsqlQueryRequest;
import org.elasticsearch.xpack.esql.action.EsqlQueryResponse;
import org.elasticsearch.xpack.esql.core.type.DataType;
import org.junit.Before;

Expand All @@ -33,6 +36,12 @@ public void setupIndex() {
createAndPopulateIndex();
}

@Override
protected EsqlQueryResponse run(EsqlQueryRequest request) {
assumeTrue("qstr function available in snapshot builds only", EsqlCapabilities.Cap.QSTR_FUNCTION.isEnabled());
return super.run(request);
}

public void testSimpleQueryString() {
var query = """
FROM test
Expand Down
18 changes: 9 additions & 9 deletions x-pack/plugin/esql/src/main/antlr/EsqlBaseLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ ASTERISK : '*';
SLASH : '/';
PERCENT : '%';

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

NAMED_OR_POSITIONAL_PARAM
Expand Down Expand Up @@ -305,8 +305,8 @@ mode PROJECT_MODE;
PROJECT_PIPE : PIPE -> type(PIPE), popMode;
PROJECT_DOT: DOT -> type(DOT);
PROJECT_COMMA : COMMA -> type(COMMA);
PROJECT_PARAM : {this.isDevVersion()}? PARAM -> type(PARAM);
PROJECT_NAMED_OR_POSITIONAL_PARAM : {this.isDevVersion()}? NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);
PROJECT_PARAM : PARAM -> type(PARAM);
PROJECT_NAMED_OR_POSITIONAL_PARAM : NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);
fragment UNQUOTED_ID_BODY_WITH_PATTERN
: (LETTER | DIGIT | UNDERSCORE | ASTERISK)
Expand Down Expand Up @@ -340,8 +340,8 @@ RENAME_PIPE : PIPE -> type(PIPE), popMode;
RENAME_ASSIGN : ASSIGN -> type(ASSIGN);
RENAME_COMMA : COMMA -> type(COMMA);
RENAME_DOT: DOT -> type(DOT);
RENAME_PARAM : {this.isDevVersion()}? PARAM -> type(PARAM);
RENAME_NAMED_OR_POSITIONAL_PARAM : {this.isDevVersion()}? NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);
RENAME_PARAM : PARAM -> type(PARAM);
RENAME_NAMED_OR_POSITIONAL_PARAM : NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);
AS : 'as';
Expand Down Expand Up @@ -413,8 +413,8 @@ ENRICH_FIELD_QUOTED_IDENTIFIER
: QUOTED_IDENTIFIER -> type(QUOTED_IDENTIFIER)
;

ENRICH_FIELD_PARAM : {this.isDevVersion()}? PARAM -> type(PARAM);
ENRICH_FIELD_NAMED_OR_POSITIONAL_PARAM : {this.isDevVersion()}? NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);
ENRICH_FIELD_PARAM : PARAM -> type(PARAM);
ENRICH_FIELD_NAMED_OR_POSITIONAL_PARAM : NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);

ENRICH_FIELD_LINE_COMMENT
: LINE_COMMENT -> channel(HIDDEN)
Expand All @@ -431,8 +431,8 @@ ENRICH_FIELD_WS
mode MVEXPAND_MODE;
MVEXPAND_PIPE : PIPE -> type(PIPE), popMode;
MVEXPAND_DOT: DOT -> type(DOT);
MVEXPAND_PARAM : {this.isDevVersion()}? PARAM -> type(PARAM);
MVEXPAND_NAMED_OR_POSITIONAL_PARAM : {this.isDevVersion()}? NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);
MVEXPAND_PARAM : PARAM -> type(PARAM);
MVEXPAND_NAMED_OR_POSITIONAL_PARAM : NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);

MVEXPAND_QUOTED_IDENTIFIER
: QUOTED_IDENTIFIER -> type(QUOTED_IDENTIFIER)
Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugin/esql/src/main/antlr/EsqlBaseLexer.tokens

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions x-pack/plugin/esql/src/main/antlr/EsqlBaseParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ regexBooleanExpression
;

matchBooleanExpression
: valueExpression MATCH queryString=string
: valueExpression DEV_MATCH queryString=string
;

valueExpression
Expand Down Expand Up @@ -106,7 +106,7 @@ functionExpression

functionName
// Additional function identifiers that are already a reserved word in the language
: MATCH
: {this.isDevVersion()}? DEV_MATCH
| identifierOrParameter
;

Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugin/esql/src/main/antlr/EsqlBaseParser.tokens

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,12 @@ public enum Cap {
/**
* QSTR function
*/
QSTR_FUNCTION,
QSTR_FUNCTION(true),

/**
* MATCH function
*/
MATCH_FUNCTION,
MATCH_FUNCTION(true),

/**
* Don't optimize CASE IS NOT NULL function by not requiring the fields to be not null as well.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,17 +388,18 @@ private FunctionDefinition[][] functions() {
def(MvSlice.class, MvSlice::new, "mv_slice"),
def(MvZip.class, MvZip::new, "mv_zip"),
def(MvSum.class, MvSum::new, "mv_sum"),
def(Split.class, Split::new, "split") },
// fulltext functions
new FunctionDefinition[] { def(Match.class, Match::new, "match"), def(QueryString.class, QueryString::new, "qstr") } };
def(Split.class, Split::new, "split") } };

}

private static FunctionDefinition[][] snapshotFunctions() {
return new FunctionDefinition[][] {
new FunctionDefinition[] {
def(Rate.class, Rate::withUnresolvedTimestamp, "rate"),
def(Categorize.class, Categorize::new, "categorize"),
def(Rate.class, Rate::withUnresolvedTimestamp, "rate") } };
// Full text functions
def(QueryString.class, QueryString::new, "qstr"),
def(Match.class, Match::new, "match") } };
}

public EsqlFunctionRegistry snapshotRegistry() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@

import org.apache.lucene.util.BytesRef;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
import org.elasticsearch.xpack.esql.core.expression.Expression;
import org.elasticsearch.xpack.esql.core.expression.Nullability;
import org.elasticsearch.xpack.esql.core.expression.TypeResolutions;
import org.elasticsearch.xpack.esql.core.expression.function.Function;
import org.elasticsearch.xpack.esql.core.tree.Source;
import org.elasticsearch.xpack.esql.core.type.DataType;

import java.util.ArrayList;
import java.util.List;

import static org.elasticsearch.common.logging.LoggerMessageFormat.format;
Expand All @@ -30,7 +32,14 @@
*/
public abstract class FullTextFunction extends Function {
public static List<NamedWriteableRegistry.Entry> getNamedWriteables() {
return List.of(QueryString.ENTRY, Match.ENTRY);
List<NamedWriteableRegistry.Entry> entries = new ArrayList<>();
if (EsqlCapabilities.Cap.QSTR_FUNCTION.isEnabled()) {
entries.add(QueryString.ENTRY);
}
if (EsqlCapabilities.Cap.MATCH_FUNCTION.isEnabled()) {
entries.add(Match.ENTRY);
}
return entries;
}

private final Expression query;
Expand Down

Large diffs are not rendered by default.

Loading

0 comments on commit def4601

Please sign in to comment.