From 64473198c3cdf890050155994febb7d163b4493b Mon Sep 17 00:00:00 2001
From: Gal Lalouche
Date: Tue, 28 Jan 2025 12:11:37 +0200
Subject: [PATCH 1/8] Multivalue error tests
---
.../MvPSeriesWeightedSumErrorTests.java | 37 +++++++++++++++++++
.../multivalue/MvPSeriesWeightedSumTests.java | 5 +--
.../multivalue/MvPercentileErrorTests.java | 37 +++++++++++++++++++
.../scalar/multivalue/MvPercentileTests.java | 5 +--
.../scalar/multivalue/MvSumErrorTests.java | 37 +++++++++++++++++++
.../scalar/multivalue/MvSumTests.java | 2 +-
6 files changed, 116 insertions(+), 7 deletions(-)
create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPSeriesWeightedSumErrorTests.java
create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPercentileErrorTests.java
create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSumErrorTests.java
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPSeriesWeightedSumErrorTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPSeriesWeightedSumErrorTests.java
new file mode 100644
index 0000000000000..4f1f8f911c306
--- /dev/null
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPSeriesWeightedSumErrorTests.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+package org.elasticsearch.xpack.esql.expression.function.scalar.multivalue;
+
+import org.elasticsearch.xpack.esql.core.expression.Expression;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+import org.elasticsearch.xpack.esql.core.type.DataType;
+import org.elasticsearch.xpack.esql.expression.function.ErrorsForCasesWithoutExamplesTestCase;
+import org.elasticsearch.xpack.esql.expression.function.TestCaseSupplier;
+import org.hamcrest.Matcher;
+
+import java.util.List;
+import java.util.Set;
+
+import static org.hamcrest.Matchers.equalTo;
+
+public class MvPSeriesWeightedSumErrorTests extends ErrorsForCasesWithoutExamplesTestCase {
+ @Override
+ protected List cases() {
+ return paramsToSuppliers(MvPSeriesWeightedSumTests.parameters());
+ }
+
+ @Override
+ protected Expression build(Source source, List args) {
+ return new MvPSeriesWeightedSum(source, args.get(0), args.get(1));
+ }
+
+ @Override
+ protected Matcher expectedTypeErrorMatcher(List> validPerPosition, List signature) {
+ return equalTo(typeErrorMessage(true, validPerPosition, signature, (v, p) -> "double"));
+ }
+}
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPSeriesWeightedSumTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPSeriesWeightedSumTests.java
index 0c905b28ac931..47669cba71894 100644
--- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPSeriesWeightedSumTests.java
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPSeriesWeightedSumTests.java
@@ -35,7 +35,7 @@ public static Iterable
*/
- protected static Iterable parameterSuppliersFromTypedDataWithDefaultChecks(
+ protected static Iterable parameterSuppliersFromTypedDataWithDefaultChecksNoErrors(
List suppliers,
boolean entirelyNullPreservesType,
PositionalErrorMessageSupplier positionalErrorMessageSupplier
@@ -91,13 +91,7 @@ protected static Iterable parameterSuppliersFromTypedDataWithDefaultCh
return parameterSuppliersFromTypedData(anyNullIsNull(entirelyNullPreservesType, randomizeBytesRefsOffset(suppliers)));
}
- // TODO: Remove and migrate everything to the method with all the parameters
- /**
- * @deprecated Use {@link #parameterSuppliersFromTypedDataWithDefaultChecks(List, boolean, PositionalErrorMessageSupplier)} instead.
- * This method doesn't add all the default checks.
- */
- @Deprecated
- protected static Iterable parameterSuppliersFromTypedDataWithDefaultChecks(List suppliers) {
+ protected static Iterable parameterSuppliersFromTypedDataWithDefaultChecksNoErrors(List suppliers) {
return parameterSuppliersFromTypedData(withNoRowsExpectingNull(randomizeBytesRefsOffset(suppliers)));
}
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SumTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SumTests.java
index 4f14dafc8b30d..6730c2591ebbf 100644
--- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SumTests.java
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SumTests.java
@@ -77,7 +77,7 @@ public static Iterable parameters() {
)
);
- return parameterSuppliersFromTypedDataWithDefaultChecks(suppliers);
+ return parameterSuppliersFromTypedDataWithDefaultChecksNoErrors(suppliers);
}
@Override
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/TopTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/TopTests.java
index f236e4d8faf98..1d18d66110fe0 100644
--- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/TopTests.java
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/TopTests.java
@@ -280,7 +280,7 @@ public static Iterable parameters() {
)
);
- return parameterSuppliersFromTypedDataWithDefaultChecks(suppliers);
+ return parameterSuppliersFromTypedDataWithDefaultChecksNoErrors(suppliers);
}
@Override
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/WeightedAvgTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/WeightedAvgTests.java
index 2c2ffc97f268c..1ad6cdf4c2494 100644
--- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/WeightedAvgTests.java
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/WeightedAvgTests.java
@@ -90,7 +90,7 @@ public static Iterable parameters() {
)
);
- return parameterSuppliersFromTypedDataWithDefaultChecks(suppliers);
+ return parameterSuppliersFromTypedDataWithDefaultChecksNoErrors(suppliers);
}
@Override
From 1bf698f2a041883fd8d555e6fdafcacf162a3b0c Mon Sep 17 00:00:00 2001
From: elasticsearchmachine
Date: Thu, 30 Jan 2025 18:56:10 +0000
Subject: [PATCH 8/8] [CI] Auto commit changes from spotless
---
.../expression/function/scalar/spatial/StXErrorTests.java | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StXErrorTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StXErrorTests.java
index 4e230b40a8d51..77e85ea9c1882 100644
--- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StXErrorTests.java
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StXErrorTests.java
@@ -32,8 +32,6 @@ protected Expression build(Source source, List args) {
@Override
protected Matcher expectedTypeErrorMatcher(List> validPerPosition, List signature) {
- return equalTo(
- typeErrorMessage(false, validPerPosition, signature, (v, p) -> "geo_point or cartesian_point")
- );
+ return equalTo(typeErrorMessage(false, validPerPosition, signature, (v, p) -> "geo_point or cartesian_point"));
}
}