Skip to content

Commit 25acbf1

Browse files
committed
Clean useless conditional in tests.
1 parent 5f10061 commit 25acbf1

File tree

6 files changed

+17
-49
lines changed

6 files changed

+17
-49
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ private static FunctionDefinition[][] functions() {
528528
def(LastOverTime.class, uni(LastOverTime::new), "last_over_time"),
529529
def(FirstOverTime.class, uni(FirstOverTime::new), "first_over_time"),
530530
// dense vector function
531-
def(TextEmbedding.class, bi(TextEmbedding::new), "text_embedding")}};
531+
def(TextEmbedding.class, bi(TextEmbedding::new), "text_embedding") } };
532532

533533
}
534534

@@ -547,7 +547,7 @@ private static FunctionDefinition[][] snapshotFunctions() {
547547
def(L1Norm.class, L1Norm::new, "v_l1_norm"),
548548
def(L2Norm.class, L2Norm::new, "v_l2_norm"),
549549
def(Magnitude.class, Magnitude::new, "v_magnitude"),
550-
def(Hamming.class, Hamming::new, "v_hamming")}};
550+
def(Hamming.class, Hamming::new, "v_hamming") } };
551551
}
552552

553553
public EsqlFunctionRegistry snapshotRegistry() {

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3814,8 +3814,6 @@ private void assertEmptyEsRelation(LogicalPlan plan) {
38143814
}
38153815

38163816
public void testTextEmbeddingResolveInferenceId() {
3817-
assumeTrue("TEXT_EMBEDDING function required", EsqlCapabilities.Cap.TEXT_EMBEDDING_FUNCTION.isEnabled());
3818-
38193817
LogicalPlan plan = analyze(
38203818
String.format(Locale.ROOT, """
38213819
FROM books METADATA _score | EVAL embedding = TEXT_EMBEDDING("italian food recipe", "%s")""", TEXT_EMBEDDING_INFERENCE_ID),
@@ -3833,8 +3831,6 @@ public void testTextEmbeddingResolveInferenceId() {
38333831
}
38343832

38353833
public void testTextEmbeddingFunctionResolveType() {
3836-
assumeTrue("TEXT_EMBEDDING function required", EsqlCapabilities.Cap.TEXT_EMBEDDING_FUNCTION.isEnabled());
3837-
38383834
LogicalPlan plan = analyze(
38393835
String.format(Locale.ROOT, """
38403836
FROM books METADATA _score| EVAL embedding = TEXT_EMBEDDING("italian food recipe", "%s")""", TEXT_EMBEDDING_INFERENCE_ID),
@@ -3853,8 +3849,6 @@ public void testTextEmbeddingFunctionResolveType() {
38533849
}
38543850

38553851
public void testTextEmbeddingFunctionMissingInferenceIdError() {
3856-
assumeTrue("TEXT_EMBEDDING function required", EsqlCapabilities.Cap.TEXT_EMBEDDING_FUNCTION.isEnabled());
3857-
38583852
VerificationException ve = expectThrows(
38593853
VerificationException.class,
38603854
() -> analyze(
@@ -3868,8 +3862,6 @@ public void testTextEmbeddingFunctionMissingInferenceIdError() {
38683862
}
38693863

38703864
public void testTextEmbeddingFunctionInvalidInferenceIdError() {
3871-
assumeTrue("TEXT_EMBEDDING function required", EsqlCapabilities.Cap.TEXT_EMBEDDING_FUNCTION.isEnabled());
3872-
38733865
String inferenceId = randomInferenceIdOtherThan(TEXT_EMBEDDING_INFERENCE_ID);
38743866
VerificationException ve = expectThrows(
38753867
VerificationException.class,
@@ -3887,8 +3879,6 @@ public void testTextEmbeddingFunctionInvalidInferenceIdError() {
38873879
}
38883880

38893881
public void testTextEmbeddingFunctionWithoutModel() {
3890-
assumeTrue("TEXT_EMBEDDING function required", EsqlCapabilities.Cap.TEXT_EMBEDDING_FUNCTION.isEnabled());
3891-
38923882
ParsingException ve = expectThrows(ParsingException.class, () -> analyze("""
38933883
FROM books METADATA _score| EVAL embedding = TEXT_EMBEDDING("italian food recipe")""", "mapping-books.json"));
38943884

@@ -3899,8 +3889,6 @@ public void testTextEmbeddingFunctionWithoutModel() {
38993889
}
39003890

39013891
public void testKnnFunctionWithTextEmbedding() {
3902-
assumeTrue("TEXT_EMBEDDING function required", EsqlCapabilities.Cap.TEXT_EMBEDDING_FUNCTION.isEnabled());
3903-
39043892
LogicalPlan plan = analyze(
39053893
String.format(Locale.ROOT, """
39063894
from test | where KNN(float_vector, TEXT_EMBEDDING("italian food recipe", "%s"))""", TEXT_EMBEDDING_INFERENCE_ID),

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2735,7 +2735,6 @@ public void testSortInTimeSeries() {
27352735
}
27362736

27372737
public void testTextEmbeddingFunctionInvalidQuery() {
2738-
assumeTrue("TEXT_EMBEDDING is not enabled", EsqlCapabilities.Cap.TEXT_EMBEDDING_FUNCTION.isEnabled());
27392738
assertThat(
27402739
error("from test | EVAL embedding = TEXT_EMBEDDING(null, ?)", defaultAnalyzer, TEXT_EMBEDDING_INFERENCE_ID),
27412740
equalTo("1:30: first argument of [TEXT_EMBEDDING(null, ?)] cannot be null, received [null]")
@@ -2753,7 +2752,6 @@ public void testTextEmbeddingFunctionInvalidQuery() {
27532752
}
27542753

27552754
public void testTextEmbeddingFunctionInvalidInferenceId() {
2756-
assumeTrue("TEXT_EMBEDDING is not enabled", EsqlCapabilities.Cap.TEXT_EMBEDDING_FUNCTION.isEnabled());
27572755
assertThat(
27582756
error("from test | EVAL embedding = TEXT_EMBEDDING(?, null)", defaultAnalyzer, "query text"),
27592757
equalTo("1:30: second argument of [TEXT_EMBEDDING(?, null)] cannot be null, received [null]")

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbeddingErrorTests.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
package org.elasticsearch.xpack.esql.expression.function.inference;
99

10-
import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
1110
import org.elasticsearch.xpack.esql.core.expression.Expression;
1211
import org.elasticsearch.xpack.esql.core.expression.TypeResolutions;
1312
import org.elasticsearch.xpack.esql.core.tree.Source;
@@ -16,7 +15,6 @@
1615
import org.elasticsearch.xpack.esql.expression.function.ErrorsForCasesWithoutExamplesTestCase;
1716
import org.elasticsearch.xpack.esql.expression.function.TestCaseSupplier;
1817
import org.hamcrest.Matcher;
19-
import org.junit.Before;
2018

2119
import java.util.List;
2220
import java.util.Locale;
@@ -28,12 +26,6 @@
2826
* Tests error conditions and type validation for TEXT_EMBEDDING function.
2927
*/
3028
public class TextEmbeddingErrorTests extends ErrorsForCasesWithoutExamplesTestCase {
31-
32-
@Before
33-
public void checkCapability() {
34-
assumeTrue("TEXT_EMBEDDING is not enabled", EsqlCapabilities.Cap.TEXT_EMBEDDING_FUNCTION.isEnabled());
35-
}
36-
3729
@Override
3830
protected List<TestCaseSupplier> cases() {
3931
return paramsToSuppliers(TextEmbeddingTests.parameters());

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbeddingTests.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@
1010
import com.carrotsearch.randomizedtesting.annotations.Name;
1111
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
1212

13-
import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
1413
import org.elasticsearch.xpack.esql.core.expression.Expression;
1514
import org.elasticsearch.xpack.esql.core.tree.Source;
1615
import org.elasticsearch.xpack.esql.expression.function.AbstractFunctionTestCase;
1716
import org.elasticsearch.xpack.esql.expression.function.FunctionName;
1817
import org.elasticsearch.xpack.esql.expression.function.TestCaseSupplier;
1918
import org.hamcrest.Matchers;
20-
import org.junit.Before;
2119

2220
import java.util.List;
2321
import java.util.function.Supplier;
@@ -28,11 +26,6 @@
2826

2927
@FunctionName("text_embedding")
3028
public class TextEmbeddingTests extends AbstractFunctionTestCase {
31-
@Before
32-
public void checkCapability() {
33-
assumeTrue("TEXT_EMBEDDING is not enabled", EsqlCapabilities.Cap.TEXT_EMBEDDING_FUNCTION.isEnabled());
34-
}
35-
3629
public TextEmbeddingTests(@Name("TestCase") Supplier<TestCaseSupplier.TestCase> testCaseSupplier) {
3730
this.testCase = testCaseSupplier.get();
3831
}

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

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.elasticsearch.threadpool.TestThreadPool;
2424
import org.elasticsearch.threadpool.ThreadPool;
2525
import org.elasticsearch.xpack.core.inference.action.GetInferenceModelAction;
26-
import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
2726
import org.elasticsearch.xpack.esql.expression.function.EsqlFunctionRegistry;
2827
import org.elasticsearch.xpack.esql.parser.EsqlParser;
2928
import org.junit.After;
@@ -84,25 +83,23 @@ public void testCollectInferenceIds() {
8483
List.of("completion-inference-id")
8584
);
8685

87-
if (EsqlCapabilities.Cap.TEXT_EMBEDDING_FUNCTION.isEnabled()) {
88-
// Text embedding inference plan
89-
assertCollectInferenceIds(
90-
"FROM books METADATA _score | EVAL embedding = TEXT_EMBEDDING(\"description\", \"text-embedding-inference-id\")",
91-
List.of("text-embedding-inference-id")
92-
);
86+
// Text embedding function
87+
assertCollectInferenceIds(
88+
"FROM books METADATA _score | EVAL embedding = TEXT_EMBEDDING(\"description\", \"text-embedding-inference-id\")",
89+
List.of("text-embedding-inference-id")
90+
);
9391

94-
// Test inference ID collection from an inference function
95-
assertCollectInferenceIds(
96-
"FROM books METADATA _score | EVAL embedding = TEXT_EMBEDDING(\"description\", \"text-embedding-inference-id\")",
97-
List.of("text-embedding-inference-id")
98-
);
92+
// Test inference ID collection from an inference function
93+
assertCollectInferenceIds(
94+
"FROM books METADATA _score | EVAL embedding = TEXT_EMBEDDING(\"description\", \"text-embedding-inference-id\")",
95+
List.of("text-embedding-inference-id")
96+
);
9997

100-
// Test inference ID collection with nested functions
101-
assertCollectInferenceIds(
102-
"FROM books METADATA _score | EVAL embedding = TEXT_EMBEDDING(TEXT_EMBEDDING(\"nested\", \"nested-id\"), \"outer-id\")",
103-
List.of("nested-id", "outer-id")
104-
);
105-
}
98+
// Test inference ID collection with nested functions
99+
assertCollectInferenceIds(
100+
"FROM books METADATA _score | EVAL embedding = TEXT_EMBEDDING(TEXT_EMBEDDING(\"nested\", \"nested-id\"), \"outer-id\")",
101+
List.of("nested-id", "outer-id")
102+
);
106103

107104
// Multiple inference plans
108105
assertCollectInferenceIds("""

0 commit comments

Comments
 (0)