Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -1329,6 +1329,11 @@ public enum Cap {
*/
FIX_MV_EXPAND_INCONSISTENT_COLUMN_ORDER,

/**
* Support for the SET command.
*/
SET_COMMAND(Build.current().isSnapshot()),

/**
* (Re)Added EXPLAIN command
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ public void testInvalidSample() {
}

public void testSet() {
assumeTrue("SET command available in snapshot only", EsqlCapabilities.Cap.SET_COMMAND.isEnabled());
EsqlStatement query = parse("SET foo = \"bar\"; row a = 1", new QueryParams());
assertThat(query.plan(), is(instanceOf(Row.class)));
assertThat(query.settings().size(), is(1));
Expand All @@ -232,6 +233,7 @@ public void testSet() {
}

public void testSetWithTripleQuotes() {
assumeTrue("SET command available in snapshot only", EsqlCapabilities.Cap.SET_COMMAND.isEnabled());
EsqlStatement query = parse("SET foo = \"\"\"bar\"baz\"\"\"; row a = 1", new QueryParams());
assertThat(query.plan(), is(instanceOf(Row.class)));
assertThat(query.settings().size(), is(1));
Expand All @@ -249,6 +251,7 @@ public void testSetWithTripleQuotes() {
}

public void testMultipleSet() {
assumeTrue("SET command available in snapshot only", EsqlCapabilities.Cap.SET_COMMAND.isEnabled());
EsqlStatement query = parse(
"SET foo = \"bar\"; SET bar = 2; SET foo = \"baz\"; SET x = 3.5; SET y = false; SET z = null; row a = 1",
new QueryParams()
Expand All @@ -265,6 +268,7 @@ public void testMultipleSet() {
}

public void testSetArrays() {
assumeTrue("SET command available in snapshot only", EsqlCapabilities.Cap.SET_COMMAND.isEnabled());
EsqlStatement query = parse("SET foo = [\"bar\", \"baz\"]; SET bar = [1, 2, 3]; row a = 1", new QueryParams());
assertThat(query.plan(), is(instanceOf(Row.class)));
assertThat(query.settings().size(), is(2));
Expand All @@ -274,6 +278,7 @@ public void testSetArrays() {
}

public void testSetWithNamedParams() {
assumeTrue("SET command available in snapshot only", EsqlCapabilities.Cap.SET_COMMAND.isEnabled());
EsqlStatement query = parse(
"SET foo = \"bar\"; SET bar = ?a; SET foo = \"baz\"; SET x = ?x; row a = 1",
new QueryParams(
Expand All @@ -293,6 +298,7 @@ public void testSetWithNamedParams() {
}

public void testSetWithPositionalParams() {
assumeTrue("SET command available in snapshot only", EsqlCapabilities.Cap.SET_COMMAND.isEnabled());
EsqlStatement query = parse(
"SET foo = \"bar\"; SET bar = ?; SET foo = \"baz\"; SET x = ?; row a = ?",
new QueryParams(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
import org.elasticsearch.common.geo.GeoPoint;
import org.elasticsearch.common.unit.DistanceUnit;
import org.elasticsearch.script.ScoreScriptUtils;
import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
import org.elasticsearch.xpack.esql.core.expression.Expression;
import org.elasticsearch.xpack.esql.core.expression.Literal;
import org.elasticsearch.xpack.esql.core.expression.MapExpression;
import org.elasticsearch.xpack.esql.core.tree.Source;
import org.elasticsearch.xpack.esql.core.type.DataType;
import org.elasticsearch.xpack.esql.expression.function.AbstractScalarFunctionTestCase;
import org.elasticsearch.xpack.esql.expression.function.TestCaseSupplier;
import org.junit.BeforeClass;

import java.time.Duration;
import java.time.Instant;
Expand All @@ -44,6 +46,11 @@ public DecayTests(@Name("TestCase") Supplier<TestCaseSupplier.TestCase> testCase
this.testCase = testCaseSupplier.get();
}

@BeforeClass
public static void checkCapability() {
assumeTrue("Decay function tests require the DECAY_FUNCTION capability", EsqlCapabilities.Cap.DECAY_FUNCTION.isEnabled());
}

@ParametersFactory
public static Iterable<Object[]> parameters() {
List<TestCaseSupplier> testCaseSuppliers = new ArrayList<>();
Expand Down