Skip to content

Commit

Permalink
Remove snapshot build restriction for match and qstr functions (elast…
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosdelest authored and georgewallace committed Oct 25, 2024
1 parent 06f83b2 commit 2961658
Show file tree
Hide file tree
Showing 21 changed files with 966 additions and 1,049 deletions.
5 changes: 5 additions & 0 deletions docs/changelog/114482.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 114482
summary: Remove snapshot build restriction for match and qstr functions
area: ES|QL
type: feature
issues: []
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,9 +14,6 @@
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 @@ -36,12 +33,6 @@ 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
2 changes: 1 addition & 1 deletion 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 : '%';

DEV_MATCH : {this.isDevVersion()}? 'match';
MATCH : 'match';

NAMED_OR_POSITIONAL_PARAM
: PARAM (LETTER | UNDERSCORE) UNQUOTED_ID_BODY*
Expand Down
3 changes: 2 additions & 1 deletion 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 DEV_MATCH queryString=string
: valueExpression 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
: {this.isDevVersion()}? DEV_MATCH
: MATCH
| identifierOrParameter
;

Expand Down
3 changes: 2 additions & 1 deletion 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 @@ -344,12 +344,12 @@ public enum Cap {
/**
* QSTR function
*/
QSTR_FUNCTION(true),
QSTR_FUNCTION,

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

/**
* 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 @@ -386,18 +386,17 @@ 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") } };
def(Split.class, Split::new, "split") },
// fulltext functions
new FunctionDefinition[] { def(Match.class, Match::new, "match"), def(QueryString.class, QueryString::new, "qstr") } };

}

private static FunctionDefinition[][] snapshotFunctions() {
return new FunctionDefinition[][] {
new FunctionDefinition[] {
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") } };
def(Rate.class, Rate::withUnresolvedTimestamp, "rate") } };
}

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

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 @@ -32,14 +30,7 @@
*/
public abstract class FullTextFunction extends Function {
public static List<NamedWriteableRegistry.Entry> getNamedWriteables() {
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;
return List.of(QueryString.ENTRY, Match.ENTRY);
}

private final Expression query;
Expand Down

Large diffs are not rendered by default.

Loading

0 comments on commit 2961658

Please sign in to comment.