From a707bec1cec71ebfc9045bf314a8a2a64cb0441b Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Tue, 5 Aug 2025 17:07:27 +0200 Subject: [PATCH 01/38] Make equals include ids for Alias, TypedAttribute --- .../elasticsearch/xpack/esql/core/expression/Alias.java | 7 +++++++ .../xpack/esql/core/expression/TypedAttribute.java | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Alias.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Alias.java index f0340f570c8b7..6a2ba0992422c 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Alias.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Alias.java @@ -17,6 +17,7 @@ import java.io.IOException; import java.util.List; +import java.util.Objects; import static java.util.Collections.singletonList; @@ -147,4 +148,10 @@ public String nodeString() { public static Expression unwrap(Expression e) { return e instanceof Alias as ? as.child() : e; } + + @Override + protected boolean innerEquals(Object o) { + var other = (Alias) o; + return super.innerEquals(other) && Objects.equals(id(), other.id()); + } } diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypedAttribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypedAttribute.java index e7e40c7aacf1e..6580467309285 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypedAttribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypedAttribute.java @@ -54,6 +54,6 @@ public int hashCode() { @Override protected boolean innerEquals(Object o) { var other = (TypedAttribute) o; - return super.innerEquals(other) && dataType == other.dataType; + return super.innerEquals(other) && Objects.equals(id(), other.id()) && dataType == other.dataType; } } From 204859817dea9daf55c8b34d784c6efd42e1b97f Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Mon, 15 Sep 2025 14:05:41 +0200 Subject: [PATCH 02/38] Add test case for circular renames --- .../src/main/resources/rename.csv-spec | 14 ++++++++++++++ .../xpack/esql/action/EsqlCapabilities.java | 7 ++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/rename.csv-spec b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/rename.csv-spec index f485e39233982..936723536099a 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/rename.csv-spec +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/rename.csv-spec @@ -343,3 +343,17 @@ ROW a="keyword", b=5, c=null a:integer 5 ; + +circularRename +required_capability: attribute_equals_respects_name_id + +FROM employees +| EVAL y = emp_no - 10000 +| RENAME y as z, z as y +| WHERE y*y == 1 +| KEEP emp_no, y +; + +emp_no:integer | y:integer +10001 | 1 +; diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java index 652bbbb07652d..aa809910b698d 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java @@ -1494,7 +1494,12 @@ public enum Cap { /** * Support absent_over_time aggregation that gets evaluated per time-series */ - ABSENT_OVER_TIME(Build.current().isSnapshot()); + ABSENT_OVER_TIME(Build.current().isSnapshot()), + + /** + * Fix attribute equality to respect the name id of the attribute. + */ + ATTRIBUTE_EQUALS_RESPECTS_NAME_ID; private final boolean enabled; From d0a994f886cdd6c7996bb8cf493c3e58fc2a3d24 Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Mon, 15 Sep 2025 14:28:35 +0200 Subject: [PATCH 03/38] Add tests for ENRICH/LOOKUP JOIN + VALUES agg --- .../src/main/resources/enrich.csv-spec | 18 ++++++++++++++++++ .../src/main/resources/lookup-join.csv-spec | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/enrich.csv-spec b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/enrich.csv-spec index c263ce4326865..37af74c1df8e7 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/enrich.csv-spec +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/enrich.csv-spec @@ -762,3 +762,21 @@ FROM sample_data message:keyword | language_code:keyword | first_language_name:keyword | language_name:keyword Connected to 10.1.0.1 | 1 | English | English ; + +enrichOnSameFieldTwiceValues +required_capability: enrich_load +required_capability: attribute_equals_respects_name_id + +ROW a = 1, b = 2 +| EVAL language_code = a +| ENRICH languages_policy ON language_code +| RENAME language_name AS language_name_a +| EVAL language_code = b +| ENRICH languages_policy ON language_code +| RENAME language_name AS language_name_b +| STATS values(language_name_a), values(language_name_b) +; + +values(language_name_a):keyword | values(language_name_b):keyword +English | French +; diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/lookup-join.csv-spec b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/lookup-join.csv-spec index 2aa88f47a0a96..014a1e64120af 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/lookup-join.csv-spec +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/lookup-join.csv-spec @@ -1875,6 +1875,24 @@ type:keyword | language_code:integer | language_name:keyword Production | 3 | Spanish ; +lookupJoinOnSameFieldTwiceValues +required_capability: join_lookup_v12 +required_capability: attribute_equals_respects_name_id + +ROW a = 1, b = 2 +| EVAL language_code = a +| LOOKUP JOIN languages_lookup ON language_code +| RENAME language_name AS language_name_a +| EVAL language_code = b +| LOOKUP JOIN languages_lookup ON language_code +| RENAME language_name AS language_name_b +| STATS values(language_name_a), values(language_name_b) +; + +values(language_name_a):keyword | values(language_name_b):keyword +English | French +; + ############################################### # LOOKUP JOIN on mixed numerical fields ############################################### From d34572ab4a1e63f6ccc42670b94abc07976d8af4 Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Mon, 15 Sep 2025 14:50:25 +0200 Subject: [PATCH 04/38] Use id in hashCode for Alias, TypedAttribute --- .../xpack/esql/core/expression/Alias.java | 10 ++++++++++ .../xpack/esql/core/expression/EmptyAttribute.java | 3 ++- .../xpack/esql/core/expression/NamedExpression.java | 3 +++ .../xpack/esql/core/expression/TypedAttribute.java | 10 +++++++++- .../esql/core/expression/UnresolvedAttribute.java | 4 ++++ 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Alias.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Alias.java index 6a2ba0992422c..56f4a68656b8d 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Alias.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Alias.java @@ -149,6 +149,16 @@ public static Expression unwrap(Expression e) { return e instanceof Alias as ? as.child() : e; } + @Override + @SuppressWarnings("checkstyle:EqualsHashCode")// equals is implemented in parent. See innerEquals instead + public int hashCode() { + return Objects.hash(super.hashCode(), id()); + } + + /** + * Compared to e.g. {@link UnresolvedAttribute}, the id is part of equality for Alias because the {@link ReferenceAttribute} created + * by {@link #toAttribute()} uses it. + */ @Override protected boolean innerEquals(Object o) { var other = (Alias) o; diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/EmptyAttribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/EmptyAttribute.java index 05fc864983d27..f041870f9cfd7 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/EmptyAttribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/EmptyAttribute.java @@ -17,9 +17,10 @@ /** * Marker for optional attributes. Acting as a dummy placeholder to avoid using null - * in the tree (which is not allowed). + * in the tree (which is not allowed). All empty attributes are considered equal. */ public class EmptyAttribute extends Attribute { + // TODO: Could be a singleton - all instances are already considered equal. public EmptyAttribute(Source source) { super(source, StringUtils.EMPTY, null); } diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/NamedExpression.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/NamedExpression.java index 1746b6308160c..22e40981ddd59 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/NamedExpression.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/NamedExpression.java @@ -27,6 +27,9 @@ public NamedExpression(Source source, String name, List children, @N this(source, name, children, id, false); } + /** + * Assigns a new id if null is passed for {@code id}. + */ public NamedExpression(Source source, String name, List children, @Nullable NameId id, boolean synthetic) { super(source, children); this.name = name; diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypedAttribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypedAttribute.java index 6580467309285..6bfed5c728c40 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypedAttribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypedAttribute.java @@ -12,6 +12,11 @@ import java.util.Objects; +/** + * A resolved attribute - we know its type. + * Because the name alone is not sufficient to identify an attribute (two different relations can have the same attribute name), + * we also have an id that, when present, is used in equality checks and hashing. + */ public abstract class TypedAttribute extends Attribute { private final DataType dataType; @@ -48,9 +53,12 @@ public DataType dataType() { @Override @SuppressWarnings("checkstyle:EqualsHashCode")// equals is implemented in parent. See innerEquals instead public int hashCode() { - return Objects.hash(super.hashCode(), dataType); + return Objects.hash(super.hashCode(), id(), dataType); } + /** + * After resolution, the name id uniquely identifies an attribute, so it is included in equality check. + */ @Override protected boolean innerEquals(Object o) { var other = (TypedAttribute) o; diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedAttribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedAttribute.java index 5a31bd31d9189..9927759f78273 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedAttribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedAttribute.java @@ -178,6 +178,10 @@ public int hashCode() { return Objects.hash(super.hashCode(), resolutionMetadata, unresolvedMsg); } + /** + * We ignore the {@link #id()} in equality checks because unresolved attributes are not yet referring to a specific upstream field or + * attribute. + */ @Override protected boolean innerEquals(Object o) { var other = (UnresolvedAttribute) o; From 3e8e9193d3c30ec463b954a6dbaad9427aeaba09 Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Mon, 15 Sep 2025 15:11:47 +0200 Subject: [PATCH 05/38] Fix comment --- .../xpack/esql/core/expression/TypedAttribute.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypedAttribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypedAttribute.java index 6bfed5c728c40..8add1a26829f2 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypedAttribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypedAttribute.java @@ -15,7 +15,7 @@ /** * A resolved attribute - we know its type. * Because the name alone is not sufficient to identify an attribute (two different relations can have the same attribute name), - * we also have an id that, when present, is used in equality checks and hashing. + * we also have an id that is used in equality checks and hashing. */ public abstract class TypedAttribute extends Attribute { From a2bb5e98703cc030e573b81ed54a5c091b0a6390 Mon Sep 17 00:00:00 2001 From: elasticsearchmachine Date: Mon, 15 Sep 2025 16:07:37 +0000 Subject: [PATCH 06/38] [CI] Update transport version definitions --- server/src/main/resources/transport/upper_bounds/9.2.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/resources/transport/upper_bounds/9.2.csv b/server/src/main/resources/transport/upper_bounds/9.2.csv index 49360d5e62d69..e24f914a1d1ca 100644 --- a/server/src/main/resources/transport/upper_bounds/9.2.csv +++ b/server/src/main/resources/transport/upper_bounds/9.2.csv @@ -1 +1 @@ -inference_api_eis_diagnostics,9156000 +ml_inference_endpoint_cache,9157000 From a191f30f62c60f8a80e28b6a84cf81ebe2fd3f16 Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Wed, 17 Sep 2025 10:59:22 +0200 Subject: [PATCH 07/38] Make Attribute#equals generally respect the id Except EmptyAttribute --- .../xpack/esql/core/expression/Attribute.java | 8 ++++++-- .../xpack/esql/core/expression/Expression.java | 9 +++++++++ .../esql/core/expression/TypedAttribute.java | 12 ++++-------- .../core/expression/UnresolvedAttribute.java | 18 ++++++++---------- .../esql/core/expression/UnresolvedStar.java | 2 +- 5 files changed, 28 insertions(+), 21 deletions(-) diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java index b7af6041ea56a..aa043aa0a92ee 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java @@ -163,13 +163,17 @@ protected Expression canonicalize() { @Override @SuppressWarnings("checkstyle:EqualsHashCode")// equals is implemented in parent. See innerEquals instead public int hashCode() { - return Objects.hash(super.hashCode(), qualifier, nullability); + return Objects.hash(super.hashCode(), id(), qualifier, nullability); } + /** + * Because the name alone is not sufficient to identify an attribute (two different relations can have the same attribute name), + * we also have an id that is used in equality checks and hashing. + */ @Override protected boolean innerEquals(Object o) { var other = (Attribute) o; - return super.innerEquals(other) && Objects.equals(qualifier, other.qualifier) && Objects.equals(nullability, other.nullability); + return Objects.equals(id(), other.id()) && super.innerEquals(other) && Objects.equals(qualifier, other.qualifier) && Objects.equals(nullability, other.nullability); } @Override diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Expression.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Expression.java index 62c3adafb8fff..68438a95f7dda 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Expression.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Expression.java @@ -180,10 +180,19 @@ protected Expression canonicalize() { return replaceChildrenSameSize(canonicalChildren); } + /** + * Whether this expression means the same as {@code other}, even if they are not exactly equal. + * For example, {@code a + b} and {@code b + a} are not equal, but they are semantically equivalent. + *

+ * If two expressions are equal, they are also semantically equal, but the reverse is not true. + */ public boolean semanticEquals(Expression other) { return canonical().equals(other.canonical()); } + /** + * A hash code that is consistent with {@link #semanticEquals}. + */ public int semanticHash() { return canonical().hashCode(); } diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypedAttribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypedAttribute.java index 8add1a26829f2..c054b32b9fecc 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypedAttribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypedAttribute.java @@ -13,9 +13,8 @@ import java.util.Objects; /** - * A resolved attribute - we know its type. - * Because the name alone is not sufficient to identify an attribute (two different relations can have the same attribute name), - * we also have an id that is used in equality checks and hashing. + * A fully resolved attribute - we know its type. For example, if it references data directly from Lucene, this will be a + * {@link FieldAttribute}. If it references the results of another calculation it will be {@link ReferenceAttribute}s. */ public abstract class TypedAttribute extends Attribute { @@ -53,15 +52,12 @@ public DataType dataType() { @Override @SuppressWarnings("checkstyle:EqualsHashCode")// equals is implemented in parent. See innerEquals instead public int hashCode() { - return Objects.hash(super.hashCode(), id(), dataType); + return Objects.hash(super.hashCode(), dataType); } - /** - * After resolution, the name id uniquely identifies an attribute, so it is included in equality check. - */ @Override protected boolean innerEquals(Object o) { var other = (TypedAttribute) o; - return super.innerEquals(other) && Objects.equals(id(), other.id()) && dataType == other.dataType; + return super.innerEquals(other) && dataType == other.dataType; } } diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedAttribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedAttribute.java index 9927759f78273..0132329cfe5a8 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedAttribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedAttribute.java @@ -20,18 +20,14 @@ import java.util.Objects; /** - * An unresolved attribute. We build these while walking the syntax - * tree and then resolve them into other {@link Attribute} subclasses during - * analysis. - *

- * For example, if they reference the data directly from lucene they'll be - * {@link FieldAttribute}s. If they reference the results of another calculation - * they will be {@link ReferenceAttribute}s. - *

+ * An unresolved attribute. We build these while walking the syntax tree and then resolve them into other {@link Attribute} subclasses + * during analysis. {@link Alias}es whose types are not yet resolved also return {@link UnresolvedAttribute}s when calling + * {@link Alias#toAttribute()}. */ public class UnresolvedAttribute extends Attribute implements Unresolvable { private final boolean customMessage; private final String unresolvedMsg; + // TODO: unused and always null, remove this. private final Object resolutionMetadata; // TODO: Check usage of constructors without qualifiers, that's likely where qualifiers need to be plugged into resolution logic. @@ -179,8 +175,10 @@ public int hashCode() { } /** - * We ignore the {@link #id()} in equality checks because unresolved attributes are not yet referring to a specific upstream field or - * attribute. + * Note that the {@link #id()} is respected here. Two unresolved attributes with the same name but different + * {@link NameId} can occur e.g. when resolving {@code EVAL x = 2*x, y = 3*x}. In the first expression, {@code x} is referring to an + * upstream attribute, while in the second expression it is referring to the alias defined in the first expression. This allows us to + * distinguish the attributes generated by the {@code EVAL} from attributes referenced by it. */ @Override protected boolean innerEquals(Object o) { diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedStar.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedStar.java index 2508702a87156..eedb2231ca33c 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedStar.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedStar.java @@ -19,7 +19,7 @@ public class UnresolvedStar extends UnresolvedNamedExpression { - // typically used for nested fields or inner/dotted fields + // TODO: Currently unused, but likely will be again when we support qualified star resolution private final UnresolvedAttribute qualifier; public UnresolvedStar(Source source, UnresolvedAttribute qualifier) { From 41a60d36768b41338fd9b11f533577d693e5167d Mon Sep 17 00:00:00 2001 From: elasticsearchmachine Date: Wed, 17 Sep 2025 09:08:22 +0000 Subject: [PATCH 08/38] [CI] Auto commit changes from spotless --- .../elasticsearch/xpack/esql/core/expression/Attribute.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java index aa043aa0a92ee..de42c6739a2e1 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java @@ -173,7 +173,10 @@ public int hashCode() { @Override protected boolean innerEquals(Object o) { var other = (Attribute) o; - return Objects.equals(id(), other.id()) && super.innerEquals(other) && Objects.equals(qualifier, other.qualifier) && Objects.equals(nullability, other.nullability); + return Objects.equals(id(), other.id()) + && super.innerEquals(other) + && Objects.equals(qualifier, other.qualifier) + && Objects.equals(nullability, other.nullability); } @Override From c67035c8de9a805030614dd0e0ef4d2e51991757 Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Wed, 17 Sep 2025 11:35:52 +0200 Subject: [PATCH 09/38] Introduce non-semantic equality for attributes --- .../xpack/esql/core/expression/Attribute.java | 24 ++++++++++++++----- .../esql/core/expression/EmptyAttribute.java | 15 +++++++++--- .../esql/core/expression/FieldAttribute.java | 9 ++++--- .../core/expression/MetadataAttribute.java | 9 ++++--- .../esql/core/expression/TypedAttribute.java | 9 ++++--- .../core/expression/UnresolvedAttribute.java | 9 ++++--- .../function/UnsupportedAttribute.java | 9 ++++--- 7 files changed, 50 insertions(+), 34 deletions(-) diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java index de42c6739a2e1..28bace0b9319e 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java @@ -152,7 +152,7 @@ public int semanticHash() { @Override public boolean semanticEquals(Expression other) { - return other instanceof Attribute ? id().equals(((Attribute) other).id()) : false; + return other instanceof Attribute otherAttr && id().equals(otherAttr.id()); } @Override @@ -160,10 +160,25 @@ protected Expression canonicalize() { return clone(Source.EMPTY, qualifier(), name(), dataType(), nullability, id(), synthetic()); } + /** + * Compares all fields except the id. Useful when looking for attributes that are the same except for their origin, or when we create + * new attributes based on existing ones and want to avoid duplicates. + */ + protected boolean nonSemanticEquals(Attribute other) { + return super.innerEquals(other) && Objects.equals(qualifier, other.qualifier) && Objects.equals(nullability, other.nullability); + } + + /** + * Hashcode that's consistent with {@link #nonSemanticEquals(Attribute)}. + */ + protected int nonSemanticHashCode() { + return Objects.hash(super.hashCode(), qualifier, nullability); + } + @Override @SuppressWarnings("checkstyle:EqualsHashCode")// equals is implemented in parent. See innerEquals instead public int hashCode() { - return Objects.hash(super.hashCode(), id(), qualifier, nullability); + return Objects.hash(super.hashCode(), id(), nonSemanticHashCode()); } /** @@ -173,10 +188,7 @@ public int hashCode() { @Override protected boolean innerEquals(Object o) { var other = (Attribute) o; - return Objects.equals(id(), other.id()) - && super.innerEquals(other) - && Objects.equals(qualifier, other.qualifier) - && Objects.equals(nullability, other.nullability); + return semanticEquals(other) && nonSemanticEquals(other); } @Override diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/EmptyAttribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/EmptyAttribute.java index f041870f9cfd7..fd9bc66dac138 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/EmptyAttribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/EmptyAttribute.java @@ -79,13 +79,22 @@ protected NodeInfo info() { } @Override - @SuppressWarnings("checkstyle:EqualsHashCode")// equals is implemented in parent. See innerEquals instead - public int hashCode() { + public int nonSemanticHashCode() { return EmptyAttribute.class.hashCode(); } @Override - protected boolean innerEquals(Object o) { + protected boolean nonSemanticEquals(Attribute o) { return true; } + + @Override + public int semanticHash() { + return EmptyAttribute.class.hashCode(); + } + + @Override + public boolean semanticEquals(Expression other) { + return other instanceof EmptyAttribute; + } } diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/FieldAttribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/FieldAttribute.java index 6b3d0ff07a9e7..58d6e4ec50e4e 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/FieldAttribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/FieldAttribute.java @@ -231,15 +231,14 @@ public Attribute withDataType(DataType type) { } @Override - @SuppressWarnings("checkstyle:EqualsHashCode")// equals is implemented in parent. See innerEquals instead - public int hashCode() { - return Objects.hash(super.hashCode(), parentName, field); + public int nonSemanticHashCode() { + return Objects.hash(super.nonSemanticHashCode(), parentName, field); } @Override - protected boolean innerEquals(Object o) { + protected boolean nonSemanticEquals(Attribute o) { var other = (FieldAttribute) o; - return super.innerEquals(other) && Objects.equals(parentName, other.parentName) && Objects.equals(field, other.field); + return super.nonSemanticEquals(other) && Objects.equals(parentName, other.parentName) && Objects.equals(field, other.field); } @Override diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/MetadataAttribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/MetadataAttribute.java index 24daf3e66e220..e608b128878f1 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/MetadataAttribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/MetadataAttribute.java @@ -169,14 +169,13 @@ public static boolean isScoreAttribute(Expression a) { } @Override - @SuppressWarnings("checkstyle:EqualsHashCode")// equals is implemented in parent. See innerEquals instead - public int hashCode() { - return Objects.hash(super.hashCode(), searchable); + public int nonSemanticHashCode() { + return Objects.hash(super.nonSemanticHashCode(), searchable); } @Override - protected boolean innerEquals(Object o) { + protected boolean nonSemanticEquals(Attribute o) { var other = (MetadataAttribute) o; - return super.innerEquals(other) && searchable == other.searchable; + return super.nonSemanticEquals(other) && searchable == other.searchable; } } diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypedAttribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypedAttribute.java index c054b32b9fecc..f7d035077d099 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypedAttribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypedAttribute.java @@ -50,14 +50,13 @@ public DataType dataType() { } @Override - @SuppressWarnings("checkstyle:EqualsHashCode")// equals is implemented in parent. See innerEquals instead - public int hashCode() { - return Objects.hash(super.hashCode(), dataType); + public int nonSemanticHashCode() { + return Objects.hash(super.nonSemanticHashCode(), dataType); } @Override - protected boolean innerEquals(Object o) { + protected boolean nonSemanticEquals(Attribute o) { var other = (TypedAttribute) o; - return super.innerEquals(other) && dataType == other.dataType; + return super.nonSemanticEquals(other) && dataType == other.dataType; } } diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedAttribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedAttribute.java index 0132329cfe5a8..9a4c97e915a67 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedAttribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedAttribute.java @@ -169,9 +169,8 @@ public static String errorMessage(String name, List potentialMatches) { } @Override - @SuppressWarnings("checkstyle:EqualsHashCode")// equals is implemented in parent. See innerEquals instead - public int hashCode() { - return Objects.hash(super.hashCode(), resolutionMetadata, unresolvedMsg); + public int nonSemanticHashCode() { + return Objects.hash(super.nonSemanticHashCode(), resolutionMetadata, unresolvedMsg); } /** @@ -181,9 +180,9 @@ public int hashCode() { * distinguish the attributes generated by the {@code EVAL} from attributes referenced by it. */ @Override - protected boolean innerEquals(Object o) { + protected boolean nonSemanticEquals(Attribute o) { var other = (UnresolvedAttribute) o; - return super.innerEquals(other) + return super.nonSemanticEquals(other) && Objects.equals(resolutionMetadata, other.resolutionMetadata) && Objects.equals(unresolvedMsg, other.unresolvedMsg); } diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttribute.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttribute.java index df57609bbd802..f5b9950557ba8 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttribute.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttribute.java @@ -188,15 +188,14 @@ public boolean hasCustomMessage() { } @Override - @SuppressWarnings("checkstyle:EqualsHashCode")// equals is implemented in parent. See innerEquals instead - public int hashCode() { - return Objects.hash(super.hashCode(), hasCustomMessage, message); + public int nonSemanticHashCode() { + return Objects.hash(super.nonSemanticHashCode(), hasCustomMessage, message); } @Override - protected boolean innerEquals(Object o) { + protected boolean nonSemanticEquals(Attribute o) { var other = (UnsupportedAttribute) o; - return super.innerEquals(other) && hasCustomMessage == other.hasCustomMessage && Objects.equals(message, other.message); + return super.nonSemanticEquals(other) && hasCustomMessage == other.hasCustomMessage && Objects.equals(message, other.message); } /** From eb07eb6b09dec4a8caffeb2497abf179f099c58d Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Wed, 17 Sep 2025 12:55:02 +0200 Subject: [PATCH 10/38] Fix union type resolution --- .../xpack/esql/core/expression/Alias.java | 2 +- .../xpack/esql/core/expression/Attribute.java | 58 ++++++++++++++++++- .../xpack/esql/analysis/Analyzer.java | 20 ++++--- 3 files changed, 69 insertions(+), 11 deletions(-) diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Alias.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Alias.java index 56f4a68656b8d..a3ab13621041f 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Alias.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Alias.java @@ -162,6 +162,6 @@ public int hashCode() { @Override protected boolean innerEquals(Object o) { var other = (Alias) o; - return super.innerEquals(other) && Objects.equals(id(), other.id()); + return Objects.equals(id(), other.id()) && super.innerEquals(other); } } diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java index 28bace0b9319e..03fd466092173 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java @@ -32,6 +32,55 @@ * The rest are not as they are not part of the projection and thus are not part of the derived table. */ public abstract class Attribute extends NamedExpression { + /** + * A wrapper class where equality of the contained attribute ignores the {@link Attribute#id()}. Useful when we want to create new + * attributes and want to avoid duplicates - we can create a set of {@link NonSemanticAttribute}s. + */ + public class NonSemanticAttribute { + private Attribute attribute; + + public NonSemanticAttribute(Attribute attribute) { + if (attribute == null) { + throw new IllegalStateException("Attribute inside NonSemanticAttribute cannot be null"); + } + this.attribute = attribute; + } + + public Attribute get() { + return attribute; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + Attribute otherAttribute = ((NonSemanticAttribute) o).attribute; + + if (attribute == otherAttribute) { + return true; + } + if (otherAttribute == null || attribute.getClass() != otherAttribute.getClass()) { + return false; + } + + return attribute.nonSemanticEquals(otherAttribute); + } + + @Override + public int hashCode() { + return attribute.nonSemanticHashCode(); + } + } + + public NonSemanticAttribute ignoreId() { + return new NonSemanticAttribute(this); + } + /** * Changing this will break bwc with 8.15, see {@link FieldAttribute#fieldName()}. */ @@ -163,18 +212,23 @@ protected Expression canonicalize() { /** * Compares all fields except the id. Useful when looking for attributes that are the same except for their origin, or when we create * new attributes based on existing ones and want to avoid duplicates. + *

+ * Does not perform the usual instance and class equality checks, those are already done in {@link NamedExpression#equals(Object)} */ protected boolean nonSemanticEquals(Attribute other) { return super.innerEquals(other) && Objects.equals(qualifier, other.qualifier) && Objects.equals(nullability, other.nullability); } /** - * Hashcode that's consistent with {@link #nonSemanticEquals(Attribute)}. + * Hashcode that's consistent with {@link #nonSemanticEquals(Attribute)}. Hashes everything but the id. */ protected int nonSemanticHashCode() { return Objects.hash(super.hashCode(), qualifier, nullability); } + /** + * Inheritors should generally only override {@link #nonSemanticHashCode()}. + */ @Override @SuppressWarnings("checkstyle:EqualsHashCode")// equals is implemented in parent. See innerEquals instead public int hashCode() { @@ -184,6 +238,8 @@ public int hashCode() { /** * Because the name alone is not sufficient to identify an attribute (two different relations can have the same attribute name), * we also have an id that is used in equality checks and hashing. + *

+ * Inheritors should generally only override {@link #nonSemanticEquals(Attribute)}. */ @Override protected boolean innerEquals(Object o) { diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Analyzer.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Analyzer.java index 88ee8dab97aaa..a0567a07482cb 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Analyzer.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Analyzer.java @@ -1734,7 +1734,7 @@ private static class ResolveUnionTypes extends Rule { record TypeResolutionKey(String fieldName, DataType fieldType) {} - private List unionFieldAttributes; + private List unionFieldAttributes; @Override public LogicalPlan apply(LogicalPlan plan) { @@ -1749,7 +1749,7 @@ private LogicalPlan doRule(LogicalPlan plan) { unionFieldAttributes.clear(); for (Attribute attr : rel.output()) { if (attr instanceof FieldAttribute fa && fa.field() instanceof MultiTypeEsField && fa.synthetic()) { - unionFieldAttributes.add(fa); + unionFieldAttributes.add(fa.ignoreId()); } } } @@ -1768,7 +1768,7 @@ private LogicalPlan doRule(LogicalPlan plan) { return plan; } - return addGeneratedFieldsToEsRelations(plan, unionFieldAttributes); + return addGeneratedFieldsToEsRelations(plan, unionFieldAttributes.stream().map(attr -> (FieldAttribute) attr.get()).toList()); } /** @@ -1798,7 +1798,7 @@ private static LogicalPlan addGeneratedFieldsToEsRelations(LogicalPlan plan, Lis }); } - private Expression resolveConvertFunction(ConvertFunction convert, List unionFieldAttributes) { + private Expression resolveConvertFunction(ConvertFunction convert, List unionFieldAttributes) { Expression convertExpression = (Expression) convert; if (convert.field() instanceof FieldAttribute fa && fa.field() instanceof InvalidMappedField imf) { HashMap typeResolutions = new HashMap<>(); @@ -1869,7 +1869,7 @@ private Expression resolveConvertFunction(ConvertFunction convert, List unionFieldAttributes + List unionFieldAttributes ) { // Generate new ID for the field and suffix it with the data type to maintain unique attribute names. // NOTE: The name has to start with $$ to not break bwc with 8.15 - in that version, this is how we had to mark this as @@ -1883,13 +1883,15 @@ private Expression createIfDoesNotAlreadyExist( resolvedField, true ); - int existingIndex = unionFieldAttributes.indexOf(unionFieldAttribute); + var nonSemanticUnionFieldAttribute = unionFieldAttribute.ignoreId(); + + int existingIndex = unionFieldAttributes.indexOf(nonSemanticUnionFieldAttribute); if (existingIndex >= 0) { // Do not generate multiple name/type combinations with different IDs - return unionFieldAttributes.get(existingIndex); + return unionFieldAttributes.get(existingIndex).get(); } else { - unionFieldAttributes.add(unionFieldAttribute); - return unionFieldAttribute; + unionFieldAttributes.add(nonSemanticUnionFieldAttribute); + return nonSemanticUnionFieldAttribute.get(); } } From eeb6c5ae76b51c28ea15d4e62b0e98f973cfea34 Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Thu, 18 Sep 2025 18:29:43 +0200 Subject: [PATCH 11/38] Fix a bunch of serialization tests --- .../xpack/esql/SerializationTestUtils.java | 11 ++++++++- .../AbstractExpressionSerializationTests.java | 24 +++++++++++++++++++ ...AbstractUnaryScalarSerializationTests.java | 4 ++-- .../AbstractVarargsSerializationTests.java | 4 ++-- .../expression/LiteralSerializationTests.java | 4 ++-- .../expression/OrderSerializationTests.java | 4 ++-- .../aggregate/AbsentSerializationTests.java | 4 ++-- .../aggregate/AvgSerializationTests.java | 4 ++-- .../CountDistinctSerializationTests.java | 4 ++-- .../aggregate/CountSerializationTests.java | 4 ++-- .../aggregate/FirstSerializationTests.java | 4 ++-- .../aggregate/LastSerializationTests.java | 4 ++-- .../aggregate/MaxSerializationTests.java | 4 ++-- ...anAbsoluteDeviationSerializationTests.java | 4 ++-- .../aggregate/MedianSerializationTests.java | 4 ++-- .../aggregate/MinSerializationTests.java | 4 ++-- .../PercentileSerializationTests.java | 4 ++-- .../aggregate/PresentSerializationTests.java | 4 ++-- .../aggregate/RateSerializationTests.java | 4 ++-- .../aggregate/SampleSerializationTests.java | 4 ++-- .../SpatialCentroidSerializationTests.java | 4 ++-- .../SpatialExtentSerializationTests.java | 4 ++-- .../aggregate/StdDevSerializationTests.java | 4 ++-- .../aggregate/SumSerializationTests.java | 4 ++-- .../aggregate/TopSerializationTests.java | 4 ++-- .../aggregate/ValuesSerializationTests.java | 4 ++-- .../WeightedAvgSerializationTests.java | 4 ++-- .../grouping/BucketSerializationTests.java | 4 ++-- .../scalar/AndSerializationTests.java | 4 ++-- .../scalar/NotSerializationTests.java | 4 ++-- .../function/scalar/OrSerializationTests.java | 4 ++-- .../date/DateDiffSerializationTests.java | 4 ++-- .../date/DateExtractSerializationTests.java | 4 ++-- .../date/DateFormatSerializationTests.java | 4 ++-- .../date/DateParseSerializationTests.java | 4 ++-- .../date/DateTruncSerializationTests.java | 4 ++-- .../date/DayNameSerializationTests.java | 4 ++-- .../date/MonthNameSerializationTests.java | 4 ++-- .../scalar/date/NowSerializationTests.java | 4 ++-- .../ip/CIDRMatchSerializationTests.java | 4 ++-- .../scalar/ip/IpPrefixSerializationTests.java | 4 ++-- .../scalar/math/Atan2SerializationTests.java | 4 ++-- .../scalar/math/ESerializationTests.java | 4 ++-- .../scalar/math/HypotSerializationTests.java | 4 ++-- .../scalar/math/LogSerializationTests.java | 4 ++-- .../scalar/math/PiSerializationTests.java | 4 ++-- .../scalar/math/PowSerializationTests.java | 4 ++-- .../scalar/math/RoundSerializationTests.java | 4 ++-- .../math/RoundToSerializationTests.java | 4 ++-- .../scalar/math/TauSerializationTests.java | 4 ++-- .../MvAppendSerializationTests.java | 4 ++-- .../multivalue/MvAvgSerializationTests.java | 4 ++-- .../MvConcatSerializationTests.java | 4 ++-- .../MvContainsSerializationTests.java | 4 ++-- .../multivalue/MvCountSerializationTests.java | 4 ++-- .../MvDedupeSerializationTests.java | 4 ++-- .../multivalue/MvFirstSerializationTests.java | 4 ++-- .../multivalue/MvLastSerializationTests.java | 4 ++-- .../multivalue/MvMaxSerializationTests.java | 4 ++-- ...anAbsoluteDeviationSerializationTests.java | 4 ++-- .../MvMedianSerializationTests.java | 4 ++-- .../multivalue/MvMinSerializationTests.java | 4 ++-- ...vPSeriesWeightedSumSerializationTests.java | 4 ++-- .../multivalue/MvSliceSerializationTests.java | 4 ++-- .../multivalue/MvSortSerializationTests.java | 4 ++-- .../multivalue/MvSumSerializationTests.java | 4 ++-- .../multivalue/MvZipSerializationTests.java | 4 ++-- .../nulls/IsNotNullSerializationTests.java | 4 ++-- .../nulls/IsNullSerializationTests.java | 4 ++-- ...ySpatialFunctionSerializationTestCase.java | 4 ++-- .../scalar/spatial/StXSerializationTests.java | 4 ++-- .../scalar/spatial/StYSerializationTests.java | 4 ++-- .../string/EndsWithSerializationTests.java | 4 ++-- .../scalar/string/HashSerializationTests.java | 4 ++-- .../scalar/string/LeftSerializationTests.java | 4 ++-- .../string/LocateSerializationTests.java | 4 ++-- .../scalar/string/Md5SerializationTests.java | 4 ++-- .../string/RLikeListSerializationTests.java | 4 ++-- .../string/RLikeSerializationTests.java | 4 ++-- .../string/RepeatSerializationTests.java | 4 ++-- .../string/ReplaceSerializationTests.java | 4 ++-- .../string/RightSerializationTests.java | 4 ++-- .../scalar/string/Sha1SerializationTests.java | 4 ++-- .../string/Sha256SerializationTests.java | 4 ++-- .../string/SpaceSerializationTests.java | 4 ++-- .../string/SplitSerializationTests.java | 4 ++-- .../string/StartsWithSerializationTests.java | 4 ++-- .../string/SubstringSerializationTests.java | 4 ++-- .../string/ToLowerSerializationTests.java | 4 ++-- .../string/ToUpperSerializationTests.java | 4 ++-- .../WildcardLikeListSerializationTests.java | 4 ++-- .../WildcardLikeSerializationTests.java | 4 ++-- .../AbstractArithmeticSerializationTests.java | 4 ++-- .../AbstractComparisonSerializationTests.java | 4 ++-- .../comparison/InSerializationTests.java | 4 ++-- .../InsensitiveEqualsSerializationTests.java | 4 ++-- 96 files changed, 222 insertions(+), 189 deletions(-) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/SerializationTestUtils.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/SerializationTestUtils.java index e55a1b039258e..3b1b2b107de54 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/SerializationTestUtils.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/SerializationTestUtils.java @@ -26,7 +26,9 @@ import org.elasticsearch.index.query.WildcardQueryBuilder; import org.elasticsearch.search.vectors.KnnVectorQueryBuilder; import org.elasticsearch.test.EqualsHashCodeTestUtils; +import org.elasticsearch.xpack.esql.core.expression.Attribute; import org.elasticsearch.xpack.esql.core.expression.Expression; +import org.elasticsearch.xpack.esql.core.expression.NameId; import org.elasticsearch.xpack.esql.expression.ExpressionWritables; import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput; import org.elasticsearch.xpack.esql.io.stream.PlanStreamOutput; @@ -65,6 +67,13 @@ public static void assertSerialization(Expression expression) { assertSerialization(expression, EsqlTestUtils.TEST_CFG); } + private static final NameId DUMMY_ID = new NameId(); + + @SuppressWarnings("unchecked") + public static E ignoreIds(E expression) { + return (E) expression.transformDown(Attribute.class, attr -> attr.withId(DUMMY_ID)); + } + public static void assertSerialization(Expression expression, Configuration configuration) { Expression deserExpression = serializeDeserialize( expression, @@ -72,7 +81,7 @@ public static void assertSerialization(Expression expression, Configuration conf in -> in.readNamedWriteable(Expression.class), configuration ); - EqualsHashCodeTestUtils.checkEqualsAndHashCode(expression, unused -> deserExpression); + EqualsHashCodeTestUtils.checkEqualsAndHashCode(ignoreIds(expression), unused -> ignoreIds(deserExpression)); } public static T serializeDeserialize(T orig, Serializer serializer, Deserializer deserializer) { diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractExpressionSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractExpressionSerializationTests.java index 050293e58c19d..b8c1f3fb6b98d 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractExpressionSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractExpressionSerializationTests.java @@ -7,12 +7,17 @@ package org.elasticsearch.xpack.esql.expression; +import org.elasticsearch.TransportVersion; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.xpack.esql.core.expression.Expression; import org.elasticsearch.xpack.esql.core.tree.Node; import org.elasticsearch.xpack.esql.expression.function.ReferenceAttributeTests; import org.elasticsearch.xpack.esql.plan.AbstractNodeSerializationTests; +import java.io.IOException; + +import static org.elasticsearch.xpack.esql.SerializationTestUtils.ignoreIds; + public abstract class AbstractExpressionSerializationTests extends AbstractNodeSerializationTests { public static Expression randomChild() { @@ -32,4 +37,23 @@ protected final NamedWriteableRegistry getNamedWriteableRegistry() { protected Class> categoryClass() { return Expression.class; } + + @Override + protected final T createTestInstance() { + return ignoreIds(innerCreateTestInstance()); + } + + protected abstract T innerCreateTestInstance(); + + @Override + protected final T mutateInstance(T instance) throws IOException { + return ignoreIds(innerMutateInstance(instance)); + } + + protected abstract T innerMutateInstance(T instance) throws IOException; + + @Override + protected T copyInstance(T instance, TransportVersion version) throws IOException { + return ignoreIds(super.copyInstance(instance, version)); + } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractUnaryScalarSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractUnaryScalarSerializationTests.java index 8581699b83fbd..451b2d0bfc0b5 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractUnaryScalarSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractUnaryScalarSerializationTests.java @@ -17,12 +17,12 @@ public abstract class AbstractUnaryScalarSerializationTests ex protected abstract T create(Source source, Expression first, List rest); @Override - protected final T createTestInstance() { + protected final T innerCreateTestInstance() { Source source = randomSource(); Expression first = randomChild(); List rest = randomList(0, 10, AbstractExpressionSerializationTests::randomChild); @@ -25,7 +25,7 @@ protected final T createTestInstance() { } @Override - protected final T mutateInstance(T instance) throws IOException { + protected final T innerMutateInstance(T instance) throws IOException { Source source = instance.source(); Expression first = instance.children().get(0); List rest = instance.children().subList(1, instance.children().size()); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/LiteralSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/LiteralSerializationTests.java index fa6041c6d2e58..9c433373c74e0 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/LiteralSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/LiteralSerializationTests.java @@ -14,12 +14,12 @@ public class LiteralSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Literal createTestInstance() { + protected Literal innerCreateTestInstance() { return LiteralTests.randomLiteral(); } @Override - protected Literal mutateInstance(Literal instance) throws IOException { + protected Literal innerMutateInstance(Literal instance) throws IOException { return LiteralTests.mutateLiteral(instance); } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/OrderSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/OrderSerializationTests.java index 4b14e453201f8..96267cd2e0427 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/OrderSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/OrderSerializationTests.java @@ -18,7 +18,7 @@ public static Order randomOrder() { } @Override - protected Order createTestInstance() { + protected Order innerCreateTestInstance() { return randomOrder(); } @@ -31,7 +31,7 @@ private static Order.NullsPosition randomNulls() { } @Override - protected Order mutateInstance(Order instance) throws IOException { + protected Order innerMutateInstance(Order instance) throws IOException { Source source = instance.source(); Expression child = instance.child(); Order.OrderDirection direction = instance.direction(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/AbsentSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/AbsentSerializationTests.java index 1d7e1e0b62428..26ce06d0908f4 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/AbsentSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/AbsentSerializationTests.java @@ -13,12 +13,12 @@ public class AbsentSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Absent createTestInstance() { + protected Absent innerCreateTestInstance() { return new Absent(randomSource(), randomChild()); } @Override - protected Absent mutateInstance(Absent instance) throws IOException { + protected Absent innerMutateInstance(Absent instance) throws IOException { return new Absent(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/AvgSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/AvgSerializationTests.java index 5d6fa21e20813..738248a8b4d54 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/AvgSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/AvgSerializationTests.java @@ -25,12 +25,12 @@ public class AvgSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Avg createTestInstance() { + protected Avg innerCreateTestInstance() { return new Avg(randomSource(), randomChild(), randomChild(), randomChild()); } @Override - protected Avg mutateInstance(Avg instance) throws IOException { + protected Avg innerMutateInstance(Avg instance) throws IOException { Expression field = instance.field(); Expression filter = instance.filter(); Expression summationMode = instance.summationMode(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/CountDistinctSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/CountDistinctSerializationTests.java index 1dbaaf16a559c..d15444e1040b4 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/CountDistinctSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/CountDistinctSerializationTests.java @@ -15,7 +15,7 @@ public class CountDistinctSerializationTests extends AbstractExpressionSerializationTests { @Override - protected CountDistinct createTestInstance() { + protected CountDistinct innerCreateTestInstance() { Source source = randomSource(); Expression field = randomChild(); Expression precision = randomBoolean() ? null : randomChild(); @@ -23,7 +23,7 @@ protected CountDistinct createTestInstance() { } @Override - protected CountDistinct mutateInstance(CountDistinct instance) throws IOException { + protected CountDistinct innerMutateInstance(CountDistinct instance) throws IOException { Source source = randomSource(); Expression field = instance.field(); Expression precision = instance.precision(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/CountSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/CountSerializationTests.java index 39defdd9c0777..44241ab4359f4 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/CountSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/CountSerializationTests.java @@ -13,12 +13,12 @@ public class CountSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Count createTestInstance() { + protected Count innerCreateTestInstance() { return new Count(randomSource(), randomChild()); } @Override - protected Count mutateInstance(Count instance) throws IOException { + protected Count innerMutateInstance(Count instance) throws IOException { return new Count(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/FirstSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/FirstSerializationTests.java index e4cc6ad5ebb9d..356e171976a45 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/FirstSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/FirstSerializationTests.java @@ -14,12 +14,12 @@ public class FirstSerializationTests extends AbstractExpressionSerializationTests { @Override - protected First createTestInstance() { + protected First innerCreateTestInstance() { return new First(randomSource(), randomChild(), randomChild()); } @Override - protected First mutateInstance(First instance) throws IOException { + protected First innerMutateInstance(First instance) throws IOException { Expression field = instance.field(); Expression sort = instance.sort(); if (randomBoolean()) { diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/LastSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/LastSerializationTests.java index 81a68b6003a32..129b859951cf4 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/LastSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/LastSerializationTests.java @@ -14,12 +14,12 @@ public class LastSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Last createTestInstance() { + protected Last innerCreateTestInstance() { return new Last(randomSource(), randomChild(), randomChild()); } @Override - protected Last mutateInstance(Last instance) throws IOException { + protected Last innerMutateInstance(Last instance) throws IOException { Expression field = instance.field(); Expression sort = instance.sort(); if (randomBoolean()) { diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MaxSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MaxSerializationTests.java index c1c4898f1e057..ea6ca2fe528b1 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MaxSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MaxSerializationTests.java @@ -13,12 +13,12 @@ public class MaxSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Max createTestInstance() { + protected Max innerCreateTestInstance() { return new Max(randomSource(), randomChild()); } @Override - protected Max mutateInstance(Max instance) throws IOException { + protected Max innerMutateInstance(Max instance) throws IOException { return new Max(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MedianAbsoluteDeviationSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MedianAbsoluteDeviationSerializationTests.java index 1d6497541e29b..334afdab80f25 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MedianAbsoluteDeviationSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MedianAbsoluteDeviationSerializationTests.java @@ -13,12 +13,12 @@ public class MedianAbsoluteDeviationSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MedianAbsoluteDeviation createTestInstance() { + protected MedianAbsoluteDeviation innerCreateTestInstance() { return new MedianAbsoluteDeviation(randomSource(), randomChild()); } @Override - protected MedianAbsoluteDeviation mutateInstance(MedianAbsoluteDeviation instance) throws IOException { + protected MedianAbsoluteDeviation innerMutateInstance(MedianAbsoluteDeviation instance) throws IOException { return new MedianAbsoluteDeviation( instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MedianSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MedianSerializationTests.java index f0b2d63da70d1..afe075b9c1eab 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MedianSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MedianSerializationTests.java @@ -13,12 +13,12 @@ public class MedianSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Median createTestInstance() { + protected Median innerCreateTestInstance() { return new Median(randomSource(), randomChild()); } @Override - protected Median mutateInstance(Median instance) throws IOException { + protected Median innerMutateInstance(Median instance) throws IOException { return new Median(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MinSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MinSerializationTests.java index 18e813acdb74c..23e17234ab59a 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MinSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MinSerializationTests.java @@ -13,12 +13,12 @@ public class MinSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Min createTestInstance() { + protected Min innerCreateTestInstance() { return new Min(randomSource(), randomChild()); } @Override - protected Min mutateInstance(Min instance) throws IOException { + protected Min innerMutateInstance(Min instance) throws IOException { return new Min(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/PercentileSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/PercentileSerializationTests.java index 5c01b62f7d663..193494d94ab52 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/PercentileSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/PercentileSerializationTests.java @@ -15,7 +15,7 @@ public class PercentileSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Percentile createTestInstance() { + protected Percentile innerCreateTestInstance() { Source source = randomSource(); Expression field = randomChild(); Expression percentile = randomChild(); @@ -23,7 +23,7 @@ protected Percentile createTestInstance() { } @Override - protected Percentile mutateInstance(Percentile instance) throws IOException { + protected Percentile innerMutateInstance(Percentile instance) throws IOException { Source source = instance.source(); Expression field = instance.field(); Expression percentile = instance.percentile(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/PresentSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/PresentSerializationTests.java index ab221e43861f6..402353550aac3 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/PresentSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/PresentSerializationTests.java @@ -13,12 +13,12 @@ public class PresentSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Present createTestInstance() { + protected Present innerCreateTestInstance() { return new Present(randomSource(), randomChild()); } @Override - protected Present mutateInstance(Present instance) throws IOException { + protected Present innerMutateInstance(Present instance) throws IOException { return new Present(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/RateSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/RateSerializationTests.java index d3130f9ae5f44..d057646b991c6 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/RateSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/RateSerializationTests.java @@ -15,7 +15,7 @@ public class RateSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Rate createTestInstance() { + protected Rate innerCreateTestInstance() { Source source = randomSource(); Expression field = randomChild(); Expression timestamp = randomChild(); @@ -23,7 +23,7 @@ protected Rate createTestInstance() { } @Override - protected Rate mutateInstance(Rate instance) throws IOException { + protected Rate innerMutateInstance(Rate instance) throws IOException { Source source = randomSource(); Expression field = instance.field(); Expression timestamp = instance.timestamp(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SampleSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SampleSerializationTests.java index 078557093a317..e9bfc96e81270 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SampleSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SampleSerializationTests.java @@ -15,7 +15,7 @@ public class SampleSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Sample createTestInstance() { + protected Sample innerCreateTestInstance() { Source source = randomSource(); Expression field = randomChild(); Expression limit = randomChild(); @@ -23,7 +23,7 @@ protected Sample createTestInstance() { } @Override - protected Sample mutateInstance(Sample instance) throws IOException { + protected Sample innerMutateInstance(Sample instance) throws IOException { Source source = randomSource(); Expression field = instance.field(); Expression limit = instance.limitField(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SpatialCentroidSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SpatialCentroidSerializationTests.java index 4d31cd3cf31ff..a34ea43c6c04d 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SpatialCentroidSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SpatialCentroidSerializationTests.java @@ -13,12 +13,12 @@ public class SpatialCentroidSerializationTests extends AbstractExpressionSerializationTests { @Override - protected SpatialCentroid createTestInstance() { + protected SpatialCentroid innerCreateTestInstance() { return new SpatialCentroid(randomSource(), randomChild()); } @Override - protected SpatialCentroid mutateInstance(SpatialCentroid instance) throws IOException { + protected SpatialCentroid innerMutateInstance(SpatialCentroid instance) throws IOException { return new SpatialCentroid( instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SpatialExtentSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SpatialExtentSerializationTests.java index eacb95646651a..d6611bb2ef74d 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SpatialExtentSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SpatialExtentSerializationTests.java @@ -13,12 +13,12 @@ public class SpatialExtentSerializationTests extends AbstractExpressionSerializationTests { @Override - protected SpatialExtent createTestInstance() { + protected SpatialExtent innerCreateTestInstance() { return new SpatialExtent(randomSource(), randomChild()); } @Override - protected SpatialExtent mutateInstance(SpatialExtent instance) throws IOException { + protected SpatialExtent innerMutateInstance(SpatialExtent instance) throws IOException { return new SpatialExtent( instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/StdDevSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/StdDevSerializationTests.java index 3dd7bbb321ccb..88c85884506f2 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/StdDevSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/StdDevSerializationTests.java @@ -13,12 +13,12 @@ public class StdDevSerializationTests extends AbstractExpressionSerializationTests { @Override - protected StdDev createTestInstance() { + protected StdDev innerCreateTestInstance() { return new StdDev(randomSource(), randomChild()); } @Override - protected StdDev mutateInstance(StdDev instance) throws IOException { + protected StdDev innerMutateInstance(StdDev instance) throws IOException { return new StdDev(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SumSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SumSerializationTests.java index f15d8bb96cf24..c36a1709850ce 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SumSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SumSerializationTests.java @@ -25,12 +25,12 @@ public class SumSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Sum createTestInstance() { + protected Sum innerCreateTestInstance() { return new Sum(randomSource(), randomChild(), randomChild(), randomChild()); } @Override - protected Sum mutateInstance(Sum instance) throws IOException { + protected Sum innerMutateInstance(Sum instance) throws IOException { Expression field = instance.field(); Expression filter = instance.filter(); Expression summationMode = instance.summationMode(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/TopSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/TopSerializationTests.java index 82bf57d1a194e..0a533b2352a15 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/TopSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/TopSerializationTests.java @@ -15,7 +15,7 @@ public class TopSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Top createTestInstance() { + protected Top innerCreateTestInstance() { Source source = randomSource(); Expression field = randomChild(); Expression limit = randomChild(); @@ -24,7 +24,7 @@ protected Top createTestInstance() { } @Override - protected Top mutateInstance(Top instance) throws IOException { + protected Top innerMutateInstance(Top instance) throws IOException { Source source = instance.source(); Expression field = instance.field(); Expression limit = instance.limitField(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/ValuesSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/ValuesSerializationTests.java index aac10e14a6999..9ead9002bb8d7 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/ValuesSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/ValuesSerializationTests.java @@ -13,12 +13,12 @@ public class ValuesSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Values createTestInstance() { + protected Values innerCreateTestInstance() { return new Values(randomSource(), randomChild()); } @Override - protected Values mutateInstance(Values instance) throws IOException { + protected Values innerMutateInstance(Values instance) throws IOException { return new Values(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/WeightedAvgSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/WeightedAvgSerializationTests.java index 000d02fe342a3..81eeacf6823d2 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/WeightedAvgSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/WeightedAvgSerializationTests.java @@ -14,12 +14,12 @@ public class WeightedAvgSerializationTests extends AbstractExpressionSerializationTests { @Override - protected WeightedAvg createTestInstance() { + protected WeightedAvg innerCreateTestInstance() { return new WeightedAvg(randomSource(), randomChild(), randomChild()); } @Override - protected WeightedAvg mutateInstance(WeightedAvg instance) throws IOException { + protected WeightedAvg innerMutateInstance(WeightedAvg instance) throws IOException { Expression field = instance.field(); Expression weight = instance.weight(); if (randomBoolean()) { diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/grouping/BucketSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/grouping/BucketSerializationTests.java index 5fe270a4cce42..a60d12be3c185 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/grouping/BucketSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/grouping/BucketSerializationTests.java @@ -15,7 +15,7 @@ public class BucketSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Bucket createTestInstance() { + protected Bucket innerCreateTestInstance() { return createRandomBucket(); } @@ -29,7 +29,7 @@ public static Bucket createRandomBucket() { } @Override - protected Bucket mutateInstance(Bucket instance) throws IOException { + protected Bucket innerMutateInstance(Bucket instance) throws IOException { Source source = instance.source(); Expression field = instance.field(); Expression buckets = instance.buckets(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/AndSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/AndSerializationTests.java index fdfdebb159531..8d194dc251744 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/AndSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/AndSerializationTests.java @@ -16,7 +16,7 @@ public class AndSerializationTests extends AbstractExpressionSerializationTests { @Override - protected And createTestInstance() { + protected And innerCreateTestInstance() { Source source = randomSource(); Expression left = randomChild(); Expression right = randomChild(); @@ -24,7 +24,7 @@ protected And createTestInstance() { } @Override - protected And mutateInstance(And instance) throws IOException { + protected And innerMutateInstance(And instance) throws IOException { Source source = instance.source(); Expression left = instance.left(); Expression right = instance.right(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/NotSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/NotSerializationTests.java index 966bb664f2a09..6e90a1c0027c8 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/NotSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/NotSerializationTests.java @@ -16,12 +16,12 @@ public class NotSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Not createTestInstance() { + protected Not innerCreateTestInstance() { return new Not(randomSource(), randomChild()); } @Override - protected Not mutateInstance(Not instance) throws IOException { + protected Not innerMutateInstance(Not instance) throws IOException { Source source = instance.source(); Expression child = randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild); return new Not(source, child); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/OrSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/OrSerializationTests.java index 9ceddc9910485..b4c469460f111 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/OrSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/OrSerializationTests.java @@ -16,7 +16,7 @@ public class OrSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Or createTestInstance() { + protected Or innerCreateTestInstance() { Source source = randomSource(); Expression left = randomChild(); Expression right = randomChild(); @@ -24,7 +24,7 @@ protected Or createTestInstance() { } @Override - protected Or mutateInstance(Or instance) throws IOException { + protected Or innerMutateInstance(Or instance) throws IOException { Source source = instance.source(); Expression left = instance.left(); Expression right = instance.right(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateDiffSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateDiffSerializationTests.java index f1f8d1b0f8dad..40af73eac5afa 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateDiffSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateDiffSerializationTests.java @@ -15,7 +15,7 @@ public class DateDiffSerializationTests extends AbstractExpressionSerializationTests { @Override - protected DateDiff createTestInstance() { + protected DateDiff innerCreateTestInstance() { Source source = randomSource(); Expression unit = randomChild(); Expression startTimestamp = randomChild(); @@ -24,7 +24,7 @@ protected DateDiff createTestInstance() { } @Override - protected DateDiff mutateInstance(DateDiff instance) throws IOException { + protected DateDiff innerMutateInstance(DateDiff instance) throws IOException { Source source = instance.source(); Expression unit = instance.unit(); Expression startTimestamp = instance.startTimestamp(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateExtractSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateExtractSerializationTests.java index f4e6d2672a40f..250b9729514ec 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateExtractSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateExtractSerializationTests.java @@ -15,7 +15,7 @@ public class DateExtractSerializationTests extends AbstractExpressionSerializationTests { @Override - protected DateExtract createTestInstance() { + protected DateExtract innerCreateTestInstance() { Source source = randomSource(); Expression datePart = randomChild(); Expression field = randomChild(); @@ -23,7 +23,7 @@ protected DateExtract createTestInstance() { } @Override - protected DateExtract mutateInstance(DateExtract instance) throws IOException { + protected DateExtract innerMutateInstance(DateExtract instance) throws IOException { Source source = instance.source(); Expression datePart = instance.datePart(); Expression field = instance.field(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateFormatSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateFormatSerializationTests.java index ece145e95aabb..0c44b67a611e2 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateFormatSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateFormatSerializationTests.java @@ -15,7 +15,7 @@ public class DateFormatSerializationTests extends AbstractExpressionSerializationTests { @Override - protected DateFormat createTestInstance() { + protected DateFormat innerCreateTestInstance() { Source source = randomSource(); Expression field = randomChild(); Expression format = randomBoolean() ? null : randomChild(); @@ -23,7 +23,7 @@ protected DateFormat createTestInstance() { } @Override - protected DateFormat mutateInstance(DateFormat instance) throws IOException { + protected DateFormat innerMutateInstance(DateFormat instance) throws IOException { Source source = instance.source(); Expression field = instance.field(); Expression format = instance.format(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateParseSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateParseSerializationTests.java index 79a650c8dd963..9df40c464e041 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateParseSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateParseSerializationTests.java @@ -15,7 +15,7 @@ public class DateParseSerializationTests extends AbstractExpressionSerializationTests { @Override - protected DateParse createTestInstance() { + protected DateParse innerCreateTestInstance() { Source source = randomSource(); Expression first = randomChild(); Expression second = randomBoolean() ? null : randomChild(); @@ -23,7 +23,7 @@ protected DateParse createTestInstance() { } @Override - protected DateParse mutateInstance(DateParse instance) throws IOException { + protected DateParse innerMutateInstance(DateParse instance) throws IOException { Source source = instance.source(); Expression first = instance.children().get(0); Expression second = instance.children().size() == 1 ? null : instance.children().get(1); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateTruncSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateTruncSerializationTests.java index 3d1616ce29adf..64b623abf070a 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateTruncSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateTruncSerializationTests.java @@ -15,7 +15,7 @@ public class DateTruncSerializationTests extends AbstractExpressionSerializationTests { @Override - protected DateTrunc createTestInstance() { + protected DateTrunc innerCreateTestInstance() { Source source = randomSource(); Expression interval = randomChild(); Expression field = randomChild(); @@ -23,7 +23,7 @@ protected DateTrunc createTestInstance() { } @Override - protected DateTrunc mutateInstance(DateTrunc instance) throws IOException { + protected DateTrunc innerMutateInstance(DateTrunc instance) throws IOException { Source source = instance.source(); Expression interval = instance.interval(); Expression field = instance.field(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DayNameSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DayNameSerializationTests.java index 49173d4db9c6d..70a433985ecce 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DayNameSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DayNameSerializationTests.java @@ -16,14 +16,14 @@ public class DayNameSerializationTests extends AbstractExpressionSerializationTests { @Override - protected DayName createTestInstance() { + protected DayName innerCreateTestInstance() { Source source = randomSource(); Expression date = randomChild(); return new DayName(source, date, configuration()); } @Override - protected DayName mutateInstance(DayName instance) throws IOException { + protected DayName innerMutateInstance(DayName instance) throws IOException { Source source = instance.source(); Expression date = instance.field(); return new DayName(source, randomValueOtherThan(date, AbstractExpressionSerializationTests::randomChild), configuration()); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/MonthNameSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/MonthNameSerializationTests.java index 348c7f9be8cc6..d3c20a9602c9b 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/MonthNameSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/MonthNameSerializationTests.java @@ -16,14 +16,14 @@ public class MonthNameSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MonthName createTestInstance() { + protected MonthName innerCreateTestInstance() { Source source = randomSource(); Expression date = randomChild(); return new MonthName(source, date, configuration()); } @Override - protected MonthName mutateInstance(MonthName instance) throws IOException { + protected MonthName innerMutateInstance(MonthName instance) throws IOException { Source source = instance.source(); Expression date = instance.field(); return new MonthName(source, randomValueOtherThan(date, AbstractExpressionSerializationTests::randomChild), configuration()); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/NowSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/NowSerializationTests.java index b816e3a8da858..c015e21b15e46 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/NowSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/NowSerializationTests.java @@ -13,12 +13,12 @@ public class NowSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Now createTestInstance() { + protected Now innerCreateTestInstance() { return new Now(randomSource(), configuration()); } @Override - protected Now mutateInstance(Now instance) throws IOException { + protected Now innerMutateInstance(Now instance) throws IOException { return null; } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/ip/CIDRMatchSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/ip/CIDRMatchSerializationTests.java index 3c833c4b0d7ac..ee019fa43be22 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/ip/CIDRMatchSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/ip/CIDRMatchSerializationTests.java @@ -16,7 +16,7 @@ public class CIDRMatchSerializationTests extends AbstractExpressionSerializationTests { @Override - protected CIDRMatch createTestInstance() { + protected CIDRMatch innerCreateTestInstance() { Source source = randomSource(); Expression ipField = randomChild(); List matches = randomList(1, 10, AbstractExpressionSerializationTests::randomChild); @@ -24,7 +24,7 @@ protected CIDRMatch createTestInstance() { } @Override - protected CIDRMatch mutateInstance(CIDRMatch instance) throws IOException { + protected CIDRMatch innerMutateInstance(CIDRMatch instance) throws IOException { Source source = instance.source(); Expression ipField = instance.ipField(); List matches = instance.matches(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/ip/IpPrefixSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/ip/IpPrefixSerializationTests.java index d7fc05d9d0f64..794304dd8f747 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/ip/IpPrefixSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/ip/IpPrefixSerializationTests.java @@ -15,7 +15,7 @@ public class IpPrefixSerializationTests extends AbstractExpressionSerializationTests { @Override - protected IpPrefix createTestInstance() { + protected IpPrefix innerCreateTestInstance() { Source source = randomSource(); Expression ipField = randomChild(); Expression prefixLengthV4Field = randomChild(); @@ -24,7 +24,7 @@ protected IpPrefix createTestInstance() { } @Override - protected IpPrefix mutateInstance(IpPrefix instance) throws IOException { + protected IpPrefix innerMutateInstance(IpPrefix instance) throws IOException { Source source = instance.source(); Expression ipField = instance.ipField(); Expression prefixLengthV4Field = instance.prefixLengthV4Field(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/Atan2SerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/Atan2SerializationTests.java index 2ae88bbf24549..b0beaebec9d0f 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/Atan2SerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/Atan2SerializationTests.java @@ -16,7 +16,7 @@ public class Atan2SerializationTests extends AbstractExpressionSerializationTests { @Override - protected Atan2 createTestInstance() { + protected Atan2 innerCreateTestInstance() { Source source = randomSource(); Expression y = randomChild(); Expression x = randomChild(); @@ -24,7 +24,7 @@ protected Atan2 createTestInstance() { } @Override - protected Atan2 mutateInstance(Atan2 instance) throws IOException { + protected Atan2 innerMutateInstance(Atan2 instance) throws IOException { Source source = instance.source(); Expression y = instance.y(); Expression x = instance.x(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/ESerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/ESerializationTests.java index 971295aa02a9b..0f078e6e45eb0 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/ESerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/ESerializationTests.java @@ -13,12 +13,12 @@ public class ESerializationTests extends AbstractExpressionSerializationTests { @Override - protected E createTestInstance() { + protected E innerCreateTestInstance() { return new E(randomSource()); } @Override - protected E mutateInstance(E instance) throws IOException { + protected E innerMutateInstance(E instance) throws IOException { return null; } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/HypotSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/HypotSerializationTests.java index 5c2e84fcba8e0..c5a7a25a4adaf 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/HypotSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/HypotSerializationTests.java @@ -17,7 +17,7 @@ public class HypotSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Hypot createTestInstance() { + protected Hypot innerCreateTestInstance() { Source source = randomSource(); Expression n1 = randomChild(); Expression n2 = randomChild(); @@ -25,7 +25,7 @@ protected Hypot createTestInstance() { } @Override - protected Hypot mutateInstance(Hypot instance) throws IOException { + protected Hypot innerMutateInstance(Hypot instance) throws IOException { Source source = instance.source(); Expression n1 = instance.n1(); Expression n2 = instance.n2(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/LogSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/LogSerializationTests.java index 8b65a40d9e831..3298e1ae5045b 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/LogSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/LogSerializationTests.java @@ -15,7 +15,7 @@ public class LogSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Log createTestInstance() { + protected Log innerCreateTestInstance() { Source source = randomSource(); Expression value = randomChild(); Expression base = randomBoolean() ? null : randomChild(); @@ -23,7 +23,7 @@ protected Log createTestInstance() { } @Override - protected Log mutateInstance(Log instance) throws IOException { + protected Log innerMutateInstance(Log instance) throws IOException { Source source = instance.source(); Expression value = instance.value(); Expression base = instance.base(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/PiSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/PiSerializationTests.java index 597d1cbc8533c..43f4657a3ed5a 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/PiSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/PiSerializationTests.java @@ -13,12 +13,12 @@ public class PiSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Pi createTestInstance() { + protected Pi innerCreateTestInstance() { return new Pi(randomSource()); } @Override - protected Pi mutateInstance(Pi instance) throws IOException { + protected Pi innerMutateInstance(Pi instance) throws IOException { return null; } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/PowSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/PowSerializationTests.java index b811d719ca923..637b7ba3d26bb 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/PowSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/PowSerializationTests.java @@ -15,7 +15,7 @@ public class PowSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Pow createTestInstance() { + protected Pow innerCreateTestInstance() { Source source = randomSource(); Expression base = randomChild(); Expression exponent = randomChild(); @@ -23,7 +23,7 @@ protected Pow createTestInstance() { } @Override - protected Pow mutateInstance(Pow instance) throws IOException { + protected Pow innerMutateInstance(Pow instance) throws IOException { Source source = instance.source(); Expression base = instance.base(); Expression exponent = instance.exponent(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundSerializationTests.java index 91e97a6d07b14..20e05760a7e6b 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundSerializationTests.java @@ -15,7 +15,7 @@ public class RoundSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Round createTestInstance() { + protected Round innerCreateTestInstance() { Source source = randomSource(); Expression field = randomChild(); Expression decimals = randomBoolean() ? null : randomChild(); @@ -23,7 +23,7 @@ protected Round createTestInstance() { } @Override - protected Round mutateInstance(Round instance) throws IOException { + protected Round innerMutateInstance(Round instance) throws IOException { Source source = instance.source(); Expression field = instance.field(); Expression decimals = instance.decimals(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundToSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundToSerializationTests.java index 9d67158eb305f..e782930edee1b 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundToSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundToSerializationTests.java @@ -21,7 +21,7 @@ public class RoundToSerializationTests extends AbstractExpressionSerializationTests { @Override - protected RoundTo createTestInstance() { + protected RoundTo innerCreateTestInstance() { Source source = randomSource(); DataType type = randomFrom(DataType.INTEGER, DataType.LONG, DataType.DOUBLE, DataType.DATETIME, DataType.DATE_NANOS); Expression field = randomField(type); @@ -44,7 +44,7 @@ private List randomPoints(DataType type) { } @Override - protected RoundTo mutateInstance(RoundTo instance) throws IOException { + protected RoundTo innerMutateInstance(RoundTo instance) throws IOException { Source source = instance.source(); Expression field = instance.field(); List points = instance.points(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/TauSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/TauSerializationTests.java index fb259f0e43150..07d44702093b8 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/TauSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/TauSerializationTests.java @@ -13,12 +13,12 @@ public class TauSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Tau createTestInstance() { + protected Tau innerCreateTestInstance() { return new Tau(randomSource()); } @Override - protected Tau mutateInstance(Tau instance) throws IOException { + protected Tau innerMutateInstance(Tau instance) throws IOException { return null; } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAppendSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAppendSerializationTests.java index 9bbb4856b5e0f..90a2cf8a3db5f 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAppendSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAppendSerializationTests.java @@ -15,7 +15,7 @@ public class MvAppendSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvAppend createTestInstance() { + protected MvAppend innerCreateTestInstance() { Source source = randomSource(); Expression field1 = randomChild(); Expression field2 = randomChild(); @@ -23,7 +23,7 @@ protected MvAppend createTestInstance() { } @Override - protected MvAppend mutateInstance(MvAppend instance) throws IOException { + protected MvAppend innerMutateInstance(MvAppend instance) throws IOException { Source source = randomSource(); Expression field1 = randomChild(); Expression field2 = randomChild(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAvgSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAvgSerializationTests.java index 0a3ddaf576c38..42a70970053bc 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAvgSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAvgSerializationTests.java @@ -13,12 +13,12 @@ public class MvAvgSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvAvg createTestInstance() { + protected MvAvg innerCreateTestInstance() { return new MvAvg(randomSource(), randomChild()); } @Override - protected MvAvg mutateInstance(MvAvg instance) throws IOException { + protected MvAvg innerMutateInstance(MvAvg instance) throws IOException { return new MvAvg(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvConcatSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvConcatSerializationTests.java index ba4eda8590f70..31d64180e210a 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvConcatSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvConcatSerializationTests.java @@ -15,7 +15,7 @@ public class MvConcatSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvConcat createTestInstance() { + protected MvConcat innerCreateTestInstance() { Source source = randomSource(); Expression left = randomChild(); Expression right = randomChild(); @@ -23,7 +23,7 @@ protected MvConcat createTestInstance() { } @Override - protected MvConcat mutateInstance(MvConcat instance) throws IOException { + protected MvConcat innerMutateInstance(MvConcat instance) throws IOException { Source source = instance.source(); Expression left = instance.left(); Expression right = instance.right(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvContainsSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvContainsSerializationTests.java index 3f190b0250671..c71abe7360c0d 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvContainsSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvContainsSerializationTests.java @@ -15,7 +15,7 @@ public class MvContainsSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvContains createTestInstance() { + protected MvContains innerCreateTestInstance() { Source source = randomSource(); Expression field1 = randomChild(); Expression field2 = randomChild(); @@ -23,7 +23,7 @@ protected MvContains createTestInstance() { } @Override - protected MvContains mutateInstance(MvContains instance) throws IOException { + protected MvContains innerMutateInstance(MvContains instance) throws IOException { Source source = randomSource(); Expression field1 = randomChild(); Expression field2 = randomChild(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvCountSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvCountSerializationTests.java index be641e210782c..ec8ec1e1811ec 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvCountSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvCountSerializationTests.java @@ -13,12 +13,12 @@ public class MvCountSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvCount createTestInstance() { + protected MvCount innerCreateTestInstance() { return new MvCount(randomSource(), randomChild()); } @Override - protected MvCount mutateInstance(MvCount instance) throws IOException { + protected MvCount innerMutateInstance(MvCount instance) throws IOException { return new MvCount(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvDedupeSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvDedupeSerializationTests.java index 151b73c3fb9a3..e26c85c0f3f40 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvDedupeSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvDedupeSerializationTests.java @@ -13,12 +13,12 @@ public class MvDedupeSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvDedupe createTestInstance() { + protected MvDedupe innerCreateTestInstance() { return new MvDedupe(randomSource(), randomChild()); } @Override - protected MvDedupe mutateInstance(MvDedupe instance) throws IOException { + protected MvDedupe innerMutateInstance(MvDedupe instance) throws IOException { return new MvDedupe(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvFirstSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvFirstSerializationTests.java index 59d42abfbf291..f6e081938f788 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvFirstSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvFirstSerializationTests.java @@ -13,12 +13,12 @@ public class MvFirstSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvFirst createTestInstance() { + protected MvFirst innerCreateTestInstance() { return new MvFirst(randomSource(), randomChild()); } @Override - protected MvFirst mutateInstance(MvFirst instance) throws IOException { + protected MvFirst innerMutateInstance(MvFirst instance) throws IOException { return new MvFirst(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvLastSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvLastSerializationTests.java index d3aada6879caa..cdd8b89f24965 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvLastSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvLastSerializationTests.java @@ -13,12 +13,12 @@ public class MvLastSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvLast createTestInstance() { + protected MvLast innerCreateTestInstance() { return new MvLast(randomSource(), randomChild()); } @Override - protected MvLast mutateInstance(MvLast instance) throws IOException { + protected MvLast innerMutateInstance(MvLast instance) throws IOException { return new MvLast(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMaxSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMaxSerializationTests.java index d4880b6814905..3229dfb3e18d0 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMaxSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMaxSerializationTests.java @@ -13,12 +13,12 @@ public class MvMaxSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvMax createTestInstance() { + protected MvMax innerCreateTestInstance() { return new MvMax(randomSource(), randomChild()); } @Override - protected MvMax mutateInstance(MvMax instance) throws IOException { + protected MvMax innerMutateInstance(MvMax instance) throws IOException { return new MvMax(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMedianAbsoluteDeviationSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMedianAbsoluteDeviationSerializationTests.java index 3e402a9f7422e..e9073378b7efb 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMedianAbsoluteDeviationSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMedianAbsoluteDeviationSerializationTests.java @@ -13,12 +13,12 @@ public class MvMedianAbsoluteDeviationSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvMedianAbsoluteDeviation createTestInstance() { + protected MvMedianAbsoluteDeviation innerCreateTestInstance() { return new MvMedianAbsoluteDeviation(randomSource(), randomChild()); } @Override - protected MvMedianAbsoluteDeviation mutateInstance(MvMedianAbsoluteDeviation instance) throws IOException { + protected MvMedianAbsoluteDeviation innerMutateInstance(MvMedianAbsoluteDeviation instance) throws IOException { return new MvMedianAbsoluteDeviation( instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMedianSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMedianSerializationTests.java index 6b7a1dd5a8d0f..8ab491118553c 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMedianSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMedianSerializationTests.java @@ -13,12 +13,12 @@ public class MvMedianSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvMedian createTestInstance() { + protected MvMedian innerCreateTestInstance() { return new MvMedian(randomSource(), randomChild()); } @Override - protected MvMedian mutateInstance(MvMedian instance) throws IOException { + protected MvMedian innerMutateInstance(MvMedian instance) throws IOException { return new MvMedian(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMinSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMinSerializationTests.java index f53aa660834cf..7f792fee6521f 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMinSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMinSerializationTests.java @@ -13,12 +13,12 @@ public class MvMinSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvMin createTestInstance() { + protected MvMin innerCreateTestInstance() { return new MvMin(randomSource(), randomChild()); } @Override - protected MvMin mutateInstance(MvMin instance) throws IOException { + protected MvMin innerMutateInstance(MvMin instance) throws IOException { return new MvMin(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPSeriesWeightedSumSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPSeriesWeightedSumSerializationTests.java index dcb525c79b272..2c08563fa5b8c 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPSeriesWeightedSumSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPSeriesWeightedSumSerializationTests.java @@ -15,7 +15,7 @@ public class MvPSeriesWeightedSumSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvPSeriesWeightedSum createTestInstance() { + protected MvPSeriesWeightedSum innerCreateTestInstance() { Source source = randomSource(); Expression field = randomChild(); Expression p = randomChild(); @@ -24,7 +24,7 @@ protected MvPSeriesWeightedSum createTestInstance() { } @Override - protected MvPSeriesWeightedSum mutateInstance(MvPSeriesWeightedSum instance) throws IOException { + protected MvPSeriesWeightedSum innerMutateInstance(MvPSeriesWeightedSum instance) throws IOException { Source source = instance.source(); Expression field = instance.field(); Expression p = instance.p(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSliceSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSliceSerializationTests.java index 70f106b65f78d..a0fe8ac4d8804 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSliceSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSliceSerializationTests.java @@ -15,7 +15,7 @@ public class MvSliceSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvSlice createTestInstance() { + protected MvSlice innerCreateTestInstance() { Source source = randomSource(); Expression field = randomChild(); Expression start = randomChild(); @@ -24,7 +24,7 @@ protected MvSlice createTestInstance() { } @Override - protected MvSlice mutateInstance(MvSlice instance) throws IOException { + protected MvSlice innerMutateInstance(MvSlice instance) throws IOException { Source source = instance.source(); Expression field = instance.field(); Expression start = instance.start(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSortSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSortSerializationTests.java index d7dba33e1aae3..64a8b44d6f111 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSortSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSortSerializationTests.java @@ -15,7 +15,7 @@ public class MvSortSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvSort createTestInstance() { + protected MvSort innerCreateTestInstance() { Source source = randomSource(); Expression field = randomChild(); Expression order = randomBoolean() ? null : randomChild(); @@ -23,7 +23,7 @@ protected MvSort createTestInstance() { } @Override - protected MvSort mutateInstance(MvSort instance) throws IOException { + protected MvSort innerMutateInstance(MvSort instance) throws IOException { Source source = instance.source(); Expression field = instance.field(); Expression order = instance.order(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSumSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSumSerializationTests.java index 01db7335d7901..9dd23ecf5e258 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSumSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSumSerializationTests.java @@ -13,12 +13,12 @@ public class MvSumSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvSum createTestInstance() { + protected MvSum innerCreateTestInstance() { return new MvSum(randomSource(), randomChild()); } @Override - protected MvSum mutateInstance(MvSum instance) throws IOException { + protected MvSum innerMutateInstance(MvSum instance) throws IOException { return new MvSum(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvZipSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvZipSerializationTests.java index 4b49a1f55340d..61ef09772d872 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvZipSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvZipSerializationTests.java @@ -15,7 +15,7 @@ public class MvZipSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvZip createTestInstance() { + protected MvZip innerCreateTestInstance() { Source source = randomSource(); Expression mvLeft = randomChild(); Expression mvRight = randomChild(); @@ -24,7 +24,7 @@ protected MvZip createTestInstance() { } @Override - protected MvZip mutateInstance(MvZip instance) throws IOException { + protected MvZip innerMutateInstance(MvZip instance) throws IOException { Source source = instance.source(); Expression mvLeft = instance.mvLeft(); Expression mvRight = instance.mvRight(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNotNullSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNotNullSerializationTests.java index a4b42a2145327..4d7270c35149b 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNotNullSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNotNullSerializationTests.java @@ -16,12 +16,12 @@ public class IsNotNullSerializationTests extends AbstractExpressionSerializationTests { @Override - protected IsNotNull createTestInstance() { + protected IsNotNull innerCreateTestInstance() { return new IsNotNull(randomSource(), randomChild()); } @Override - protected IsNotNull mutateInstance(IsNotNull instance) throws IOException { + protected IsNotNull innerMutateInstance(IsNotNull instance) throws IOException { Source source = instance.source(); Expression child = randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild); return new IsNotNull(source, child); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNullSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNullSerializationTests.java index 6202db6db185d..182add9a0ea90 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNullSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNullSerializationTests.java @@ -16,12 +16,12 @@ public class IsNullSerializationTests extends AbstractExpressionSerializationTests { @Override - protected IsNull createTestInstance() { + protected IsNull innerCreateTestInstance() { return new IsNull(randomSource(), randomChild()); } @Override - protected IsNull mutateInstance(IsNull instance) throws IOException { + protected IsNull innerMutateInstance(IsNull instance) throws IOException { Source source = instance.source(); Expression child = randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild); return new IsNull(source, child); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/AbstractBinarySpatialFunctionSerializationTestCase.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/AbstractBinarySpatialFunctionSerializationTestCase.java index b4862c52ef710..1bc10f9fac6e5 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/AbstractBinarySpatialFunctionSerializationTestCase.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/AbstractBinarySpatialFunctionSerializationTestCase.java @@ -19,7 +19,7 @@ public abstract class AbstractBinarySpatialFunctionSerializationTestCase { @Override - protected StX createTestInstance() { + protected StX innerCreateTestInstance() { return new StX(randomSource(), randomChild()); } @Override - protected StX mutateInstance(StX instance) throws IOException { + protected StX innerMutateInstance(StX instance) throws IOException { return new StX(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StYSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StYSerializationTests.java index 5b3edb9cd0a24..6f8d38802a514 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StYSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StYSerializationTests.java @@ -13,12 +13,12 @@ public class StYSerializationTests extends AbstractExpressionSerializationTests { @Override - protected StY createTestInstance() { + protected StY innerCreateTestInstance() { return new StY(randomSource(), randomChild()); } @Override - protected StY mutateInstance(StY instance) throws IOException { + protected StY innerMutateInstance(StY instance) throws IOException { return new StY(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/EndsWithSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/EndsWithSerializationTests.java index 183e39f11b6c3..e73fe8cf6af32 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/EndsWithSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/EndsWithSerializationTests.java @@ -15,7 +15,7 @@ public class EndsWithSerializationTests extends AbstractExpressionSerializationTests { @Override - protected EndsWith createTestInstance() { + protected EndsWith innerCreateTestInstance() { Source source = randomSource(); Expression str = randomChild(); Expression suffix = randomChild(); @@ -23,7 +23,7 @@ protected EndsWith createTestInstance() { } @Override - protected EndsWith mutateInstance(EndsWith instance) throws IOException { + protected EndsWith innerMutateInstance(EndsWith instance) throws IOException { Source source = instance.source(); Expression str = instance.str(); Expression suffix = instance.suffix(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/HashSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/HashSerializationTests.java index f21105c2c8bca..06b45b52e83bb 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/HashSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/HashSerializationTests.java @@ -14,12 +14,12 @@ public class HashSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Hash createTestInstance() { + protected Hash innerCreateTestInstance() { return new Hash(randomSource(), randomChild(), randomChild()); } @Override - protected Hash mutateInstance(Hash instance) throws IOException { + protected Hash innerMutateInstance(Hash instance) throws IOException { return randomBoolean() ? new Hash(instance.source(), mutateExpression(instance.algorithm()), instance.input()) : new Hash(instance.source(), instance.algorithm(), mutateExpression(instance.input())); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/LeftSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/LeftSerializationTests.java index b20d740954ff9..643883bd734a6 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/LeftSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/LeftSerializationTests.java @@ -15,7 +15,7 @@ public class LeftSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Left createTestInstance() { + protected Left innerCreateTestInstance() { Source source = randomSource(); Expression str = randomChild(); Expression length = randomChild(); @@ -23,7 +23,7 @@ protected Left createTestInstance() { } @Override - protected Left mutateInstance(Left instance) throws IOException { + protected Left innerMutateInstance(Left instance) throws IOException { Source source = instance.source(); Expression str = instance.str(); Expression length = instance.length(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/LocateSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/LocateSerializationTests.java index a75fb9d1f772a..ba622a335cc19 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/LocateSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/LocateSerializationTests.java @@ -15,7 +15,7 @@ public class LocateSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Locate createTestInstance() { + protected Locate innerCreateTestInstance() { Source source = randomSource(); Expression str = randomChild(); Expression substr = randomChild(); @@ -24,7 +24,7 @@ protected Locate createTestInstance() { } @Override - protected Locate mutateInstance(Locate instance) throws IOException { + protected Locate innerMutateInstance(Locate instance) throws IOException { Source source = instance.source(); Expression str = instance.str(); Expression substr = instance.substr(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Md5SerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Md5SerializationTests.java index 666e5a3ea5d58..c175b0b123072 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Md5SerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Md5SerializationTests.java @@ -14,12 +14,12 @@ public class Md5SerializationTests extends AbstractExpressionSerializationTests { @Override - protected Md5 createTestInstance() { + protected Md5 innerCreateTestInstance() { return new Md5(randomSource(), randomChild()); } @Override - protected Md5 mutateInstance(Md5 instance) throws IOException { + protected Md5 innerMutateInstance(Md5 instance) throws IOException { return new Md5(instance.source(), mutateExpression(instance.field())); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RLikeListSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RLikeListSerializationTests.java index ff2dd31e2c832..fd48550a7ca20 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RLikeListSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RLikeListSerializationTests.java @@ -20,14 +20,14 @@ public class RLikeListSerializationTests extends AbstractExpressionSerializationTests { @Override - protected RLikeList createTestInstance() { + protected RLikeList innerCreateTestInstance() { Source source = randomSource(); Expression child = randomChild(); return new RLikeList(source, child, generateRandomPatternList()); } @Override - protected RLikeList mutateInstance(RLikeList instance) throws IOException { + protected RLikeList innerMutateInstance(RLikeList instance) throws IOException { Source source = instance.source(); Expression child = instance.field(); List patterns = new ArrayList<>(instance.pattern().patternList()); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RLikeSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RLikeSerializationTests.java index 0316e86ffd1bd..0ae002639e6eb 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RLikeSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RLikeSerializationTests.java @@ -17,7 +17,7 @@ public class RLikeSerializationTests extends AbstractExpressionSerializationTests { @Override - protected RLike createTestInstance() { + protected RLike innerCreateTestInstance() { Source source = randomSource(); Expression child = randomChild(); RLikePattern pattern = new RLikePattern(randomAlphaOfLength(4)); @@ -25,7 +25,7 @@ protected RLike createTestInstance() { } @Override - protected RLike mutateInstance(RLike instance) throws IOException { + protected RLike innerMutateInstance(RLike instance) throws IOException { Source source = instance.source(); Expression child = instance.field(); RLikePattern pattern = instance.pattern(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RepeatSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RepeatSerializationTests.java index 6abcfdc472685..7738c305a48d5 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RepeatSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RepeatSerializationTests.java @@ -15,7 +15,7 @@ public class RepeatSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Repeat createTestInstance() { + protected Repeat innerCreateTestInstance() { Source source = randomSource(); Expression str = randomChild(); Expression number = randomChild(); @@ -23,7 +23,7 @@ protected Repeat createTestInstance() { } @Override - protected Repeat mutateInstance(Repeat instance) throws IOException { + protected Repeat innerMutateInstance(Repeat instance) throws IOException { Source source = instance.source(); Expression str = instance.str(); Expression number = instance.number(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ReplaceSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ReplaceSerializationTests.java index 21e1f51063ceb..22e0b07863ee8 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ReplaceSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ReplaceSerializationTests.java @@ -15,7 +15,7 @@ public class ReplaceSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Replace createTestInstance() { + protected Replace innerCreateTestInstance() { Source source = randomSource(); Expression str = randomChild(); Expression regex = randomChild(); @@ -24,7 +24,7 @@ protected Replace createTestInstance() { } @Override - protected Replace mutateInstance(Replace instance) throws IOException { + protected Replace innerMutateInstance(Replace instance) throws IOException { Source source = instance.source(); Expression str = instance.str(); Expression regex = instance.regex(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RightSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RightSerializationTests.java index 7ed7345910765..10e68d76bf14a 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RightSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RightSerializationTests.java @@ -15,7 +15,7 @@ public class RightSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Right createTestInstance() { + protected Right innerCreateTestInstance() { Source source = randomSource(); Expression str = randomChild(); Expression length = randomChild(); @@ -23,7 +23,7 @@ protected Right createTestInstance() { } @Override - protected Right mutateInstance(Right instance) throws IOException { + protected Right innerMutateInstance(Right instance) throws IOException { Source source = instance.source(); Expression str = instance.str(); Expression length = instance.length(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Sha1SerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Sha1SerializationTests.java index 12c9cc7580de9..923806163f4da 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Sha1SerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Sha1SerializationTests.java @@ -14,12 +14,12 @@ public class Sha1SerializationTests extends AbstractExpressionSerializationTests { @Override - protected Sha1 createTestInstance() { + protected Sha1 innerCreateTestInstance() { return new Sha1(randomSource(), randomChild()); } @Override - protected Sha1 mutateInstance(Sha1 instance) throws IOException { + protected Sha1 innerMutateInstance(Sha1 instance) throws IOException { return new Sha1(instance.source(), mutateExpression(instance.field())); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Sha256SerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Sha256SerializationTests.java index 2f209fef25d36..2c98295bb3274 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Sha256SerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Sha256SerializationTests.java @@ -14,12 +14,12 @@ public class Sha256SerializationTests extends AbstractExpressionSerializationTests { @Override - protected Sha256 createTestInstance() { + protected Sha256 innerCreateTestInstance() { return new Sha256(randomSource(), randomChild()); } @Override - protected Sha256 mutateInstance(Sha256 instance) throws IOException { + protected Sha256 innerMutateInstance(Sha256 instance) throws IOException { return new Sha256(instance.source(), mutateExpression(instance.field())); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/SpaceSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/SpaceSerializationTests.java index bf3b15145e0f3..c0f1283a3f9f5 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/SpaceSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/SpaceSerializationTests.java @@ -15,14 +15,14 @@ public class SpaceSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Space createTestInstance() { + protected Space innerCreateTestInstance() { Source source = randomSource(); Expression number = randomChild(); return new Space(source, number); } @Override - protected Space mutateInstance(Space instance) throws IOException { + protected Space innerMutateInstance(Space instance) throws IOException { Source source = instance.source(); Expression number = instance.field(); number = randomValueOtherThan(number, AbstractExpressionSerializationTests::randomChild); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/SplitSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/SplitSerializationTests.java index bede192c354d1..db35507795217 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/SplitSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/SplitSerializationTests.java @@ -15,7 +15,7 @@ public class SplitSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Split createTestInstance() { + protected Split innerCreateTestInstance() { Source source = randomSource(); Expression str = randomChild(); Expression delim = randomChild(); @@ -23,7 +23,7 @@ protected Split createTestInstance() { } @Override - protected Split mutateInstance(Split instance) throws IOException { + protected Split innerMutateInstance(Split instance) throws IOException { Source source = instance.source(); Expression str = instance.str(); Expression delim = instance.delim(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/StartsWithSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/StartsWithSerializationTests.java index 1b1167879b212..821f9bfc7f1b3 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/StartsWithSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/StartsWithSerializationTests.java @@ -15,7 +15,7 @@ public class StartsWithSerializationTests extends AbstractExpressionSerializationTests { @Override - protected StartsWith createTestInstance() { + protected StartsWith innerCreateTestInstance() { Source source = randomSource(); Expression str = randomChild(); Expression prefix = randomChild(); @@ -23,7 +23,7 @@ protected StartsWith createTestInstance() { } @Override - protected StartsWith mutateInstance(StartsWith instance) throws IOException { + protected StartsWith innerMutateInstance(StartsWith instance) throws IOException { Source source = instance.source(); Expression str = instance.str(); Expression prefix = instance.prefix(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/SubstringSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/SubstringSerializationTests.java index accbed6e8f613..dd0d1d1e9b8a3 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/SubstringSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/SubstringSerializationTests.java @@ -15,7 +15,7 @@ public class SubstringSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Substring createTestInstance() { + protected Substring innerCreateTestInstance() { Source source = randomSource(); Expression str = randomChild(); Expression start = randomChild(); @@ -24,7 +24,7 @@ protected Substring createTestInstance() { } @Override - protected Substring mutateInstance(Substring instance) throws IOException { + protected Substring innerMutateInstance(Substring instance) throws IOException { Source source = instance.source(); Expression str = instance.str(); Expression start = instance.start(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToLowerSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToLowerSerializationTests.java index 5950aeffea79a..a392b32737b99 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToLowerSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToLowerSerializationTests.java @@ -15,12 +15,12 @@ public class ToLowerSerializationTests extends AbstractExpressionSerializationTests { @Override - protected ToLower createTestInstance() { + protected ToLower innerCreateTestInstance() { return new ToLower(randomSource(), randomChild(), configuration()); } @Override - protected ToLower mutateInstance(ToLower instance) throws IOException { + protected ToLower innerMutateInstance(ToLower instance) throws IOException { Source source = instance.source(); Expression child = randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild); return new ToLower(source, child, configuration()); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToUpperSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToUpperSerializationTests.java index 74d891ac2f5cd..8f33c0dcbb215 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToUpperSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToUpperSerializationTests.java @@ -15,12 +15,12 @@ public class ToUpperSerializationTests extends AbstractExpressionSerializationTests { @Override - protected ToUpper createTestInstance() { + protected ToUpper innerCreateTestInstance() { return new ToUpper(randomSource(), randomChild(), configuration()); } @Override - protected ToUpper mutateInstance(ToUpper instance) throws IOException { + protected ToUpper innerMutateInstance(ToUpper instance) throws IOException { Source source = instance.source(); Expression child = randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild); return new ToUpper(source, child, configuration()); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/WildcardLikeListSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/WildcardLikeListSerializationTests.java index f9b903c473547..2d061285d9b22 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/WildcardLikeListSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/WildcardLikeListSerializationTests.java @@ -20,14 +20,14 @@ public class WildcardLikeListSerializationTests extends AbstractExpressionSerializationTests { @Override - protected WildcardLikeList createTestInstance() { + protected WildcardLikeList innerCreateTestInstance() { Source source = randomSource(); Expression child = randomChild(); return new WildcardLikeList(source, child, generateRandomPatternList()); } @Override - protected WildcardLikeList mutateInstance(WildcardLikeList instance) throws IOException { + protected WildcardLikeList innerMutateInstance(WildcardLikeList instance) throws IOException { Source source = instance.source(); Expression child = instance.field(); List patterns = new ArrayList<>(instance.pattern().patternList()); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/WildcardLikeSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/WildcardLikeSerializationTests.java index d1399d5e635c6..c35902506644a 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/WildcardLikeSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/WildcardLikeSerializationTests.java @@ -17,7 +17,7 @@ public class WildcardLikeSerializationTests extends AbstractExpressionSerializationTests { @Override - protected WildcardLike createTestInstance() { + protected WildcardLike innerCreateTestInstance() { Source source = randomSource(); Expression child = randomChild(); WildcardPattern pattern = new WildcardPattern(randomAlphaOfLength(4)); @@ -25,7 +25,7 @@ protected WildcardLike createTestInstance() { } @Override - protected WildcardLike mutateInstance(WildcardLike instance) throws IOException { + protected WildcardLike innerMutateInstance(WildcardLike instance) throws IOException { Source source = instance.source(); Expression child = instance.field(); WildcardPattern pattern = instance.pattern(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/AbstractArithmeticSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/AbstractArithmeticSerializationTests.java index 81860addf1c5e..0e141273c812c 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/AbstractArithmeticSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/AbstractArithmeticSerializationTests.java @@ -18,12 +18,12 @@ public abstract class AbstractArithmeticSerializationTests { @Override - protected In createTestInstance() { + protected In innerCreateTestInstance() { Source source = randomSource(); Expression value = randomChild(); List list = randomList(10, AbstractExpressionSerializationTests::randomChild); @@ -24,7 +24,7 @@ protected In createTestInstance() { } @Override - protected In mutateInstance(In instance) throws IOException { + protected In innerMutateInstance(In instance) throws IOException { Source source = instance.source(); Expression value = instance.value(); List list = instance.list(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InsensitiveEqualsSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InsensitiveEqualsSerializationTests.java index 7ca1e27ba510a..fb374f2d23e65 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InsensitiveEqualsSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InsensitiveEqualsSerializationTests.java @@ -14,12 +14,12 @@ public class InsensitiveEqualsSerializationTests extends AbstractExpressionSerializationTests { @Override - protected final InsensitiveEquals createTestInstance() { + protected final InsensitiveEquals innerCreateTestInstance() { return new InsensitiveEquals(randomSource(), randomChild(), randomChild()); } @Override - protected final InsensitiveEquals mutateInstance(InsensitiveEquals instance) throws IOException { + protected final InsensitiveEquals innerMutateInstance(InsensitiveEquals instance) throws IOException { Expression left = instance.left(); Expression right = instance.right(); if (randomBoolean()) { From 4771dbac5b938d6d403bdcd7af6eef75113ed532 Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Thu, 18 Sep 2025 19:22:22 +0200 Subject: [PATCH 12/38] Fix most csv tests --- .../xpack/esql/core/expression/Alias.java | 4 ++ .../xpack/esql/SerializationTestUtils.java | 43 +++++++++++++++---- 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Alias.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Alias.java index a3ab13621041f..22b0aa78ae282 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Alias.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Alias.java @@ -72,6 +72,10 @@ public Alias(StreamInput in) throws IOException { ); } + public Alias withId(NameId id) { + return new Alias(source(), name(), child(), id, synthetic()); + } + @Override public void writeTo(StreamOutput out) throws IOException { Source.EMPTY.writeTo(out); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/SerializationTestUtils.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/SerializationTestUtils.java index 3b1b2b107de54..e95dfc41afb69 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/SerializationTestUtils.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/SerializationTestUtils.java @@ -26,14 +26,17 @@ import org.elasticsearch.index.query.WildcardQueryBuilder; import org.elasticsearch.search.vectors.KnnVectorQueryBuilder; import org.elasticsearch.test.EqualsHashCodeTestUtils; +import org.elasticsearch.xpack.esql.core.expression.Alias; import org.elasticsearch.xpack.esql.core.expression.Attribute; import org.elasticsearch.xpack.esql.core.expression.Expression; import org.elasticsearch.xpack.esql.core.expression.NameId; +import org.elasticsearch.xpack.esql.core.expression.NamedExpression; import org.elasticsearch.xpack.esql.expression.ExpressionWritables; import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput; import org.elasticsearch.xpack.esql.io.stream.PlanStreamOutput; import org.elasticsearch.xpack.esql.plan.PlanWritables; import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan; +import org.elasticsearch.xpack.esql.plan.physical.FragmentExec; import org.elasticsearch.xpack.esql.plan.physical.PhysicalPlan; import org.elasticsearch.xpack.esql.querydsl.query.SingleValueQuery; import org.elasticsearch.xpack.esql.session.Configuration; @@ -44,6 +47,35 @@ import java.util.List; public class SerializationTestUtils { + private static final NameId DUMMY_ID = new NameId(); + + @SuppressWarnings("unchecked") + public static E ignoreIds(E expression) { + return (E) expression.transformDown( + NamedExpression.class, + ne -> ne instanceof Alias alias ? alias.withId(DUMMY_ID) : ne instanceof Attribute attr ? attr.withId(DUMMY_ID) : ne + ); + } + + private static LogicalPlan ignoreIds(LogicalPlan plan) { + return plan.transformExpressionsDown( + NamedExpression.class, + ne -> ne instanceof Alias alias ? alias.withId(DUMMY_ID) : ne instanceof Attribute attr ? attr.withId(DUMMY_ID) : ne + ); + } + + private static PhysicalPlan ignoreIds(PhysicalPlan plan) { + PhysicalPlan ignoredInPhysicalNodes = plan.transformExpressionsDown( + NamedExpression.class, + ne -> ne instanceof Alias alias ? alias.withId(DUMMY_ID) : ne instanceof Attribute attr ? attr.withId(DUMMY_ID) : ne + ); + return ignoredInPhysicalNodes.transformDown(FragmentExec.class, fragmentExec -> { + LogicalPlan fragment = fragmentExec.fragment(); + LogicalPlan ignoredInFragment = ignoreIds(fragment); + return fragmentExec.withFragment(ignoredInFragment); + }); + } + public static void assertSerialization(PhysicalPlan plan) { assertSerialization(plan, EsqlTestUtils.TEST_CFG); } @@ -55,25 +87,18 @@ public static void assertSerialization(PhysicalPlan plan, Configuration configur in -> in.readNamedWriteable(PhysicalPlan.class), configuration ); - EqualsHashCodeTestUtils.checkEqualsAndHashCode(plan, unused -> deserPlan); + EqualsHashCodeTestUtils.checkEqualsAndHashCode(ignoreIds(plan), unused -> ignoreIds(deserPlan)); } public static void assertSerialization(LogicalPlan plan) { var deserPlan = serializeDeserialize(plan, PlanStreamOutput::writeNamedWriteable, in -> in.readNamedWriteable(LogicalPlan.class)); - EqualsHashCodeTestUtils.checkEqualsAndHashCode(plan, unused -> deserPlan); + EqualsHashCodeTestUtils.checkEqualsAndHashCode(ignoreIds(plan), unused -> ignoreIds(deserPlan)); } public static void assertSerialization(Expression expression) { assertSerialization(expression, EsqlTestUtils.TEST_CFG); } - private static final NameId DUMMY_ID = new NameId(); - - @SuppressWarnings("unchecked") - public static E ignoreIds(E expression) { - return (E) expression.transformDown(Attribute.class, attr -> attr.withId(DUMMY_ID)); - } - public static void assertSerialization(Expression expression, Configuration configuration) { Expression deserExpression = serializeDeserialize( expression, From 9db6528bc158654cd3e965edb5b8c35059497813 Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Tue, 23 Sep 2025 16:29:29 +0200 Subject: [PATCH 13/38] Add comment to semanticEquals --- .../xpack/esql/core/expression/Expression.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Expression.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Expression.java index 68438a95f7dda..d283932d69f9b 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Expression.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Expression.java @@ -182,9 +182,16 @@ protected Expression canonicalize() { /** * Whether this expression means the same as {@code other}, even if they are not exactly equal. - * For example, {@code a + b} and {@code b + a} are not equal, but they are semantically equivalent. + * For example, {@code a + b} and {@code b + a} are not equal, but they are semantically equal. *

- * If two expressions are equal, they are also semantically equal, but the reverse is not true. + * If two expressions are equal, they are also semantically equal, but the reverse is generally not true. + *

+ * Caution! {@link Attribute#semanticEquals(Expression)} is especially lenient, as it considers two attributes + * with the same {@link NameId} to be semantically equal, even if they have different data types or are represented using different + * classes. + *

+ * But this doesn't extend to expressions containing attributes as children, which is pretty inconsistent. + * We have to revisit this before using {@link #semanticEquals} in more places. */ public boolean semanticEquals(Expression other) { return canonical().equals(other.canonical()); From 782067b3fef5f79cb3793c562bf4cd5cd5ab940b Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Tue, 23 Sep 2025 16:36:30 +0200 Subject: [PATCH 14/38] Fix IncreaseSerializationTests --- .../function/aggregate/IncreaseSerializationTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/IncreaseSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/IncreaseSerializationTests.java index 76605f1d66243..52e15d939d51f 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/IncreaseSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/IncreaseSerializationTests.java @@ -15,7 +15,7 @@ public class IncreaseSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Increase createTestInstance() { + protected Increase innerCreateTestInstance() { Source source = randomSource(); Expression field = randomChild(); Expression timestamp = randomChild(); @@ -23,7 +23,7 @@ protected Increase createTestInstance() { } @Override - protected Increase mutateInstance(Increase instance) throws IOException { + protected Increase innerMutateInstance(Increase instance) throws IOException { Source source = randomSource(); Expression field = instance.field(); Expression timestamp = instance.timestamp(); From 6b7fa4ec648275eb2f2288290af284c143c53577 Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Tue, 23 Sep 2025 16:52:33 +0200 Subject: [PATCH 15/38] Fix attribute tests --- .../expression/function/AbstractAttributeTestCase.java | 9 +++++++++ .../esql/expression/function/FieldAttributeTests.java | 8 +++++--- .../esql/expression/function/MetadataAttributeTests.java | 8 +++++--- .../expression/function/ReferenceAttributeTests.java | 8 +++++--- .../expression/function/UnsupportedAttributeTests.java | 7 ++++--- 5 files changed, 28 insertions(+), 12 deletions(-) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractAttributeTestCase.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractAttributeTestCase.java index d59e309790ad2..0ec457672cc87 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractAttributeTestCase.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractAttributeTestCase.java @@ -7,6 +7,7 @@ package org.elasticsearch.xpack.esql.expression.function; +import org.elasticsearch.TransportVersion; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; @@ -63,6 +64,14 @@ protected final Writeable.Reader instanceReader() { }; } + @Override + protected ExtraAttribute copyInstance(ExtraAttribute instance, TransportVersion version) throws IOException { + ExtraAttribute copied = super.copyInstance(instance, version); + // In production, we assign new name ids when deserializing a plan, as name ids are globally unique on a node. + // In tests we don't do that because it would make equality testing impossible, so we just copy the original id. + return new ExtraAttribute(copied.a.withId(instance.a.id())); + } + /** * Adds extra equality comparisons needed for testing round trips of {@link Attribute}. */ diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/FieldAttributeTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/FieldAttributeTests.java index 0ac170f6c3cab..0c0c65c5b1452 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/FieldAttributeTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/FieldAttributeTests.java @@ -47,15 +47,17 @@ protected FieldAttribute mutate(FieldAttribute instance) { String qualifier = instance.qualifier(); EsField field = instance.field(); Nullability nullability = instance.nullable(); + NameId id = instance.id(); boolean synthetic = instance.synthetic(); - switch (between(0, 5)) { + switch (between(0, 6)) { case 0 -> parentName = randomValueOtherThan(parentName, () -> randomBoolean() ? null : randomAlphaOfLength(2)); case 1 -> qualifier = randomAlphaOfLength(qualifier == null ? 3 : qualifier.length() + 1); case 2 -> name = randomAlphaOfLength(name.length() + 1); case 3 -> field = randomValueOtherThan(field, () -> AbstractEsFieldTypeTests.randomAnyEsField(3)); case 4 -> nullability = randomValueOtherThan(nullability, () -> randomFrom(Nullability.values())); - case 5 -> synthetic = false == synthetic; + case 5 -> id = new NameId(); + case 6 -> synthetic = false == synthetic; } - return new FieldAttribute(source, parentName, qualifier, name, field, nullability, new NameId(), synthetic); + return new FieldAttribute(source, parentName, qualifier, name, field, nullability, id, synthetic); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/MetadataAttributeTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/MetadataAttributeTests.java index c8c7c86c91778..119bf5306ef38 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/MetadataAttributeTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/MetadataAttributeTests.java @@ -36,14 +36,16 @@ protected MetadataAttribute mutate(MetadataAttribute instance) { DataType type = instance.dataType(); Nullability nullability = instance.nullable(); boolean synthetic = instance.synthetic(); + NameId id = instance.id(); boolean searchable = instance.searchable(); - switch (between(0, 4)) { + switch (between(0, 5)) { case 0 -> name = randomAlphaOfLength(name.length() + 1); case 1 -> type = randomValueOtherThan(type, () -> randomFrom(DataType.types())); case 2 -> nullability = randomValueOtherThan(nullability, () -> randomFrom(Nullability.values())); case 3 -> synthetic = false == synthetic; - case 4 -> searchable = false == searchable; + case 4 -> id = new NameId(); + case 5 -> searchable = false == searchable; } - return new MetadataAttribute(source, name, type, nullability, new NameId(), synthetic, searchable); + return new MetadataAttribute(source, name, type, nullability, id, synthetic, searchable); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/ReferenceAttributeTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/ReferenceAttributeTests.java index 1883c52ce614e..83a4b0340524d 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/ReferenceAttributeTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/ReferenceAttributeTests.java @@ -38,14 +38,16 @@ protected ReferenceAttribute mutate(ReferenceAttribute instance) { String name = instance.name(); DataType type = instance.dataType(); Nullability nullability = instance.nullable(); + NameId id = instance.id(); boolean synthetic = instance.synthetic(); - switch (between(0, 4)) { + switch (between(0, 5)) { case 0 -> qualifier = randomAlphaOfLength(qualifier == null ? 3 : qualifier.length() + 1); case 1 -> name = randomAlphaOfLength(name.length() + 1); case 2 -> type = randomValueOtherThan(type, () -> randomFrom(DataType.types())); case 3 -> nullability = randomValueOtherThan(nullability, () -> randomFrom(Nullability.values())); - case 4 -> synthetic = false == synthetic; + case 4 -> id = new NameId(); + case 5 -> synthetic = false == synthetic; } - return new ReferenceAttribute(source, qualifier, name, type, nullability, new NameId(), synthetic); + return new ReferenceAttribute(source, qualifier, name, type, nullability, id, synthetic); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttributeTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttributeTests.java index e02a04b90dfd2..243a14331a308 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttributeTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttributeTests.java @@ -34,13 +34,14 @@ protected UnsupportedAttribute mutate(UnsupportedAttribute instance) { String name = instance.name(); UnsupportedEsField field = instance.field(); String customMessage = instance.hasCustomMessage() ? instance.unresolvedMessage() : null; - switch (between(0, 3)) { + NameId id = instance.id(); + switch (between(0, 4)) { case 0 -> qualifier = randomAlphaOfLength(qualifier == null ? 3 : qualifier.length() + 1); case 1 -> name = randomAlphaOfLength(name.length() + 1); case 2 -> field = randomValueOtherThan(field, () -> UnsupportedEsFieldTests.randomUnsupportedEsField(4)); case 3 -> customMessage = randomValueOtherThan(customMessage, () -> randomBoolean() ? null : randomAlphaOfLength(9)); - default -> throw new IllegalArgumentException(); + case 4 -> id = new NameId(); } - return new UnsupportedAttribute(source, qualifier, name, field, customMessage, new NameId()); + return new UnsupportedAttribute(source, qualifier, name, field, customMessage, id); } } From 09cd30ae3a9e9e711a82f0037db423e9e0f232ea Mon Sep 17 00:00:00 2001 From: elasticsearchmachine Date: Tue, 23 Sep 2025 15:00:34 +0000 Subject: [PATCH 16/38] [CI] Update transport version definitions --- server/src/main/resources/transport/upper_bounds/9.2.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/resources/transport/upper_bounds/9.2.csv b/server/src/main/resources/transport/upper_bounds/9.2.csv index 6e7d51d3d3020..b1209b927d8a5 100644 --- a/server/src/main/resources/transport/upper_bounds/9.2.csv +++ b/server/src/main/resources/transport/upper_bounds/9.2.csv @@ -1 +1 @@ -security_stats_endpoint,9168000 +inference_api_openai_embeddings_headers,9169000 From 5f4cd4f29f73aefc4ea36e9dbee54e8722446058 Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Thu, 25 Sep 2025 12:18:55 +0200 Subject: [PATCH 17/38] Actually assert name ids in serialization tests --- .../xpack/esql/core/expression/NameId.java | 8 +++ .../xpack/esql/io/stream/PlanStreamInput.java | 15 ++++- .../plan/AbstractNodeSerializationTests.java | 58 ++++++++++++++++++- 3 files changed, 78 insertions(+), 3 deletions(-) diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/NameId.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/NameId.java index 2ee600eb21e0b..859f46e26ff18 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/NameId.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/NameId.java @@ -31,6 +31,14 @@ public NameId() { this.id = COUNTER.incrementAndGet(); } + /** + * For testing only. Otherwise, we only use name ids for equality checks and de-/serialization and don't rely on their exact + * representation as long values. + */ + public long id() { + return id; + } + @Override public int hashCode() { return Long.hashCode(id); diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/io/stream/PlanStreamInput.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/io/stream/PlanStreamInput.java index ca24f1ad322a8..1ba88bace8739 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/io/stream/PlanStreamInput.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/io/stream/PlanStreamInput.java @@ -51,13 +51,17 @@ public final class PlanStreamInput extends NamedWriteableAwareStreamInput * and increment an id from the global counter, thus avoiding potential conflicts between the * id in the stream and id's during local re-planning on the data node. */ - static final class NameIdMapper implements LongFunction { + public static class NameIdMapper implements LongFunction { final Map seen = new HashMap<>(); @Override public NameId apply(long streamNameId) { return seen.computeIfAbsent(streamNameId, k -> new NameId()); } + + protected Map seen() { + return seen; + } } private final Map cachedBlocks = new HashMap<>(); @@ -74,9 +78,16 @@ public NameId apply(long streamNameId) { private final Configuration configuration; public PlanStreamInput(StreamInput streamInput, NamedWriteableRegistry namedWriteableRegistry, Configuration configuration) { + this(streamInput, namedWriteableRegistry, configuration, new NameIdMapper()); + } + + /** + * Public for testing, only. Use {@link #PlanStreamInput(StreamInput, NamedWriteableRegistry, Configuration)} in production. + */ + public PlanStreamInput(StreamInput streamInput, NamedWriteableRegistry namedWriteableRegistry, Configuration configuration, NameIdMapper nameIdFunction) { super(streamInput, namedWriteableRegistry); this.configuration = configuration; - this.nameIdFunction = new NameIdMapper(); + this.nameIdFunction = nameIdFunction; } public Configuration configuration() throws IOException { diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plan/AbstractNodeSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plan/AbstractNodeSerializationTests.java index 998b895a4e005..3bd9c498e054a 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plan/AbstractNodeSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plan/AbstractNodeSerializationTests.java @@ -10,11 +10,18 @@ import org.elasticsearch.TransportVersion; import org.elasticsearch.test.AbstractWireTestCase; import org.elasticsearch.xpack.esql.core.expression.Attribute; +import org.elasticsearch.xpack.esql.core.expression.Expression; +import org.elasticsearch.xpack.esql.core.expression.NameId; +import org.elasticsearch.xpack.esql.core.expression.NamedExpression; import org.elasticsearch.xpack.esql.core.tree.Node; import org.elasticsearch.xpack.esql.core.tree.Source; import org.elasticsearch.xpack.esql.expression.function.FieldAttributeTests; import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput; import org.elasticsearch.xpack.esql.io.stream.PlanStreamOutput; +import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan; +import org.elasticsearch.xpack.esql.plan.logical.Lookup; +import org.elasticsearch.xpack.esql.plan.physical.FragmentExec; +import org.elasticsearch.xpack.esql.plan.physical.PhysicalPlan; import org.elasticsearch.xpack.esql.session.Configuration; import org.junit.Before; @@ -50,14 +57,63 @@ public static List randomFieldAttributes(int min, int max, boolean on return randomList(min, max, () -> FieldAttributeTests.createFieldAttribute(0, onlyRepresentable)); } + /** + * Reuses existing {@link NameId}s when deserializing a tree, rather than creating new ones all the time. This makes testing for + * equality easier because deserialized nodes will have the same {@link NameId} instances as the original ones. + */ + private static class TestIdsNameMapper extends PlanStreamInput.NameIdMapper { + private void add(NameId id) { + seen().computeIfAbsent(id.id(), unused -> id); + } + + public void collectNameIds(Node node) { + if (node instanceof Expression e) { + e.forEachDown( + NamedExpression.class, + ne -> add(ne.id()) + ); + return; + } + + if (node instanceof QueryPlan p) { + p.forEachExpressionDown( + NamedExpression.class, + ne -> add(ne.id()) + ); + } + + if (node instanceof LogicalPlan lp) { + lp.forEachDown(Lookup.class, lookup -> { + if (lookup.localRelation() != null) { + // The LocalRelation is not seen as part of the plan tree so we need to explicitly collect its NameIds. + collectNameIds(lookup.localRelation()); + } + }); + } + + if (node instanceof PhysicalPlan p) { + p.forEachDown(FragmentExec.class, fragmentExec -> { + // The fragment is not seen as part of the plan tree so we need to explicitly collect its NameIds. + LogicalPlan fragment = fragmentExec.fragment(); + collectNameIds(fragment); + }); + } + } + } + + + @Override protected T copyInstance(T instance, TransportVersion version) throws IOException { + TestIdsNameMapper idsNameMapper = new TestIdsNameMapper(); + idsNameMapper.collectNameIds(instance); + return copyInstance( instance, getNamedWriteableRegistry(), (out, v) -> new PlanStreamOutput(out, configuration()).writeNamedWriteable(v), in -> { - PlanStreamInput pin = new PlanStreamInput(in, in.namedWriteableRegistry(), configuration()); + PlanStreamInput pin = new PlanStreamInput(in, in.namedWriteableRegistry(), configuration(), idsNameMapper); @SuppressWarnings("unchecked") T deser = (T) pin.readNamedWriteable(categoryClass()); if (alwaysEmptySource()) { From 9dcbd410769740d0edd244a1c8db8aebb6ac68f8 Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Thu, 25 Sep 2025 12:23:44 +0200 Subject: [PATCH 18/38] WIP: fix serialization tests --- .../org/elasticsearch/xpack/esql/SerializationTestUtils.java | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/SerializationTestUtils.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/SerializationTestUtils.java index e95dfc41afb69..87c90b4ee371b 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/SerializationTestUtils.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/SerializationTestUtils.java @@ -49,6 +49,7 @@ public class SerializationTestUtils { private static final NameId DUMMY_ID = new NameId(); + // NOCOMMIT: do not use the ignoreIds methods; instead, fix ids during deserialization @SuppressWarnings("unchecked") public static E ignoreIds(E expression) { return (E) expression.transformDown( From 6ff02836e17661096ec92ee283b5ed11116998d6 Mon Sep 17 00:00:00 2001 From: elasticsearchmachine Date: Thu, 25 Sep 2025 10:49:37 +0000 Subject: [PATCH 19/38] [CI] Auto commit changes from spotless --- .../xpack/esql/io/stream/PlanStreamInput.java | 7 ++++++- .../esql/plan/AbstractNodeSerializationTests.java | 12 ++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/io/stream/PlanStreamInput.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/io/stream/PlanStreamInput.java index 1ba88bace8739..daae00fae7ece 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/io/stream/PlanStreamInput.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/io/stream/PlanStreamInput.java @@ -84,7 +84,12 @@ public PlanStreamInput(StreamInput streamInput, NamedWriteableRegistry namedWrit /** * Public for testing, only. Use {@link #PlanStreamInput(StreamInput, NamedWriteableRegistry, Configuration)} in production. */ - public PlanStreamInput(StreamInput streamInput, NamedWriteableRegistry namedWriteableRegistry, Configuration configuration, NameIdMapper nameIdFunction) { + public PlanStreamInput( + StreamInput streamInput, + NamedWriteableRegistry namedWriteableRegistry, + Configuration configuration, + NameIdMapper nameIdFunction + ) { super(streamInput, namedWriteableRegistry); this.configuration = configuration; this.nameIdFunction = nameIdFunction; diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plan/AbstractNodeSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plan/AbstractNodeSerializationTests.java index 3bd9c498e054a..21c92d786b6d6 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plan/AbstractNodeSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plan/AbstractNodeSerializationTests.java @@ -68,18 +68,12 @@ private void add(NameId id) { public void collectNameIds(Node node) { if (node instanceof Expression e) { - e.forEachDown( - NamedExpression.class, - ne -> add(ne.id()) - ); + e.forEachDown(NamedExpression.class, ne -> add(ne.id())); return; } if (node instanceof QueryPlan p) { - p.forEachExpressionDown( - NamedExpression.class, - ne -> add(ne.id()) - ); + p.forEachExpressionDown(NamedExpression.class, ne -> add(ne.id())); } if (node instanceof LogicalPlan lp) { @@ -101,8 +95,6 @@ public void collectNameIds(Node node) { } } - - @Override protected T copyInstance(T instance, TransportVersion version) throws IOException { TestIdsNameMapper idsNameMapper = new TestIdsNameMapper(); From 1e6b100aae8116c8a3d5f387b3a229b7884cda8f Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Fri, 26 Sep 2025 14:12:18 +0200 Subject: [PATCH 20/38] Simplify de-/serialization tests Just re-use the name ids, that prevents having to address that they may be mapped differently in the deserialized plan. --- .../xpack/esql/SerializationTestUtils.java | 96 ++++++++----- .../AbstractExpressionSerializationTests.java | 24 ---- ...AbstractUnaryScalarSerializationTests.java | 4 +- .../AbstractVarargsSerializationTests.java | 4 +- .../expression/LiteralSerializationTests.java | 4 +- .../expression/OrderSerializationTests.java | 4 +- .../function/AbstractAttributeTestCase.java | 130 ------------------ .../function/FieldAttributeTests.java | 7 +- .../function/MetadataAttributeTests.java | 13 +- .../function/ReferenceAttributeTests.java | 7 +- .../function/UnsupportedAttributeTests.java | 7 +- .../aggregate/AbsentSerializationTests.java | 4 +- .../aggregate/AvgSerializationTests.java | 4 +- .../CountDistinctSerializationTests.java | 4 +- .../aggregate/CountSerializationTests.java | 4 +- .../aggregate/FirstSerializationTests.java | 4 +- .../aggregate/IncreaseSerializationTests.java | 4 +- .../aggregate/LastSerializationTests.java | 4 +- .../aggregate/MaxSerializationTests.java | 4 +- ...anAbsoluteDeviationSerializationTests.java | 4 +- .../aggregate/MedianSerializationTests.java | 4 +- .../aggregate/MinSerializationTests.java | 4 +- .../PercentileSerializationTests.java | 4 +- .../aggregate/PresentSerializationTests.java | 4 +- .../aggregate/RateSerializationTests.java | 4 +- .../aggregate/SampleSerializationTests.java | 4 +- .../SpatialCentroidSerializationTests.java | 4 +- .../SpatialExtentSerializationTests.java | 4 +- .../aggregate/StdDevSerializationTests.java | 4 +- .../aggregate/SumSerializationTests.java | 4 +- .../aggregate/TopSerializationTests.java | 4 +- .../aggregate/ValuesSerializationTests.java | 4 +- .../WeightedAvgSerializationTests.java | 4 +- .../grouping/BucketSerializationTests.java | 4 +- .../scalar/AndSerializationTests.java | 4 +- .../scalar/NotSerializationTests.java | 4 +- .../function/scalar/OrSerializationTests.java | 4 +- .../date/DateDiffSerializationTests.java | 4 +- .../date/DateExtractSerializationTests.java | 4 +- .../date/DateFormatSerializationTests.java | 4 +- .../date/DateParseSerializationTests.java | 4 +- .../date/DateTruncSerializationTests.java | 4 +- .../date/DayNameSerializationTests.java | 4 +- .../date/MonthNameSerializationTests.java | 4 +- .../scalar/date/NowSerializationTests.java | 4 +- .../ip/CIDRMatchSerializationTests.java | 4 +- .../scalar/ip/IpPrefixSerializationTests.java | 4 +- .../scalar/math/Atan2SerializationTests.java | 4 +- .../scalar/math/ESerializationTests.java | 4 +- .../scalar/math/HypotSerializationTests.java | 4 +- .../scalar/math/LogSerializationTests.java | 4 +- .../scalar/math/PiSerializationTests.java | 4 +- .../scalar/math/PowSerializationTests.java | 4 +- .../scalar/math/RoundSerializationTests.java | 4 +- .../math/RoundToSerializationTests.java | 4 +- .../scalar/math/TauSerializationTests.java | 4 +- .../MvAppendSerializationTests.java | 4 +- .../multivalue/MvAvgSerializationTests.java | 4 +- .../MvConcatSerializationTests.java | 4 +- .../MvContainsSerializationTests.java | 4 +- .../multivalue/MvCountSerializationTests.java | 4 +- .../MvDedupeSerializationTests.java | 4 +- .../multivalue/MvFirstSerializationTests.java | 4 +- .../multivalue/MvLastSerializationTests.java | 4 +- .../multivalue/MvMaxSerializationTests.java | 4 +- ...anAbsoluteDeviationSerializationTests.java | 4 +- .../MvMedianSerializationTests.java | 4 +- .../multivalue/MvMinSerializationTests.java | 4 +- ...vPSeriesWeightedSumSerializationTests.java | 4 +- .../multivalue/MvSliceSerializationTests.java | 4 +- .../multivalue/MvSortSerializationTests.java | 4 +- .../multivalue/MvSumSerializationTests.java | 4 +- .../multivalue/MvZipSerializationTests.java | 4 +- .../nulls/IsNotNullSerializationTests.java | 4 +- .../nulls/IsNullSerializationTests.java | 4 +- ...ySpatialFunctionSerializationTestCase.java | 4 +- .../scalar/spatial/StXSerializationTests.java | 4 +- .../scalar/spatial/StYSerializationTests.java | 4 +- .../string/EndsWithSerializationTests.java | 4 +- .../scalar/string/HashSerializationTests.java | 4 +- .../scalar/string/LeftSerializationTests.java | 4 +- .../string/LocateSerializationTests.java | 4 +- .../scalar/string/Md5SerializationTests.java | 4 +- .../string/RLikeListSerializationTests.java | 4 +- .../string/RLikeSerializationTests.java | 4 +- .../string/RepeatSerializationTests.java | 4 +- .../string/ReplaceSerializationTests.java | 4 +- .../string/RightSerializationTests.java | 4 +- .../scalar/string/Sha1SerializationTests.java | 4 +- .../string/Sha256SerializationTests.java | 4 +- .../string/SpaceSerializationTests.java | 4 +- .../string/SplitSerializationTests.java | 4 +- .../string/StartsWithSerializationTests.java | 4 +- .../string/SubstringSerializationTests.java | 4 +- .../string/ToLowerSerializationTests.java | 4 +- .../string/ToUpperSerializationTests.java | 4 +- .../WildcardLikeListSerializationTests.java | 4 +- .../WildcardLikeSerializationTests.java | 4 +- .../AbstractArithmeticSerializationTests.java | 4 +- .../AbstractComparisonSerializationTests.java | 4 +- .../comparison/InSerializationTests.java | 4 +- .../InsensitiveEqualsSerializationTests.java | 4 +- .../plan/AbstractNodeSerializationTests.java | 48 +------ 103 files changed, 271 insertions(+), 441 deletions(-) delete mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractAttributeTestCase.java diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/SerializationTestUtils.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/SerializationTestUtils.java index 87c90b4ee371b..e63d2f64f5ec8 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/SerializationTestUtils.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/SerializationTestUtils.java @@ -26,16 +26,17 @@ import org.elasticsearch.index.query.WildcardQueryBuilder; import org.elasticsearch.search.vectors.KnnVectorQueryBuilder; import org.elasticsearch.test.EqualsHashCodeTestUtils; -import org.elasticsearch.xpack.esql.core.expression.Alias; -import org.elasticsearch.xpack.esql.core.expression.Attribute; import org.elasticsearch.xpack.esql.core.expression.Expression; import org.elasticsearch.xpack.esql.core.expression.NameId; import org.elasticsearch.xpack.esql.core.expression.NamedExpression; +import org.elasticsearch.xpack.esql.core.tree.Node; import org.elasticsearch.xpack.esql.expression.ExpressionWritables; import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput; import org.elasticsearch.xpack.esql.io.stream.PlanStreamOutput; import org.elasticsearch.xpack.esql.plan.PlanWritables; +import org.elasticsearch.xpack.esql.plan.QueryPlan; import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan; +import org.elasticsearch.xpack.esql.plan.logical.Lookup; import org.elasticsearch.xpack.esql.plan.physical.FragmentExec; import org.elasticsearch.xpack.esql.plan.physical.PhysicalPlan; import org.elasticsearch.xpack.esql.querydsl.query.SingleValueQuery; @@ -47,36 +48,6 @@ import java.util.List; public class SerializationTestUtils { - private static final NameId DUMMY_ID = new NameId(); - - // NOCOMMIT: do not use the ignoreIds methods; instead, fix ids during deserialization - @SuppressWarnings("unchecked") - public static E ignoreIds(E expression) { - return (E) expression.transformDown( - NamedExpression.class, - ne -> ne instanceof Alias alias ? alias.withId(DUMMY_ID) : ne instanceof Attribute attr ? attr.withId(DUMMY_ID) : ne - ); - } - - private static LogicalPlan ignoreIds(LogicalPlan plan) { - return plan.transformExpressionsDown( - NamedExpression.class, - ne -> ne instanceof Alias alias ? alias.withId(DUMMY_ID) : ne instanceof Attribute attr ? attr.withId(DUMMY_ID) : ne - ); - } - - private static PhysicalPlan ignoreIds(PhysicalPlan plan) { - PhysicalPlan ignoredInPhysicalNodes = plan.transformExpressionsDown( - NamedExpression.class, - ne -> ne instanceof Alias alias ? alias.withId(DUMMY_ID) : ne instanceof Attribute attr ? attr.withId(DUMMY_ID) : ne - ); - return ignoredInPhysicalNodes.transformDown(FragmentExec.class, fragmentExec -> { - LogicalPlan fragment = fragmentExec.fragment(); - LogicalPlan ignoredInFragment = ignoreIds(fragment); - return fragmentExec.withFragment(ignoredInFragment); - }); - } - public static void assertSerialization(PhysicalPlan plan) { assertSerialization(plan, EsqlTestUtils.TEST_CFG); } @@ -88,12 +59,12 @@ public static void assertSerialization(PhysicalPlan plan, Configuration configur in -> in.readNamedWriteable(PhysicalPlan.class), configuration ); - EqualsHashCodeTestUtils.checkEqualsAndHashCode(ignoreIds(plan), unused -> ignoreIds(deserPlan)); + EqualsHashCodeTestUtils.checkEqualsAndHashCode(plan, unused -> deserPlan); } public static void assertSerialization(LogicalPlan plan) { var deserPlan = serializeDeserialize(plan, PlanStreamOutput::writeNamedWriteable, in -> in.readNamedWriteable(LogicalPlan.class)); - EqualsHashCodeTestUtils.checkEqualsAndHashCode(ignoreIds(plan), unused -> ignoreIds(deserPlan)); + EqualsHashCodeTestUtils.checkEqualsAndHashCode(plan, unused -> deserPlan); } public static void assertSerialization(Expression expression) { @@ -107,7 +78,7 @@ public static void assertSerialization(Expression expression, Configuration conf in -> in.readNamedWriteable(Expression.class), configuration ); - EqualsHashCodeTestUtils.checkEqualsAndHashCode(ignoreIds(expression), unused -> ignoreIds(deserExpression)); + EqualsHashCodeTestUtils.checkEqualsAndHashCode(expression, unused -> deserExpression); } public static T serializeDeserialize(T orig, Serializer serializer, Deserializer deserializer) { @@ -118,11 +89,16 @@ public static T serializeDeserialize(T orig, Serializer serializer, Deser try (BytesStreamOutput out = new BytesStreamOutput()) { PlanStreamOutput planStreamOutput = new PlanStreamOutput(out, config); serializer.write(planStreamOutput, orig); + + PlanStreamInput.NameIdMapper nameIdMapper = orig instanceof Node node + // For trees, reuse the NameIds to make equality testing easier + ? new TestNameIdMapper(node) + : new PlanStreamInput.NameIdMapper(); StreamInput in = new NamedWriteableAwareStreamInput( ByteBufferStreamInput.wrap(BytesReference.toBytes(out.bytes())), writableRegistry() ); - PlanStreamInput planStreamInput = new PlanStreamInput(in, in.namedWriteableRegistry(), config); + PlanStreamInput planStreamInput = new PlanStreamInput(in, in.namedWriteableRegistry(), config, nameIdMapper); return deserializer.read(planStreamInput); } catch (IOException e) { throw new UncheckedIOException(e); @@ -160,4 +136,52 @@ public static NamedWriteableRegistry writableRegistry() { ); return new NamedWriteableRegistry(entries); } + + /** + * Reuses existing {@link NameId}s when deserializing a tree, rather than creating new ones all the time. This makes testing for + * equality easier because deserialized nodes will have the same {@link NameId} instances as the original ones. + */ + public static class TestNameIdMapper extends PlanStreamInput.NameIdMapper { + public TestNameIdMapper() { + super(); + }; + + @SuppressWarnings("this-escape") + public TestNameIdMapper(Node node) { + super(); + collectNameIds(node); + } + + private void add(NameId id) { + seen().computeIfAbsent(id.id(), unused -> id); + } + + public void collectNameIds(Node node) { + if (node instanceof Expression e) { + e.forEachDown(NamedExpression.class, ne -> add(ne.id())); + return; + } + + if (node instanceof QueryPlan p) { + p.forEachExpressionDown(NamedExpression.class, ne -> add(ne.id())); + } + + if (node instanceof LogicalPlan lp) { + lp.forEachDown(Lookup.class, lookup -> { + if (lookup.localRelation() != null) { + // The LocalRelation is not seen as part of the plan tree so we need to explicitly collect its NameIds. + collectNameIds(lookup.localRelation()); + } + }); + } + + if (node instanceof PhysicalPlan p) { + p.forEachDown(FragmentExec.class, fragmentExec -> { + // The fragment is not seen as part of the plan tree so we need to explicitly collect its NameIds. + LogicalPlan fragment = fragmentExec.fragment(); + collectNameIds(fragment); + }); + } + } + } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractExpressionSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractExpressionSerializationTests.java index b8c1f3fb6b98d..050293e58c19d 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractExpressionSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractExpressionSerializationTests.java @@ -7,17 +7,12 @@ package org.elasticsearch.xpack.esql.expression; -import org.elasticsearch.TransportVersion; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.xpack.esql.core.expression.Expression; import org.elasticsearch.xpack.esql.core.tree.Node; import org.elasticsearch.xpack.esql.expression.function.ReferenceAttributeTests; import org.elasticsearch.xpack.esql.plan.AbstractNodeSerializationTests; -import java.io.IOException; - -import static org.elasticsearch.xpack.esql.SerializationTestUtils.ignoreIds; - public abstract class AbstractExpressionSerializationTests extends AbstractNodeSerializationTests { public static Expression randomChild() { @@ -37,23 +32,4 @@ protected final NamedWriteableRegistry getNamedWriteableRegistry() { protected Class> categoryClass() { return Expression.class; } - - @Override - protected final T createTestInstance() { - return ignoreIds(innerCreateTestInstance()); - } - - protected abstract T innerCreateTestInstance(); - - @Override - protected final T mutateInstance(T instance) throws IOException { - return ignoreIds(innerMutateInstance(instance)); - } - - protected abstract T innerMutateInstance(T instance) throws IOException; - - @Override - protected T copyInstance(T instance, TransportVersion version) throws IOException { - return ignoreIds(super.copyInstance(instance, version)); - } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractUnaryScalarSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractUnaryScalarSerializationTests.java index 451b2d0bfc0b5..8581699b83fbd 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractUnaryScalarSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractUnaryScalarSerializationTests.java @@ -17,12 +17,12 @@ public abstract class AbstractUnaryScalarSerializationTests ex protected abstract T create(Source source, Expression first, List rest); @Override - protected final T innerCreateTestInstance() { + protected final T createTestInstance() { Source source = randomSource(); Expression first = randomChild(); List rest = randomList(0, 10, AbstractExpressionSerializationTests::randomChild); @@ -25,7 +25,7 @@ protected final T innerCreateTestInstance() { } @Override - protected final T innerMutateInstance(T instance) throws IOException { + protected final T mutateInstance(T instance) throws IOException { Source source = instance.source(); Expression first = instance.children().get(0); List rest = instance.children().subList(1, instance.children().size()); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/LiteralSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/LiteralSerializationTests.java index 9c433373c74e0..fa6041c6d2e58 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/LiteralSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/LiteralSerializationTests.java @@ -14,12 +14,12 @@ public class LiteralSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Literal innerCreateTestInstance() { + protected Literal createTestInstance() { return LiteralTests.randomLiteral(); } @Override - protected Literal innerMutateInstance(Literal instance) throws IOException { + protected Literal mutateInstance(Literal instance) throws IOException { return LiteralTests.mutateLiteral(instance); } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/OrderSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/OrderSerializationTests.java index 96267cd2e0427..4b14e453201f8 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/OrderSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/OrderSerializationTests.java @@ -18,7 +18,7 @@ public static Order randomOrder() { } @Override - protected Order innerCreateTestInstance() { + protected Order createTestInstance() { return randomOrder(); } @@ -31,7 +31,7 @@ private static Order.NullsPosition randomNulls() { } @Override - protected Order innerMutateInstance(Order instance) throws IOException { + protected Order mutateInstance(Order instance) throws IOException { Source source = instance.source(); Expression child = instance.child(); Order.OrderDirection direction = instance.direction(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractAttributeTestCase.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractAttributeTestCase.java deleted file mode 100644 index 0ec457672cc87..0000000000000 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractAttributeTestCase.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * 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; - -import org.elasticsearch.TransportVersion; -import org.elasticsearch.common.io.stream.NamedWriteableRegistry; -import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.test.AbstractWireSerializingTestCase; -import org.elasticsearch.xpack.esql.EsqlTestUtils; -import org.elasticsearch.xpack.esql.core.expression.Attribute; -import org.elasticsearch.xpack.esql.core.expression.FieldAttribute; -import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.ExpressionWritables; -import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput; -import org.elasticsearch.xpack.esql.io.stream.PlanStreamOutput; -import org.elasticsearch.xpack.esql.session.Configuration; - -import java.io.IOException; -import java.util.Objects; - -import static org.hamcrest.Matchers.sameInstance; - -public abstract class AbstractAttributeTestCase extends AbstractWireSerializingTestCase< - AbstractAttributeTestCase.ExtraAttribute> { - - /** - * We use a single random config for all serialization because it's pretty - * heavy to build, especially in {@link #testConcurrentSerialization()}. - */ - private Configuration config; - - protected abstract T create(); - - protected abstract T mutate(T instance); - - @Override - protected final ExtraAttribute createTestInstance() { - return new ExtraAttribute(create()); - } - - @Override - @SuppressWarnings("unchecked") - protected final ExtraAttribute mutateInstance(ExtraAttribute instance) { - return new ExtraAttribute(mutate((T) instance.a)); - } - - @Override - protected final NamedWriteableRegistry getNamedWriteableRegistry() { - return new NamedWriteableRegistry(ExpressionWritables.attributes()); - } - - @Override - protected final Writeable.Reader instanceReader() { - return in -> { - PlanStreamInput pin = new PlanStreamInput(in, in.namedWriteableRegistry(), config); - pin.setTransportVersion(in.getTransportVersion()); - return new ExtraAttribute(pin); - }; - } - - @Override - protected ExtraAttribute copyInstance(ExtraAttribute instance, TransportVersion version) throws IOException { - ExtraAttribute copied = super.copyInstance(instance, version); - // In production, we assign new name ids when deserializing a plan, as name ids are globally unique on a node. - // In tests we don't do that because it would make equality testing impossible, so we just copy the original id. - return new ExtraAttribute(copied.a.withId(instance.a.id())); - } - - /** - * Adds extra equality comparisons needed for testing round trips of {@link Attribute}. - */ - public static class ExtraAttribute implements Writeable { - private final Attribute a; - - ExtraAttribute(Attribute a) { - this.a = a; - assertThat(a.source(), sameInstance(Source.EMPTY)); - } - - ExtraAttribute(PlanStreamInput in) throws IOException { - a = in.readNamedWriteable(Attribute.class); - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - new PlanStreamOutput(out, EsqlTestUtils.TEST_CFG).writeNamedWriteable(a); - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return a.equals(null); - } - if (obj.getClass() != getClass()) { - return a.equals(obj); - } - ExtraAttribute other = (ExtraAttribute) obj; - if (false == a.equals(other.a)) { - return false; - } - if (a instanceof FieldAttribute fa && false == fa.field().equals(((FieldAttribute) other.a).field())) { - return false; - } - return a.source() == Source.EMPTY; - } - - @Override - public int hashCode() { - if (a instanceof FieldAttribute fa) { - return Objects.hash(a, a.source(), fa.field()); - } - return Objects.hash(a, a.source()); - } - - @Override - public String toString() { - StringBuilder b = new StringBuilder(a.toString()); - if (a instanceof FieldAttribute fa) { - b.append(", field=").append(fa.field()); - } - return b.toString(); - } - } -} diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/FieldAttributeTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/FieldAttributeTests.java index 0c0c65c5b1452..fff14da7e74a1 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/FieldAttributeTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/FieldAttributeTests.java @@ -13,9 +13,10 @@ import org.elasticsearch.xpack.esql.core.tree.Source; import org.elasticsearch.xpack.esql.core.type.DataType; import org.elasticsearch.xpack.esql.core.type.EsField; +import org.elasticsearch.xpack.esql.expression.AbstractExpressionSerializationTests; import org.elasticsearch.xpack.esql.type.AbstractEsFieldTypeTests; -public class FieldAttributeTests extends AbstractAttributeTestCase { +public class FieldAttributeTests extends AbstractExpressionSerializationTests { public static FieldAttribute createFieldAttribute(int maxDepth, boolean onlyRepresentable) { Source source = Source.EMPTY; String parentName = maxDepth == 0 || randomBoolean() ? null : randomAlphaOfLength(3); @@ -35,12 +36,12 @@ private static EsField randomRepresentableEsField(int maxDepth) { } @Override - protected FieldAttribute create() { + protected FieldAttribute createTestInstance() { return createFieldAttribute(3, false); } @Override - protected FieldAttribute mutate(FieldAttribute instance) { + protected FieldAttribute mutateInstance(FieldAttribute instance) { Source source = instance.source(); String parentName = instance.parentName(); String name = instance.name(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/MetadataAttributeTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/MetadataAttributeTests.java index 119bf5306ef38..b002c1af78ed1 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/MetadataAttributeTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/MetadataAttributeTests.java @@ -12,10 +12,11 @@ import org.elasticsearch.xpack.esql.core.expression.Nullability; import org.elasticsearch.xpack.esql.core.tree.Source; import org.elasticsearch.xpack.esql.core.type.DataType; +import org.elasticsearch.xpack.esql.expression.AbstractExpressionSerializationTests; -public class MetadataAttributeTests extends AbstractAttributeTestCase { +public class MetadataAttributeTests extends AbstractExpressionSerializationTests { @Override - protected MetadataAttribute create() { + protected MetadataAttribute createTestInstance() { return randomMetadataAttribute(); } @@ -30,20 +31,20 @@ public static MetadataAttribute randomMetadataAttribute() { } @Override - protected MetadataAttribute mutate(MetadataAttribute instance) { + protected MetadataAttribute mutateInstance(MetadataAttribute instance) { Source source = instance.source(); String name = instance.name(); DataType type = instance.dataType(); Nullability nullability = instance.nullable(); - boolean synthetic = instance.synthetic(); NameId id = instance.id(); + boolean synthetic = instance.synthetic(); boolean searchable = instance.searchable(); switch (between(0, 5)) { case 0 -> name = randomAlphaOfLength(name.length() + 1); case 1 -> type = randomValueOtherThan(type, () -> randomFrom(DataType.types())); case 2 -> nullability = randomValueOtherThan(nullability, () -> randomFrom(Nullability.values())); - case 3 -> synthetic = false == synthetic; - case 4 -> id = new NameId(); + case 3 -> id = new NameId(); + case 4 -> synthetic = false == synthetic; case 5 -> searchable = false == searchable; } return new MetadataAttribute(source, name, type, nullability, id, synthetic, searchable); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/ReferenceAttributeTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/ReferenceAttributeTests.java index 83a4b0340524d..9220ac1993485 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/ReferenceAttributeTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/ReferenceAttributeTests.java @@ -12,8 +12,9 @@ import org.elasticsearch.xpack.esql.core.expression.ReferenceAttribute; import org.elasticsearch.xpack.esql.core.tree.Source; import org.elasticsearch.xpack.esql.core.type.DataType; +import org.elasticsearch.xpack.esql.expression.AbstractExpressionSerializationTests; -public class ReferenceAttributeTests extends AbstractAttributeTestCase { +public class ReferenceAttributeTests extends AbstractExpressionSerializationTests { public static ReferenceAttribute randomReferenceAttribute(boolean onlyRepresentable) { Source source = Source.EMPTY; String qualifier = randomBoolean() ? null : randomAlphaOfLength(3); @@ -27,12 +28,12 @@ public static ReferenceAttribute randomReferenceAttribute(boolean onlyRepresenta } @Override - protected ReferenceAttribute create() { + protected ReferenceAttribute createTestInstance() { return randomReferenceAttribute(false); } @Override - protected ReferenceAttribute mutate(ReferenceAttribute instance) { + protected ReferenceAttribute mutateInstance(ReferenceAttribute instance) { Source source = instance.source(); String qualifier = instance.qualifier(); String name = instance.name(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttributeTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttributeTests.java index 243a14331a308..acb5108116eb5 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttributeTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttributeTests.java @@ -10,11 +10,12 @@ import org.elasticsearch.xpack.esql.core.expression.NameId; import org.elasticsearch.xpack.esql.core.tree.Source; import org.elasticsearch.xpack.esql.core.type.UnsupportedEsField; +import org.elasticsearch.xpack.esql.expression.AbstractExpressionSerializationTests; import org.elasticsearch.xpack.esql.type.UnsupportedEsFieldTests; -public class UnsupportedAttributeTests extends AbstractAttributeTestCase { +public class UnsupportedAttributeTests extends AbstractExpressionSerializationTests { @Override - protected UnsupportedAttribute create() { + protected UnsupportedAttribute createTestInstance() { return randomUnsupportedAttribute(); } @@ -28,7 +29,7 @@ public static UnsupportedAttribute randomUnsupportedAttribute() { } @Override - protected UnsupportedAttribute mutate(UnsupportedAttribute instance) { + protected UnsupportedAttribute mutateInstance(UnsupportedAttribute instance) { Source source = instance.source(); String qualifier = instance.qualifier(); String name = instance.name(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/AbsentSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/AbsentSerializationTests.java index 26ce06d0908f4..1d7e1e0b62428 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/AbsentSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/AbsentSerializationTests.java @@ -13,12 +13,12 @@ public class AbsentSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Absent innerCreateTestInstance() { + protected Absent createTestInstance() { return new Absent(randomSource(), randomChild()); } @Override - protected Absent innerMutateInstance(Absent instance) throws IOException { + protected Absent mutateInstance(Absent instance) throws IOException { return new Absent(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/AvgSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/AvgSerializationTests.java index 738248a8b4d54..5d6fa21e20813 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/AvgSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/AvgSerializationTests.java @@ -25,12 +25,12 @@ public class AvgSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Avg innerCreateTestInstance() { + protected Avg createTestInstance() { return new Avg(randomSource(), randomChild(), randomChild(), randomChild()); } @Override - protected Avg innerMutateInstance(Avg instance) throws IOException { + protected Avg mutateInstance(Avg instance) throws IOException { Expression field = instance.field(); Expression filter = instance.filter(); Expression summationMode = instance.summationMode(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/CountDistinctSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/CountDistinctSerializationTests.java index d15444e1040b4..1dbaaf16a559c 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/CountDistinctSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/CountDistinctSerializationTests.java @@ -15,7 +15,7 @@ public class CountDistinctSerializationTests extends AbstractExpressionSerializationTests { @Override - protected CountDistinct innerCreateTestInstance() { + protected CountDistinct createTestInstance() { Source source = randomSource(); Expression field = randomChild(); Expression precision = randomBoolean() ? null : randomChild(); @@ -23,7 +23,7 @@ protected CountDistinct innerCreateTestInstance() { } @Override - protected CountDistinct innerMutateInstance(CountDistinct instance) throws IOException { + protected CountDistinct mutateInstance(CountDistinct instance) throws IOException { Source source = randomSource(); Expression field = instance.field(); Expression precision = instance.precision(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/CountSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/CountSerializationTests.java index 44241ab4359f4..39defdd9c0777 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/CountSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/CountSerializationTests.java @@ -13,12 +13,12 @@ public class CountSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Count innerCreateTestInstance() { + protected Count createTestInstance() { return new Count(randomSource(), randomChild()); } @Override - protected Count innerMutateInstance(Count instance) throws IOException { + protected Count mutateInstance(Count instance) throws IOException { return new Count(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/FirstSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/FirstSerializationTests.java index 356e171976a45..e4cc6ad5ebb9d 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/FirstSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/FirstSerializationTests.java @@ -14,12 +14,12 @@ public class FirstSerializationTests extends AbstractExpressionSerializationTests { @Override - protected First innerCreateTestInstance() { + protected First createTestInstance() { return new First(randomSource(), randomChild(), randomChild()); } @Override - protected First innerMutateInstance(First instance) throws IOException { + protected First mutateInstance(First instance) throws IOException { Expression field = instance.field(); Expression sort = instance.sort(); if (randomBoolean()) { diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/IncreaseSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/IncreaseSerializationTests.java index 52e15d939d51f..76605f1d66243 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/IncreaseSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/IncreaseSerializationTests.java @@ -15,7 +15,7 @@ public class IncreaseSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Increase innerCreateTestInstance() { + protected Increase createTestInstance() { Source source = randomSource(); Expression field = randomChild(); Expression timestamp = randomChild(); @@ -23,7 +23,7 @@ protected Increase innerCreateTestInstance() { } @Override - protected Increase innerMutateInstance(Increase instance) throws IOException { + protected Increase mutateInstance(Increase instance) throws IOException { Source source = randomSource(); Expression field = instance.field(); Expression timestamp = instance.timestamp(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/LastSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/LastSerializationTests.java index 129b859951cf4..81a68b6003a32 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/LastSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/LastSerializationTests.java @@ -14,12 +14,12 @@ public class LastSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Last innerCreateTestInstance() { + protected Last createTestInstance() { return new Last(randomSource(), randomChild(), randomChild()); } @Override - protected Last innerMutateInstance(Last instance) throws IOException { + protected Last mutateInstance(Last instance) throws IOException { Expression field = instance.field(); Expression sort = instance.sort(); if (randomBoolean()) { diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MaxSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MaxSerializationTests.java index ea6ca2fe528b1..c1c4898f1e057 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MaxSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MaxSerializationTests.java @@ -13,12 +13,12 @@ public class MaxSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Max innerCreateTestInstance() { + protected Max createTestInstance() { return new Max(randomSource(), randomChild()); } @Override - protected Max innerMutateInstance(Max instance) throws IOException { + protected Max mutateInstance(Max instance) throws IOException { return new Max(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MedianAbsoluteDeviationSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MedianAbsoluteDeviationSerializationTests.java index 334afdab80f25..1d6497541e29b 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MedianAbsoluteDeviationSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MedianAbsoluteDeviationSerializationTests.java @@ -13,12 +13,12 @@ public class MedianAbsoluteDeviationSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MedianAbsoluteDeviation innerCreateTestInstance() { + protected MedianAbsoluteDeviation createTestInstance() { return new MedianAbsoluteDeviation(randomSource(), randomChild()); } @Override - protected MedianAbsoluteDeviation innerMutateInstance(MedianAbsoluteDeviation instance) throws IOException { + protected MedianAbsoluteDeviation mutateInstance(MedianAbsoluteDeviation instance) throws IOException { return new MedianAbsoluteDeviation( instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MedianSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MedianSerializationTests.java index afe075b9c1eab..f0b2d63da70d1 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MedianSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MedianSerializationTests.java @@ -13,12 +13,12 @@ public class MedianSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Median innerCreateTestInstance() { + protected Median createTestInstance() { return new Median(randomSource(), randomChild()); } @Override - protected Median innerMutateInstance(Median instance) throws IOException { + protected Median mutateInstance(Median instance) throws IOException { return new Median(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MinSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MinSerializationTests.java index 23e17234ab59a..18e813acdb74c 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MinSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MinSerializationTests.java @@ -13,12 +13,12 @@ public class MinSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Min innerCreateTestInstance() { + protected Min createTestInstance() { return new Min(randomSource(), randomChild()); } @Override - protected Min innerMutateInstance(Min instance) throws IOException { + protected Min mutateInstance(Min instance) throws IOException { return new Min(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/PercentileSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/PercentileSerializationTests.java index 193494d94ab52..5c01b62f7d663 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/PercentileSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/PercentileSerializationTests.java @@ -15,7 +15,7 @@ public class PercentileSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Percentile innerCreateTestInstance() { + protected Percentile createTestInstance() { Source source = randomSource(); Expression field = randomChild(); Expression percentile = randomChild(); @@ -23,7 +23,7 @@ protected Percentile innerCreateTestInstance() { } @Override - protected Percentile innerMutateInstance(Percentile instance) throws IOException { + protected Percentile mutateInstance(Percentile instance) throws IOException { Source source = instance.source(); Expression field = instance.field(); Expression percentile = instance.percentile(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/PresentSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/PresentSerializationTests.java index 402353550aac3..ab221e43861f6 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/PresentSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/PresentSerializationTests.java @@ -13,12 +13,12 @@ public class PresentSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Present innerCreateTestInstance() { + protected Present createTestInstance() { return new Present(randomSource(), randomChild()); } @Override - protected Present innerMutateInstance(Present instance) throws IOException { + protected Present mutateInstance(Present instance) throws IOException { return new Present(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/RateSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/RateSerializationTests.java index d057646b991c6..d3130f9ae5f44 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/RateSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/RateSerializationTests.java @@ -15,7 +15,7 @@ public class RateSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Rate innerCreateTestInstance() { + protected Rate createTestInstance() { Source source = randomSource(); Expression field = randomChild(); Expression timestamp = randomChild(); @@ -23,7 +23,7 @@ protected Rate innerCreateTestInstance() { } @Override - protected Rate innerMutateInstance(Rate instance) throws IOException { + protected Rate mutateInstance(Rate instance) throws IOException { Source source = randomSource(); Expression field = instance.field(); Expression timestamp = instance.timestamp(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SampleSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SampleSerializationTests.java index e9bfc96e81270..078557093a317 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SampleSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SampleSerializationTests.java @@ -15,7 +15,7 @@ public class SampleSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Sample innerCreateTestInstance() { + protected Sample createTestInstance() { Source source = randomSource(); Expression field = randomChild(); Expression limit = randomChild(); @@ -23,7 +23,7 @@ protected Sample innerCreateTestInstance() { } @Override - protected Sample innerMutateInstance(Sample instance) throws IOException { + protected Sample mutateInstance(Sample instance) throws IOException { Source source = randomSource(); Expression field = instance.field(); Expression limit = instance.limitField(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SpatialCentroidSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SpatialCentroidSerializationTests.java index a34ea43c6c04d..4d31cd3cf31ff 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SpatialCentroidSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SpatialCentroidSerializationTests.java @@ -13,12 +13,12 @@ public class SpatialCentroidSerializationTests extends AbstractExpressionSerializationTests { @Override - protected SpatialCentroid innerCreateTestInstance() { + protected SpatialCentroid createTestInstance() { return new SpatialCentroid(randomSource(), randomChild()); } @Override - protected SpatialCentroid innerMutateInstance(SpatialCentroid instance) throws IOException { + protected SpatialCentroid mutateInstance(SpatialCentroid instance) throws IOException { return new SpatialCentroid( instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SpatialExtentSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SpatialExtentSerializationTests.java index d6611bb2ef74d..eacb95646651a 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SpatialExtentSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SpatialExtentSerializationTests.java @@ -13,12 +13,12 @@ public class SpatialExtentSerializationTests extends AbstractExpressionSerializationTests { @Override - protected SpatialExtent innerCreateTestInstance() { + protected SpatialExtent createTestInstance() { return new SpatialExtent(randomSource(), randomChild()); } @Override - protected SpatialExtent innerMutateInstance(SpatialExtent instance) throws IOException { + protected SpatialExtent mutateInstance(SpatialExtent instance) throws IOException { return new SpatialExtent( instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/StdDevSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/StdDevSerializationTests.java index 88c85884506f2..3dd7bbb321ccb 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/StdDevSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/StdDevSerializationTests.java @@ -13,12 +13,12 @@ public class StdDevSerializationTests extends AbstractExpressionSerializationTests { @Override - protected StdDev innerCreateTestInstance() { + protected StdDev createTestInstance() { return new StdDev(randomSource(), randomChild()); } @Override - protected StdDev innerMutateInstance(StdDev instance) throws IOException { + protected StdDev mutateInstance(StdDev instance) throws IOException { return new StdDev(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SumSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SumSerializationTests.java index c36a1709850ce..f15d8bb96cf24 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SumSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SumSerializationTests.java @@ -25,12 +25,12 @@ public class SumSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Sum innerCreateTestInstance() { + protected Sum createTestInstance() { return new Sum(randomSource(), randomChild(), randomChild(), randomChild()); } @Override - protected Sum innerMutateInstance(Sum instance) throws IOException { + protected Sum mutateInstance(Sum instance) throws IOException { Expression field = instance.field(); Expression filter = instance.filter(); Expression summationMode = instance.summationMode(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/TopSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/TopSerializationTests.java index 0a533b2352a15..82bf57d1a194e 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/TopSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/TopSerializationTests.java @@ -15,7 +15,7 @@ public class TopSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Top innerCreateTestInstance() { + protected Top createTestInstance() { Source source = randomSource(); Expression field = randomChild(); Expression limit = randomChild(); @@ -24,7 +24,7 @@ protected Top innerCreateTestInstance() { } @Override - protected Top innerMutateInstance(Top instance) throws IOException { + protected Top mutateInstance(Top instance) throws IOException { Source source = instance.source(); Expression field = instance.field(); Expression limit = instance.limitField(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/ValuesSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/ValuesSerializationTests.java index 9ead9002bb8d7..aac10e14a6999 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/ValuesSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/ValuesSerializationTests.java @@ -13,12 +13,12 @@ public class ValuesSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Values innerCreateTestInstance() { + protected Values createTestInstance() { return new Values(randomSource(), randomChild()); } @Override - protected Values innerMutateInstance(Values instance) throws IOException { + protected Values mutateInstance(Values instance) throws IOException { return new Values(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/WeightedAvgSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/WeightedAvgSerializationTests.java index 81eeacf6823d2..000d02fe342a3 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/WeightedAvgSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/WeightedAvgSerializationTests.java @@ -14,12 +14,12 @@ public class WeightedAvgSerializationTests extends AbstractExpressionSerializationTests { @Override - protected WeightedAvg innerCreateTestInstance() { + protected WeightedAvg createTestInstance() { return new WeightedAvg(randomSource(), randomChild(), randomChild()); } @Override - protected WeightedAvg innerMutateInstance(WeightedAvg instance) throws IOException { + protected WeightedAvg mutateInstance(WeightedAvg instance) throws IOException { Expression field = instance.field(); Expression weight = instance.weight(); if (randomBoolean()) { diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/grouping/BucketSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/grouping/BucketSerializationTests.java index a60d12be3c185..5fe270a4cce42 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/grouping/BucketSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/grouping/BucketSerializationTests.java @@ -15,7 +15,7 @@ public class BucketSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Bucket innerCreateTestInstance() { + protected Bucket createTestInstance() { return createRandomBucket(); } @@ -29,7 +29,7 @@ public static Bucket createRandomBucket() { } @Override - protected Bucket innerMutateInstance(Bucket instance) throws IOException { + protected Bucket mutateInstance(Bucket instance) throws IOException { Source source = instance.source(); Expression field = instance.field(); Expression buckets = instance.buckets(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/AndSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/AndSerializationTests.java index 8d194dc251744..fdfdebb159531 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/AndSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/AndSerializationTests.java @@ -16,7 +16,7 @@ public class AndSerializationTests extends AbstractExpressionSerializationTests { @Override - protected And innerCreateTestInstance() { + protected And createTestInstance() { Source source = randomSource(); Expression left = randomChild(); Expression right = randomChild(); @@ -24,7 +24,7 @@ protected And innerCreateTestInstance() { } @Override - protected And innerMutateInstance(And instance) throws IOException { + protected And mutateInstance(And instance) throws IOException { Source source = instance.source(); Expression left = instance.left(); Expression right = instance.right(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/NotSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/NotSerializationTests.java index 6e90a1c0027c8..966bb664f2a09 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/NotSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/NotSerializationTests.java @@ -16,12 +16,12 @@ public class NotSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Not innerCreateTestInstance() { + protected Not createTestInstance() { return new Not(randomSource(), randomChild()); } @Override - protected Not innerMutateInstance(Not instance) throws IOException { + protected Not mutateInstance(Not instance) throws IOException { Source source = instance.source(); Expression child = randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild); return new Not(source, child); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/OrSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/OrSerializationTests.java index b4c469460f111..9ceddc9910485 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/OrSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/OrSerializationTests.java @@ -16,7 +16,7 @@ public class OrSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Or innerCreateTestInstance() { + protected Or createTestInstance() { Source source = randomSource(); Expression left = randomChild(); Expression right = randomChild(); @@ -24,7 +24,7 @@ protected Or innerCreateTestInstance() { } @Override - protected Or innerMutateInstance(Or instance) throws IOException { + protected Or mutateInstance(Or instance) throws IOException { Source source = instance.source(); Expression left = instance.left(); Expression right = instance.right(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateDiffSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateDiffSerializationTests.java index 40af73eac5afa..f1f8d1b0f8dad 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateDiffSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateDiffSerializationTests.java @@ -15,7 +15,7 @@ public class DateDiffSerializationTests extends AbstractExpressionSerializationTests { @Override - protected DateDiff innerCreateTestInstance() { + protected DateDiff createTestInstance() { Source source = randomSource(); Expression unit = randomChild(); Expression startTimestamp = randomChild(); @@ -24,7 +24,7 @@ protected DateDiff innerCreateTestInstance() { } @Override - protected DateDiff innerMutateInstance(DateDiff instance) throws IOException { + protected DateDiff mutateInstance(DateDiff instance) throws IOException { Source source = instance.source(); Expression unit = instance.unit(); Expression startTimestamp = instance.startTimestamp(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateExtractSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateExtractSerializationTests.java index 250b9729514ec..f4e6d2672a40f 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateExtractSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateExtractSerializationTests.java @@ -15,7 +15,7 @@ public class DateExtractSerializationTests extends AbstractExpressionSerializationTests { @Override - protected DateExtract innerCreateTestInstance() { + protected DateExtract createTestInstance() { Source source = randomSource(); Expression datePart = randomChild(); Expression field = randomChild(); @@ -23,7 +23,7 @@ protected DateExtract innerCreateTestInstance() { } @Override - protected DateExtract innerMutateInstance(DateExtract instance) throws IOException { + protected DateExtract mutateInstance(DateExtract instance) throws IOException { Source source = instance.source(); Expression datePart = instance.datePart(); Expression field = instance.field(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateFormatSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateFormatSerializationTests.java index 0c44b67a611e2..ece145e95aabb 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateFormatSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateFormatSerializationTests.java @@ -15,7 +15,7 @@ public class DateFormatSerializationTests extends AbstractExpressionSerializationTests { @Override - protected DateFormat innerCreateTestInstance() { + protected DateFormat createTestInstance() { Source source = randomSource(); Expression field = randomChild(); Expression format = randomBoolean() ? null : randomChild(); @@ -23,7 +23,7 @@ protected DateFormat innerCreateTestInstance() { } @Override - protected DateFormat innerMutateInstance(DateFormat instance) throws IOException { + protected DateFormat mutateInstance(DateFormat instance) throws IOException { Source source = instance.source(); Expression field = instance.field(); Expression format = instance.format(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateParseSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateParseSerializationTests.java index 9df40c464e041..79a650c8dd963 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateParseSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateParseSerializationTests.java @@ -15,7 +15,7 @@ public class DateParseSerializationTests extends AbstractExpressionSerializationTests { @Override - protected DateParse innerCreateTestInstance() { + protected DateParse createTestInstance() { Source source = randomSource(); Expression first = randomChild(); Expression second = randomBoolean() ? null : randomChild(); @@ -23,7 +23,7 @@ protected DateParse innerCreateTestInstance() { } @Override - protected DateParse innerMutateInstance(DateParse instance) throws IOException { + protected DateParse mutateInstance(DateParse instance) throws IOException { Source source = instance.source(); Expression first = instance.children().get(0); Expression second = instance.children().size() == 1 ? null : instance.children().get(1); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateTruncSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateTruncSerializationTests.java index 64b623abf070a..3d1616ce29adf 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateTruncSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateTruncSerializationTests.java @@ -15,7 +15,7 @@ public class DateTruncSerializationTests extends AbstractExpressionSerializationTests { @Override - protected DateTrunc innerCreateTestInstance() { + protected DateTrunc createTestInstance() { Source source = randomSource(); Expression interval = randomChild(); Expression field = randomChild(); @@ -23,7 +23,7 @@ protected DateTrunc innerCreateTestInstance() { } @Override - protected DateTrunc innerMutateInstance(DateTrunc instance) throws IOException { + protected DateTrunc mutateInstance(DateTrunc instance) throws IOException { Source source = instance.source(); Expression interval = instance.interval(); Expression field = instance.field(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DayNameSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DayNameSerializationTests.java index 70a433985ecce..49173d4db9c6d 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DayNameSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/DayNameSerializationTests.java @@ -16,14 +16,14 @@ public class DayNameSerializationTests extends AbstractExpressionSerializationTests { @Override - protected DayName innerCreateTestInstance() { + protected DayName createTestInstance() { Source source = randomSource(); Expression date = randomChild(); return new DayName(source, date, configuration()); } @Override - protected DayName innerMutateInstance(DayName instance) throws IOException { + protected DayName mutateInstance(DayName instance) throws IOException { Source source = instance.source(); Expression date = instance.field(); return new DayName(source, randomValueOtherThan(date, AbstractExpressionSerializationTests::randomChild), configuration()); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/MonthNameSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/MonthNameSerializationTests.java index d3c20a9602c9b..348c7f9be8cc6 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/MonthNameSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/MonthNameSerializationTests.java @@ -16,14 +16,14 @@ public class MonthNameSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MonthName innerCreateTestInstance() { + protected MonthName createTestInstance() { Source source = randomSource(); Expression date = randomChild(); return new MonthName(source, date, configuration()); } @Override - protected MonthName innerMutateInstance(MonthName instance) throws IOException { + protected MonthName mutateInstance(MonthName instance) throws IOException { Source source = instance.source(); Expression date = instance.field(); return new MonthName(source, randomValueOtherThan(date, AbstractExpressionSerializationTests::randomChild), configuration()); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/NowSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/NowSerializationTests.java index c015e21b15e46..b816e3a8da858 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/NowSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/date/NowSerializationTests.java @@ -13,12 +13,12 @@ public class NowSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Now innerCreateTestInstance() { + protected Now createTestInstance() { return new Now(randomSource(), configuration()); } @Override - protected Now innerMutateInstance(Now instance) throws IOException { + protected Now mutateInstance(Now instance) throws IOException { return null; } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/ip/CIDRMatchSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/ip/CIDRMatchSerializationTests.java index ee019fa43be22..3c833c4b0d7ac 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/ip/CIDRMatchSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/ip/CIDRMatchSerializationTests.java @@ -16,7 +16,7 @@ public class CIDRMatchSerializationTests extends AbstractExpressionSerializationTests { @Override - protected CIDRMatch innerCreateTestInstance() { + protected CIDRMatch createTestInstance() { Source source = randomSource(); Expression ipField = randomChild(); List matches = randomList(1, 10, AbstractExpressionSerializationTests::randomChild); @@ -24,7 +24,7 @@ protected CIDRMatch innerCreateTestInstance() { } @Override - protected CIDRMatch innerMutateInstance(CIDRMatch instance) throws IOException { + protected CIDRMatch mutateInstance(CIDRMatch instance) throws IOException { Source source = instance.source(); Expression ipField = instance.ipField(); List matches = instance.matches(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/ip/IpPrefixSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/ip/IpPrefixSerializationTests.java index 794304dd8f747..d7fc05d9d0f64 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/ip/IpPrefixSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/ip/IpPrefixSerializationTests.java @@ -15,7 +15,7 @@ public class IpPrefixSerializationTests extends AbstractExpressionSerializationTests { @Override - protected IpPrefix innerCreateTestInstance() { + protected IpPrefix createTestInstance() { Source source = randomSource(); Expression ipField = randomChild(); Expression prefixLengthV4Field = randomChild(); @@ -24,7 +24,7 @@ protected IpPrefix innerCreateTestInstance() { } @Override - protected IpPrefix innerMutateInstance(IpPrefix instance) throws IOException { + protected IpPrefix mutateInstance(IpPrefix instance) throws IOException { Source source = instance.source(); Expression ipField = instance.ipField(); Expression prefixLengthV4Field = instance.prefixLengthV4Field(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/Atan2SerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/Atan2SerializationTests.java index b0beaebec9d0f..2ae88bbf24549 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/Atan2SerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/Atan2SerializationTests.java @@ -16,7 +16,7 @@ public class Atan2SerializationTests extends AbstractExpressionSerializationTests { @Override - protected Atan2 innerCreateTestInstance() { + protected Atan2 createTestInstance() { Source source = randomSource(); Expression y = randomChild(); Expression x = randomChild(); @@ -24,7 +24,7 @@ protected Atan2 innerCreateTestInstance() { } @Override - protected Atan2 innerMutateInstance(Atan2 instance) throws IOException { + protected Atan2 mutateInstance(Atan2 instance) throws IOException { Source source = instance.source(); Expression y = instance.y(); Expression x = instance.x(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/ESerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/ESerializationTests.java index 0f078e6e45eb0..971295aa02a9b 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/ESerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/ESerializationTests.java @@ -13,12 +13,12 @@ public class ESerializationTests extends AbstractExpressionSerializationTests { @Override - protected E innerCreateTestInstance() { + protected E createTestInstance() { return new E(randomSource()); } @Override - protected E innerMutateInstance(E instance) throws IOException { + protected E mutateInstance(E instance) throws IOException { return null; } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/HypotSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/HypotSerializationTests.java index c5a7a25a4adaf..5c2e84fcba8e0 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/HypotSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/HypotSerializationTests.java @@ -17,7 +17,7 @@ public class HypotSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Hypot innerCreateTestInstance() { + protected Hypot createTestInstance() { Source source = randomSource(); Expression n1 = randomChild(); Expression n2 = randomChild(); @@ -25,7 +25,7 @@ protected Hypot innerCreateTestInstance() { } @Override - protected Hypot innerMutateInstance(Hypot instance) throws IOException { + protected Hypot mutateInstance(Hypot instance) throws IOException { Source source = instance.source(); Expression n1 = instance.n1(); Expression n2 = instance.n2(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/LogSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/LogSerializationTests.java index 3298e1ae5045b..8b65a40d9e831 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/LogSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/LogSerializationTests.java @@ -15,7 +15,7 @@ public class LogSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Log innerCreateTestInstance() { + protected Log createTestInstance() { Source source = randomSource(); Expression value = randomChild(); Expression base = randomBoolean() ? null : randomChild(); @@ -23,7 +23,7 @@ protected Log innerCreateTestInstance() { } @Override - protected Log innerMutateInstance(Log instance) throws IOException { + protected Log mutateInstance(Log instance) throws IOException { Source source = instance.source(); Expression value = instance.value(); Expression base = instance.base(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/PiSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/PiSerializationTests.java index 43f4657a3ed5a..597d1cbc8533c 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/PiSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/PiSerializationTests.java @@ -13,12 +13,12 @@ public class PiSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Pi innerCreateTestInstance() { + protected Pi createTestInstance() { return new Pi(randomSource()); } @Override - protected Pi innerMutateInstance(Pi instance) throws IOException { + protected Pi mutateInstance(Pi instance) throws IOException { return null; } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/PowSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/PowSerializationTests.java index 637b7ba3d26bb..b811d719ca923 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/PowSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/PowSerializationTests.java @@ -15,7 +15,7 @@ public class PowSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Pow innerCreateTestInstance() { + protected Pow createTestInstance() { Source source = randomSource(); Expression base = randomChild(); Expression exponent = randomChild(); @@ -23,7 +23,7 @@ protected Pow innerCreateTestInstance() { } @Override - protected Pow innerMutateInstance(Pow instance) throws IOException { + protected Pow mutateInstance(Pow instance) throws IOException { Source source = instance.source(); Expression base = instance.base(); Expression exponent = instance.exponent(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundSerializationTests.java index 20e05760a7e6b..91e97a6d07b14 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundSerializationTests.java @@ -15,7 +15,7 @@ public class RoundSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Round innerCreateTestInstance() { + protected Round createTestInstance() { Source source = randomSource(); Expression field = randomChild(); Expression decimals = randomBoolean() ? null : randomChild(); @@ -23,7 +23,7 @@ protected Round innerCreateTestInstance() { } @Override - protected Round innerMutateInstance(Round instance) throws IOException { + protected Round mutateInstance(Round instance) throws IOException { Source source = instance.source(); Expression field = instance.field(); Expression decimals = instance.decimals(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundToSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundToSerializationTests.java index e782930edee1b..9d67158eb305f 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundToSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundToSerializationTests.java @@ -21,7 +21,7 @@ public class RoundToSerializationTests extends AbstractExpressionSerializationTests { @Override - protected RoundTo innerCreateTestInstance() { + protected RoundTo createTestInstance() { Source source = randomSource(); DataType type = randomFrom(DataType.INTEGER, DataType.LONG, DataType.DOUBLE, DataType.DATETIME, DataType.DATE_NANOS); Expression field = randomField(type); @@ -44,7 +44,7 @@ private List randomPoints(DataType type) { } @Override - protected RoundTo innerMutateInstance(RoundTo instance) throws IOException { + protected RoundTo mutateInstance(RoundTo instance) throws IOException { Source source = instance.source(); Expression field = instance.field(); List points = instance.points(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/TauSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/TauSerializationTests.java index 07d44702093b8..fb259f0e43150 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/TauSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/TauSerializationTests.java @@ -13,12 +13,12 @@ public class TauSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Tau innerCreateTestInstance() { + protected Tau createTestInstance() { return new Tau(randomSource()); } @Override - protected Tau innerMutateInstance(Tau instance) throws IOException { + protected Tau mutateInstance(Tau instance) throws IOException { return null; } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAppendSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAppendSerializationTests.java index 90a2cf8a3db5f..9bbb4856b5e0f 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAppendSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAppendSerializationTests.java @@ -15,7 +15,7 @@ public class MvAppendSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvAppend innerCreateTestInstance() { + protected MvAppend createTestInstance() { Source source = randomSource(); Expression field1 = randomChild(); Expression field2 = randomChild(); @@ -23,7 +23,7 @@ protected MvAppend innerCreateTestInstance() { } @Override - protected MvAppend innerMutateInstance(MvAppend instance) throws IOException { + protected MvAppend mutateInstance(MvAppend instance) throws IOException { Source source = randomSource(); Expression field1 = randomChild(); Expression field2 = randomChild(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAvgSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAvgSerializationTests.java index 42a70970053bc..0a3ddaf576c38 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAvgSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAvgSerializationTests.java @@ -13,12 +13,12 @@ public class MvAvgSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvAvg innerCreateTestInstance() { + protected MvAvg createTestInstance() { return new MvAvg(randomSource(), randomChild()); } @Override - protected MvAvg innerMutateInstance(MvAvg instance) throws IOException { + protected MvAvg mutateInstance(MvAvg instance) throws IOException { return new MvAvg(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvConcatSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvConcatSerializationTests.java index 31d64180e210a..ba4eda8590f70 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvConcatSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvConcatSerializationTests.java @@ -15,7 +15,7 @@ public class MvConcatSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvConcat innerCreateTestInstance() { + protected MvConcat createTestInstance() { Source source = randomSource(); Expression left = randomChild(); Expression right = randomChild(); @@ -23,7 +23,7 @@ protected MvConcat innerCreateTestInstance() { } @Override - protected MvConcat innerMutateInstance(MvConcat instance) throws IOException { + protected MvConcat mutateInstance(MvConcat instance) throws IOException { Source source = instance.source(); Expression left = instance.left(); Expression right = instance.right(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvContainsSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvContainsSerializationTests.java index c71abe7360c0d..3f190b0250671 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvContainsSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvContainsSerializationTests.java @@ -15,7 +15,7 @@ public class MvContainsSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvContains innerCreateTestInstance() { + protected MvContains createTestInstance() { Source source = randomSource(); Expression field1 = randomChild(); Expression field2 = randomChild(); @@ -23,7 +23,7 @@ protected MvContains innerCreateTestInstance() { } @Override - protected MvContains innerMutateInstance(MvContains instance) throws IOException { + protected MvContains mutateInstance(MvContains instance) throws IOException { Source source = randomSource(); Expression field1 = randomChild(); Expression field2 = randomChild(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvCountSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvCountSerializationTests.java index ec8ec1e1811ec..be641e210782c 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvCountSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvCountSerializationTests.java @@ -13,12 +13,12 @@ public class MvCountSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvCount innerCreateTestInstance() { + protected MvCount createTestInstance() { return new MvCount(randomSource(), randomChild()); } @Override - protected MvCount innerMutateInstance(MvCount instance) throws IOException { + protected MvCount mutateInstance(MvCount instance) throws IOException { return new MvCount(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvDedupeSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvDedupeSerializationTests.java index e26c85c0f3f40..151b73c3fb9a3 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvDedupeSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvDedupeSerializationTests.java @@ -13,12 +13,12 @@ public class MvDedupeSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvDedupe innerCreateTestInstance() { + protected MvDedupe createTestInstance() { return new MvDedupe(randomSource(), randomChild()); } @Override - protected MvDedupe innerMutateInstance(MvDedupe instance) throws IOException { + protected MvDedupe mutateInstance(MvDedupe instance) throws IOException { return new MvDedupe(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvFirstSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvFirstSerializationTests.java index f6e081938f788..59d42abfbf291 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvFirstSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvFirstSerializationTests.java @@ -13,12 +13,12 @@ public class MvFirstSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvFirst innerCreateTestInstance() { + protected MvFirst createTestInstance() { return new MvFirst(randomSource(), randomChild()); } @Override - protected MvFirst innerMutateInstance(MvFirst instance) throws IOException { + protected MvFirst mutateInstance(MvFirst instance) throws IOException { return new MvFirst(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvLastSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvLastSerializationTests.java index cdd8b89f24965..d3aada6879caa 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvLastSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvLastSerializationTests.java @@ -13,12 +13,12 @@ public class MvLastSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvLast innerCreateTestInstance() { + protected MvLast createTestInstance() { return new MvLast(randomSource(), randomChild()); } @Override - protected MvLast innerMutateInstance(MvLast instance) throws IOException { + protected MvLast mutateInstance(MvLast instance) throws IOException { return new MvLast(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMaxSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMaxSerializationTests.java index 3229dfb3e18d0..d4880b6814905 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMaxSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMaxSerializationTests.java @@ -13,12 +13,12 @@ public class MvMaxSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvMax innerCreateTestInstance() { + protected MvMax createTestInstance() { return new MvMax(randomSource(), randomChild()); } @Override - protected MvMax innerMutateInstance(MvMax instance) throws IOException { + protected MvMax mutateInstance(MvMax instance) throws IOException { return new MvMax(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMedianAbsoluteDeviationSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMedianAbsoluteDeviationSerializationTests.java index e9073378b7efb..3e402a9f7422e 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMedianAbsoluteDeviationSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMedianAbsoluteDeviationSerializationTests.java @@ -13,12 +13,12 @@ public class MvMedianAbsoluteDeviationSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvMedianAbsoluteDeviation innerCreateTestInstance() { + protected MvMedianAbsoluteDeviation createTestInstance() { return new MvMedianAbsoluteDeviation(randomSource(), randomChild()); } @Override - protected MvMedianAbsoluteDeviation innerMutateInstance(MvMedianAbsoluteDeviation instance) throws IOException { + protected MvMedianAbsoluteDeviation mutateInstance(MvMedianAbsoluteDeviation instance) throws IOException { return new MvMedianAbsoluteDeviation( instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMedianSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMedianSerializationTests.java index 8ab491118553c..6b7a1dd5a8d0f 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMedianSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMedianSerializationTests.java @@ -13,12 +13,12 @@ public class MvMedianSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvMedian innerCreateTestInstance() { + protected MvMedian createTestInstance() { return new MvMedian(randomSource(), randomChild()); } @Override - protected MvMedian innerMutateInstance(MvMedian instance) throws IOException { + protected MvMedian mutateInstance(MvMedian instance) throws IOException { return new MvMedian(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMinSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMinSerializationTests.java index 7f792fee6521f..f53aa660834cf 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMinSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMinSerializationTests.java @@ -13,12 +13,12 @@ public class MvMinSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvMin innerCreateTestInstance() { + protected MvMin createTestInstance() { return new MvMin(randomSource(), randomChild()); } @Override - protected MvMin innerMutateInstance(MvMin instance) throws IOException { + protected MvMin mutateInstance(MvMin instance) throws IOException { return new MvMin(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPSeriesWeightedSumSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPSeriesWeightedSumSerializationTests.java index 2c08563fa5b8c..dcb525c79b272 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPSeriesWeightedSumSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPSeriesWeightedSumSerializationTests.java @@ -15,7 +15,7 @@ public class MvPSeriesWeightedSumSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvPSeriesWeightedSum innerCreateTestInstance() { + protected MvPSeriesWeightedSum createTestInstance() { Source source = randomSource(); Expression field = randomChild(); Expression p = randomChild(); @@ -24,7 +24,7 @@ protected MvPSeriesWeightedSum innerCreateTestInstance() { } @Override - protected MvPSeriesWeightedSum innerMutateInstance(MvPSeriesWeightedSum instance) throws IOException { + protected MvPSeriesWeightedSum mutateInstance(MvPSeriesWeightedSum instance) throws IOException { Source source = instance.source(); Expression field = instance.field(); Expression p = instance.p(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSliceSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSliceSerializationTests.java index a0fe8ac4d8804..70f106b65f78d 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSliceSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSliceSerializationTests.java @@ -15,7 +15,7 @@ public class MvSliceSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvSlice innerCreateTestInstance() { + protected MvSlice createTestInstance() { Source source = randomSource(); Expression field = randomChild(); Expression start = randomChild(); @@ -24,7 +24,7 @@ protected MvSlice innerCreateTestInstance() { } @Override - protected MvSlice innerMutateInstance(MvSlice instance) throws IOException { + protected MvSlice mutateInstance(MvSlice instance) throws IOException { Source source = instance.source(); Expression field = instance.field(); Expression start = instance.start(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSortSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSortSerializationTests.java index 64a8b44d6f111..d7dba33e1aae3 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSortSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSortSerializationTests.java @@ -15,7 +15,7 @@ public class MvSortSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvSort innerCreateTestInstance() { + protected MvSort createTestInstance() { Source source = randomSource(); Expression field = randomChild(); Expression order = randomBoolean() ? null : randomChild(); @@ -23,7 +23,7 @@ protected MvSort innerCreateTestInstance() { } @Override - protected MvSort innerMutateInstance(MvSort instance) throws IOException { + protected MvSort mutateInstance(MvSort instance) throws IOException { Source source = instance.source(); Expression field = instance.field(); Expression order = instance.order(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSumSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSumSerializationTests.java index 9dd23ecf5e258..01db7335d7901 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSumSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSumSerializationTests.java @@ -13,12 +13,12 @@ public class MvSumSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvSum innerCreateTestInstance() { + protected MvSum createTestInstance() { return new MvSum(randomSource(), randomChild()); } @Override - protected MvSum innerMutateInstance(MvSum instance) throws IOException { + protected MvSum mutateInstance(MvSum instance) throws IOException { return new MvSum(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvZipSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvZipSerializationTests.java index 61ef09772d872..4b49a1f55340d 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvZipSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvZipSerializationTests.java @@ -15,7 +15,7 @@ public class MvZipSerializationTests extends AbstractExpressionSerializationTests { @Override - protected MvZip innerCreateTestInstance() { + protected MvZip createTestInstance() { Source source = randomSource(); Expression mvLeft = randomChild(); Expression mvRight = randomChild(); @@ -24,7 +24,7 @@ protected MvZip innerCreateTestInstance() { } @Override - protected MvZip innerMutateInstance(MvZip instance) throws IOException { + protected MvZip mutateInstance(MvZip instance) throws IOException { Source source = instance.source(); Expression mvLeft = instance.mvLeft(); Expression mvRight = instance.mvRight(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNotNullSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNotNullSerializationTests.java index 4d7270c35149b..a4b42a2145327 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNotNullSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNotNullSerializationTests.java @@ -16,12 +16,12 @@ public class IsNotNullSerializationTests extends AbstractExpressionSerializationTests { @Override - protected IsNotNull innerCreateTestInstance() { + protected IsNotNull createTestInstance() { return new IsNotNull(randomSource(), randomChild()); } @Override - protected IsNotNull innerMutateInstance(IsNotNull instance) throws IOException { + protected IsNotNull mutateInstance(IsNotNull instance) throws IOException { Source source = instance.source(); Expression child = randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild); return new IsNotNull(source, child); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNullSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNullSerializationTests.java index 182add9a0ea90..6202db6db185d 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNullSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNullSerializationTests.java @@ -16,12 +16,12 @@ public class IsNullSerializationTests extends AbstractExpressionSerializationTests { @Override - protected IsNull innerCreateTestInstance() { + protected IsNull createTestInstance() { return new IsNull(randomSource(), randomChild()); } @Override - protected IsNull innerMutateInstance(IsNull instance) throws IOException { + protected IsNull mutateInstance(IsNull instance) throws IOException { Source source = instance.source(); Expression child = randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild); return new IsNull(source, child); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/AbstractBinarySpatialFunctionSerializationTestCase.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/AbstractBinarySpatialFunctionSerializationTestCase.java index 1bc10f9fac6e5..b4862c52ef710 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/AbstractBinarySpatialFunctionSerializationTestCase.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/AbstractBinarySpatialFunctionSerializationTestCase.java @@ -19,7 +19,7 @@ public abstract class AbstractBinarySpatialFunctionSerializationTestCase { @Override - protected StX innerCreateTestInstance() { + protected StX createTestInstance() { return new StX(randomSource(), randomChild()); } @Override - protected StX innerMutateInstance(StX instance) throws IOException { + protected StX mutateInstance(StX instance) throws IOException { return new StX(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StYSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StYSerializationTests.java index 6f8d38802a514..5b3edb9cd0a24 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StYSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StYSerializationTests.java @@ -13,12 +13,12 @@ public class StYSerializationTests extends AbstractExpressionSerializationTests { @Override - protected StY innerCreateTestInstance() { + protected StY createTestInstance() { return new StY(randomSource(), randomChild()); } @Override - protected StY innerMutateInstance(StY instance) throws IOException { + protected StY mutateInstance(StY instance) throws IOException { return new StY(instance.source(), randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/EndsWithSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/EndsWithSerializationTests.java index e73fe8cf6af32..183e39f11b6c3 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/EndsWithSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/EndsWithSerializationTests.java @@ -15,7 +15,7 @@ public class EndsWithSerializationTests extends AbstractExpressionSerializationTests { @Override - protected EndsWith innerCreateTestInstance() { + protected EndsWith createTestInstance() { Source source = randomSource(); Expression str = randomChild(); Expression suffix = randomChild(); @@ -23,7 +23,7 @@ protected EndsWith innerCreateTestInstance() { } @Override - protected EndsWith innerMutateInstance(EndsWith instance) throws IOException { + protected EndsWith mutateInstance(EndsWith instance) throws IOException { Source source = instance.source(); Expression str = instance.str(); Expression suffix = instance.suffix(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/HashSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/HashSerializationTests.java index 06b45b52e83bb..f21105c2c8bca 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/HashSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/HashSerializationTests.java @@ -14,12 +14,12 @@ public class HashSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Hash innerCreateTestInstance() { + protected Hash createTestInstance() { return new Hash(randomSource(), randomChild(), randomChild()); } @Override - protected Hash innerMutateInstance(Hash instance) throws IOException { + protected Hash mutateInstance(Hash instance) throws IOException { return randomBoolean() ? new Hash(instance.source(), mutateExpression(instance.algorithm()), instance.input()) : new Hash(instance.source(), instance.algorithm(), mutateExpression(instance.input())); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/LeftSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/LeftSerializationTests.java index 643883bd734a6..b20d740954ff9 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/LeftSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/LeftSerializationTests.java @@ -15,7 +15,7 @@ public class LeftSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Left innerCreateTestInstance() { + protected Left createTestInstance() { Source source = randomSource(); Expression str = randomChild(); Expression length = randomChild(); @@ -23,7 +23,7 @@ protected Left innerCreateTestInstance() { } @Override - protected Left innerMutateInstance(Left instance) throws IOException { + protected Left mutateInstance(Left instance) throws IOException { Source source = instance.source(); Expression str = instance.str(); Expression length = instance.length(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/LocateSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/LocateSerializationTests.java index ba622a335cc19..a75fb9d1f772a 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/LocateSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/LocateSerializationTests.java @@ -15,7 +15,7 @@ public class LocateSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Locate innerCreateTestInstance() { + protected Locate createTestInstance() { Source source = randomSource(); Expression str = randomChild(); Expression substr = randomChild(); @@ -24,7 +24,7 @@ protected Locate innerCreateTestInstance() { } @Override - protected Locate innerMutateInstance(Locate instance) throws IOException { + protected Locate mutateInstance(Locate instance) throws IOException { Source source = instance.source(); Expression str = instance.str(); Expression substr = instance.substr(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Md5SerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Md5SerializationTests.java index c175b0b123072..666e5a3ea5d58 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Md5SerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Md5SerializationTests.java @@ -14,12 +14,12 @@ public class Md5SerializationTests extends AbstractExpressionSerializationTests { @Override - protected Md5 innerCreateTestInstance() { + protected Md5 createTestInstance() { return new Md5(randomSource(), randomChild()); } @Override - protected Md5 innerMutateInstance(Md5 instance) throws IOException { + protected Md5 mutateInstance(Md5 instance) throws IOException { return new Md5(instance.source(), mutateExpression(instance.field())); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RLikeListSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RLikeListSerializationTests.java index fd48550a7ca20..ff2dd31e2c832 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RLikeListSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RLikeListSerializationTests.java @@ -20,14 +20,14 @@ public class RLikeListSerializationTests extends AbstractExpressionSerializationTests { @Override - protected RLikeList innerCreateTestInstance() { + protected RLikeList createTestInstance() { Source source = randomSource(); Expression child = randomChild(); return new RLikeList(source, child, generateRandomPatternList()); } @Override - protected RLikeList innerMutateInstance(RLikeList instance) throws IOException { + protected RLikeList mutateInstance(RLikeList instance) throws IOException { Source source = instance.source(); Expression child = instance.field(); List patterns = new ArrayList<>(instance.pattern().patternList()); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RLikeSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RLikeSerializationTests.java index 0ae002639e6eb..0316e86ffd1bd 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RLikeSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RLikeSerializationTests.java @@ -17,7 +17,7 @@ public class RLikeSerializationTests extends AbstractExpressionSerializationTests { @Override - protected RLike innerCreateTestInstance() { + protected RLike createTestInstance() { Source source = randomSource(); Expression child = randomChild(); RLikePattern pattern = new RLikePattern(randomAlphaOfLength(4)); @@ -25,7 +25,7 @@ protected RLike innerCreateTestInstance() { } @Override - protected RLike innerMutateInstance(RLike instance) throws IOException { + protected RLike mutateInstance(RLike instance) throws IOException { Source source = instance.source(); Expression child = instance.field(); RLikePattern pattern = instance.pattern(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RepeatSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RepeatSerializationTests.java index 7738c305a48d5..6abcfdc472685 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RepeatSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RepeatSerializationTests.java @@ -15,7 +15,7 @@ public class RepeatSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Repeat innerCreateTestInstance() { + protected Repeat createTestInstance() { Source source = randomSource(); Expression str = randomChild(); Expression number = randomChild(); @@ -23,7 +23,7 @@ protected Repeat innerCreateTestInstance() { } @Override - protected Repeat innerMutateInstance(Repeat instance) throws IOException { + protected Repeat mutateInstance(Repeat instance) throws IOException { Source source = instance.source(); Expression str = instance.str(); Expression number = instance.number(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ReplaceSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ReplaceSerializationTests.java index 22e0b07863ee8..21e1f51063ceb 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ReplaceSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ReplaceSerializationTests.java @@ -15,7 +15,7 @@ public class ReplaceSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Replace innerCreateTestInstance() { + protected Replace createTestInstance() { Source source = randomSource(); Expression str = randomChild(); Expression regex = randomChild(); @@ -24,7 +24,7 @@ protected Replace innerCreateTestInstance() { } @Override - protected Replace innerMutateInstance(Replace instance) throws IOException { + protected Replace mutateInstance(Replace instance) throws IOException { Source source = instance.source(); Expression str = instance.str(); Expression regex = instance.regex(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RightSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RightSerializationTests.java index 10e68d76bf14a..7ed7345910765 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RightSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/RightSerializationTests.java @@ -15,7 +15,7 @@ public class RightSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Right innerCreateTestInstance() { + protected Right createTestInstance() { Source source = randomSource(); Expression str = randomChild(); Expression length = randomChild(); @@ -23,7 +23,7 @@ protected Right innerCreateTestInstance() { } @Override - protected Right innerMutateInstance(Right instance) throws IOException { + protected Right mutateInstance(Right instance) throws IOException { Source source = instance.source(); Expression str = instance.str(); Expression length = instance.length(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Sha1SerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Sha1SerializationTests.java index 923806163f4da..12c9cc7580de9 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Sha1SerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Sha1SerializationTests.java @@ -14,12 +14,12 @@ public class Sha1SerializationTests extends AbstractExpressionSerializationTests { @Override - protected Sha1 innerCreateTestInstance() { + protected Sha1 createTestInstance() { return new Sha1(randomSource(), randomChild()); } @Override - protected Sha1 innerMutateInstance(Sha1 instance) throws IOException { + protected Sha1 mutateInstance(Sha1 instance) throws IOException { return new Sha1(instance.source(), mutateExpression(instance.field())); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Sha256SerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Sha256SerializationTests.java index 2c98295bb3274..2f209fef25d36 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Sha256SerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Sha256SerializationTests.java @@ -14,12 +14,12 @@ public class Sha256SerializationTests extends AbstractExpressionSerializationTests { @Override - protected Sha256 innerCreateTestInstance() { + protected Sha256 createTestInstance() { return new Sha256(randomSource(), randomChild()); } @Override - protected Sha256 innerMutateInstance(Sha256 instance) throws IOException { + protected Sha256 mutateInstance(Sha256 instance) throws IOException { return new Sha256(instance.source(), mutateExpression(instance.field())); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/SpaceSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/SpaceSerializationTests.java index c0f1283a3f9f5..bf3b15145e0f3 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/SpaceSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/SpaceSerializationTests.java @@ -15,14 +15,14 @@ public class SpaceSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Space innerCreateTestInstance() { + protected Space createTestInstance() { Source source = randomSource(); Expression number = randomChild(); return new Space(source, number); } @Override - protected Space innerMutateInstance(Space instance) throws IOException { + protected Space mutateInstance(Space instance) throws IOException { Source source = instance.source(); Expression number = instance.field(); number = randomValueOtherThan(number, AbstractExpressionSerializationTests::randomChild); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/SplitSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/SplitSerializationTests.java index db35507795217..bede192c354d1 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/SplitSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/SplitSerializationTests.java @@ -15,7 +15,7 @@ public class SplitSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Split innerCreateTestInstance() { + protected Split createTestInstance() { Source source = randomSource(); Expression str = randomChild(); Expression delim = randomChild(); @@ -23,7 +23,7 @@ protected Split innerCreateTestInstance() { } @Override - protected Split innerMutateInstance(Split instance) throws IOException { + protected Split mutateInstance(Split instance) throws IOException { Source source = instance.source(); Expression str = instance.str(); Expression delim = instance.delim(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/StartsWithSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/StartsWithSerializationTests.java index 821f9bfc7f1b3..1b1167879b212 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/StartsWithSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/StartsWithSerializationTests.java @@ -15,7 +15,7 @@ public class StartsWithSerializationTests extends AbstractExpressionSerializationTests { @Override - protected StartsWith innerCreateTestInstance() { + protected StartsWith createTestInstance() { Source source = randomSource(); Expression str = randomChild(); Expression prefix = randomChild(); @@ -23,7 +23,7 @@ protected StartsWith innerCreateTestInstance() { } @Override - protected StartsWith innerMutateInstance(StartsWith instance) throws IOException { + protected StartsWith mutateInstance(StartsWith instance) throws IOException { Source source = instance.source(); Expression str = instance.str(); Expression prefix = instance.prefix(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/SubstringSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/SubstringSerializationTests.java index dd0d1d1e9b8a3..accbed6e8f613 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/SubstringSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/SubstringSerializationTests.java @@ -15,7 +15,7 @@ public class SubstringSerializationTests extends AbstractExpressionSerializationTests { @Override - protected Substring innerCreateTestInstance() { + protected Substring createTestInstance() { Source source = randomSource(); Expression str = randomChild(); Expression start = randomChild(); @@ -24,7 +24,7 @@ protected Substring innerCreateTestInstance() { } @Override - protected Substring innerMutateInstance(Substring instance) throws IOException { + protected Substring mutateInstance(Substring instance) throws IOException { Source source = instance.source(); Expression str = instance.str(); Expression start = instance.start(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToLowerSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToLowerSerializationTests.java index a392b32737b99..5950aeffea79a 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToLowerSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToLowerSerializationTests.java @@ -15,12 +15,12 @@ public class ToLowerSerializationTests extends AbstractExpressionSerializationTests { @Override - protected ToLower innerCreateTestInstance() { + protected ToLower createTestInstance() { return new ToLower(randomSource(), randomChild(), configuration()); } @Override - protected ToLower innerMutateInstance(ToLower instance) throws IOException { + protected ToLower mutateInstance(ToLower instance) throws IOException { Source source = instance.source(); Expression child = randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild); return new ToLower(source, child, configuration()); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToUpperSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToUpperSerializationTests.java index 8f33c0dcbb215..74d891ac2f5cd 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToUpperSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToUpperSerializationTests.java @@ -15,12 +15,12 @@ public class ToUpperSerializationTests extends AbstractExpressionSerializationTests { @Override - protected ToUpper innerCreateTestInstance() { + protected ToUpper createTestInstance() { return new ToUpper(randomSource(), randomChild(), configuration()); } @Override - protected ToUpper innerMutateInstance(ToUpper instance) throws IOException { + protected ToUpper mutateInstance(ToUpper instance) throws IOException { Source source = instance.source(); Expression child = randomValueOtherThan(instance.field(), AbstractExpressionSerializationTests::randomChild); return new ToUpper(source, child, configuration()); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/WildcardLikeListSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/WildcardLikeListSerializationTests.java index 2d061285d9b22..f9b903c473547 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/WildcardLikeListSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/WildcardLikeListSerializationTests.java @@ -20,14 +20,14 @@ public class WildcardLikeListSerializationTests extends AbstractExpressionSerializationTests { @Override - protected WildcardLikeList innerCreateTestInstance() { + protected WildcardLikeList createTestInstance() { Source source = randomSource(); Expression child = randomChild(); return new WildcardLikeList(source, child, generateRandomPatternList()); } @Override - protected WildcardLikeList innerMutateInstance(WildcardLikeList instance) throws IOException { + protected WildcardLikeList mutateInstance(WildcardLikeList instance) throws IOException { Source source = instance.source(); Expression child = instance.field(); List patterns = new ArrayList<>(instance.pattern().patternList()); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/WildcardLikeSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/WildcardLikeSerializationTests.java index c35902506644a..d1399d5e635c6 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/WildcardLikeSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/WildcardLikeSerializationTests.java @@ -17,7 +17,7 @@ public class WildcardLikeSerializationTests extends AbstractExpressionSerializationTests { @Override - protected WildcardLike innerCreateTestInstance() { + protected WildcardLike createTestInstance() { Source source = randomSource(); Expression child = randomChild(); WildcardPattern pattern = new WildcardPattern(randomAlphaOfLength(4)); @@ -25,7 +25,7 @@ protected WildcardLike innerCreateTestInstance() { } @Override - protected WildcardLike innerMutateInstance(WildcardLike instance) throws IOException { + protected WildcardLike mutateInstance(WildcardLike instance) throws IOException { Source source = instance.source(); Expression child = instance.field(); WildcardPattern pattern = instance.pattern(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/AbstractArithmeticSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/AbstractArithmeticSerializationTests.java index 0e141273c812c..81860addf1c5e 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/AbstractArithmeticSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/AbstractArithmeticSerializationTests.java @@ -18,12 +18,12 @@ public abstract class AbstractArithmeticSerializationTests { @Override - protected In innerCreateTestInstance() { + protected In createTestInstance() { Source source = randomSource(); Expression value = randomChild(); List list = randomList(10, AbstractExpressionSerializationTests::randomChild); @@ -24,7 +24,7 @@ protected In innerCreateTestInstance() { } @Override - protected In innerMutateInstance(In instance) throws IOException { + protected In mutateInstance(In instance) throws IOException { Source source = instance.source(); Expression value = instance.value(); List list = instance.list(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InsensitiveEqualsSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InsensitiveEqualsSerializationTests.java index fb374f2d23e65..7ca1e27ba510a 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InsensitiveEqualsSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InsensitiveEqualsSerializationTests.java @@ -14,12 +14,12 @@ public class InsensitiveEqualsSerializationTests extends AbstractExpressionSerializationTests { @Override - protected final InsensitiveEquals innerCreateTestInstance() { + protected final InsensitiveEquals createTestInstance() { return new InsensitiveEquals(randomSource(), randomChild(), randomChild()); } @Override - protected final InsensitiveEquals innerMutateInstance(InsensitiveEquals instance) throws IOException { + protected final InsensitiveEquals mutateInstance(InsensitiveEquals instance) throws IOException { Expression left = instance.left(); Expression right = instance.right(); if (randomBoolean()) { diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plan/AbstractNodeSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plan/AbstractNodeSerializationTests.java index 21c92d786b6d6..701b80978bb68 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plan/AbstractNodeSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plan/AbstractNodeSerializationTests.java @@ -9,19 +9,13 @@ import org.elasticsearch.TransportVersion; import org.elasticsearch.test.AbstractWireTestCase; +import org.elasticsearch.xpack.esql.SerializationTestUtils; import org.elasticsearch.xpack.esql.core.expression.Attribute; -import org.elasticsearch.xpack.esql.core.expression.Expression; -import org.elasticsearch.xpack.esql.core.expression.NameId; -import org.elasticsearch.xpack.esql.core.expression.NamedExpression; import org.elasticsearch.xpack.esql.core.tree.Node; import org.elasticsearch.xpack.esql.core.tree.Source; import org.elasticsearch.xpack.esql.expression.function.FieldAttributeTests; import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput; import org.elasticsearch.xpack.esql.io.stream.PlanStreamOutput; -import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan; -import org.elasticsearch.xpack.esql.plan.logical.Lookup; -import org.elasticsearch.xpack.esql.plan.physical.FragmentExec; -import org.elasticsearch.xpack.esql.plan.physical.PhysicalPlan; import org.elasticsearch.xpack.esql.session.Configuration; import org.junit.Before; @@ -57,47 +51,9 @@ public static List randomFieldAttributes(int min, int max, boolean on return randomList(min, max, () -> FieldAttributeTests.createFieldAttribute(0, onlyRepresentable)); } - /** - * Reuses existing {@link NameId}s when deserializing a tree, rather than creating new ones all the time. This makes testing for - * equality easier because deserialized nodes will have the same {@link NameId} instances as the original ones. - */ - private static class TestIdsNameMapper extends PlanStreamInput.NameIdMapper { - private void add(NameId id) { - seen().computeIfAbsent(id.id(), unused -> id); - } - - public void collectNameIds(Node node) { - if (node instanceof Expression e) { - e.forEachDown(NamedExpression.class, ne -> add(ne.id())); - return; - } - - if (node instanceof QueryPlan p) { - p.forEachExpressionDown(NamedExpression.class, ne -> add(ne.id())); - } - - if (node instanceof LogicalPlan lp) { - lp.forEachDown(Lookup.class, lookup -> { - if (lookup.localRelation() != null) { - // The LocalRelation is not seen as part of the plan tree so we need to explicitly collect its NameIds. - collectNameIds(lookup.localRelation()); - } - }); - } - - if (node instanceof PhysicalPlan p) { - p.forEachDown(FragmentExec.class, fragmentExec -> { - // The fragment is not seen as part of the plan tree so we need to explicitly collect its NameIds. - LogicalPlan fragment = fragmentExec.fragment(); - collectNameIds(fragment); - }); - } - } - } - @Override protected T copyInstance(T instance, TransportVersion version) throws IOException { - TestIdsNameMapper idsNameMapper = new TestIdsNameMapper(); + SerializationTestUtils.TestNameIdMapper idsNameMapper = new SerializationTestUtils.TestNameIdMapper(); idsNameMapper.collectNameIds(instance); return copyInstance( From 4dab56ba084a1490e2f0614f0abadf6c244dd099 Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Fri, 26 Sep 2025 14:19:57 +0200 Subject: [PATCH 21/38] Simplify de-/serialization tests some more Don't even walk the plan to collect name ids, that's silly. --- .../xpack/esql/core/expression/NameId.java | 8 +++ .../xpack/esql/SerializationTestUtils.java | 58 ++----------------- .../plan/AbstractNodeSerializationTests.java | 10 ++-- 3 files changed, 20 insertions(+), 56 deletions(-) diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/NameId.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/NameId.java index 859f46e26ff18..28728c6f265af 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/NameId.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/NameId.java @@ -31,6 +31,14 @@ public NameId() { this.id = COUNTER.incrementAndGet(); } + /** + * Absolutely only intended for tests, esp. to deal with serialization. Never use in production as it breaks the + * uniqueness guarantee. + */ + public NameId(long id) { + this.id = id; + } + /** * For testing only. Otherwise, we only use name ids for equality checks and de-/serialization and don't rely on their exact * representation as long values. diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/SerializationTestUtils.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/SerializationTestUtils.java index e63d2f64f5ec8..9521a74c1db2b 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/SerializationTestUtils.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/SerializationTestUtils.java @@ -28,16 +28,11 @@ import org.elasticsearch.test.EqualsHashCodeTestUtils; import org.elasticsearch.xpack.esql.core.expression.Expression; import org.elasticsearch.xpack.esql.core.expression.NameId; -import org.elasticsearch.xpack.esql.core.expression.NamedExpression; -import org.elasticsearch.xpack.esql.core.tree.Node; import org.elasticsearch.xpack.esql.expression.ExpressionWritables; import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput; import org.elasticsearch.xpack.esql.io.stream.PlanStreamOutput; import org.elasticsearch.xpack.esql.plan.PlanWritables; -import org.elasticsearch.xpack.esql.plan.QueryPlan; import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan; -import org.elasticsearch.xpack.esql.plan.logical.Lookup; -import org.elasticsearch.xpack.esql.plan.physical.FragmentExec; import org.elasticsearch.xpack.esql.plan.physical.PhysicalPlan; import org.elasticsearch.xpack.esql.querydsl.query.SingleValueQuery; import org.elasticsearch.xpack.esql.session.Configuration; @@ -90,15 +85,11 @@ public static T serializeDeserialize(T orig, Serializer serializer, Deser PlanStreamOutput planStreamOutput = new PlanStreamOutput(out, config); serializer.write(planStreamOutput, orig); - PlanStreamInput.NameIdMapper nameIdMapper = orig instanceof Node node - // For trees, reuse the NameIds to make equality testing easier - ? new TestNameIdMapper(node) - : new PlanStreamInput.NameIdMapper(); StreamInput in = new NamedWriteableAwareStreamInput( ByteBufferStreamInput.wrap(BytesReference.toBytes(out.bytes())), writableRegistry() ); - PlanStreamInput planStreamInput = new PlanStreamInput(in, in.namedWriteableRegistry(), config, nameIdMapper); + PlanStreamInput planStreamInput = new PlanStreamInput(in, in.namedWriteableRegistry(), config, new TestNameIdMapper()); return deserializer.read(planStreamInput); } catch (IOException e) { throw new UncheckedIOException(e); @@ -138,50 +129,13 @@ public static NamedWriteableRegistry writableRegistry() { } /** - * Reuses existing {@link NameId}s when deserializing a tree, rather than creating new ones all the time. This makes testing for - * equality easier because deserialized nodes will have the same {@link NameId} instances as the original ones. + * Maps NameIds seen in a plan to themselves rather than creating new, unique ones. + * This makes equality checks easier when comparing a plan to itself after serialization and deserialization. */ public static class TestNameIdMapper extends PlanStreamInput.NameIdMapper { - public TestNameIdMapper() { - super(); - }; - - @SuppressWarnings("this-escape") - public TestNameIdMapper(Node node) { - super(); - collectNameIds(node); - } - - private void add(NameId id) { - seen().computeIfAbsent(id.id(), unused -> id); - } - - public void collectNameIds(Node node) { - if (node instanceof Expression e) { - e.forEachDown(NamedExpression.class, ne -> add(ne.id())); - return; - } - - if (node instanceof QueryPlan p) { - p.forEachExpressionDown(NamedExpression.class, ne -> add(ne.id())); - } - - if (node instanceof LogicalPlan lp) { - lp.forEachDown(Lookup.class, lookup -> { - if (lookup.localRelation() != null) { - // The LocalRelation is not seen as part of the plan tree so we need to explicitly collect its NameIds. - collectNameIds(lookup.localRelation()); - } - }); - } - - if (node instanceof PhysicalPlan p) { - p.forEachDown(FragmentExec.class, fragmentExec -> { - // The fragment is not seen as part of the plan tree so we need to explicitly collect its NameIds. - LogicalPlan fragment = fragmentExec.fragment(); - collectNameIds(fragment); - }); - } + @Override + public NameId apply(long streamNameId) { + return new NameId(streamNameId); } } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plan/AbstractNodeSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plan/AbstractNodeSerializationTests.java index 701b80978bb68..e8eed17944b4a 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plan/AbstractNodeSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plan/AbstractNodeSerializationTests.java @@ -53,15 +53,17 @@ public static List randomFieldAttributes(int min, int max, boolean on @Override protected T copyInstance(T instance, TransportVersion version) throws IOException { - SerializationTestUtils.TestNameIdMapper idsNameMapper = new SerializationTestUtils.TestNameIdMapper(); - idsNameMapper.collectNameIds(instance); - return copyInstance( instance, getNamedWriteableRegistry(), (out, v) -> new PlanStreamOutput(out, configuration()).writeNamedWriteable(v), in -> { - PlanStreamInput pin = new PlanStreamInput(in, in.namedWriteableRegistry(), configuration(), idsNameMapper); + PlanStreamInput pin = new PlanStreamInput( + in, + in.namedWriteableRegistry(), + configuration(), + new SerializationTestUtils.TestNameIdMapper() + ); @SuppressWarnings("unchecked") T deser = (T) pin.readNamedWriteable(categoryClass()); if (alwaysEmptySource()) { From 5f62f7283b08f6fb450e559c8deba59889c552c6 Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Fri, 26 Sep 2025 16:39:35 +0200 Subject: [PATCH 22/38] Fix analyzer tests --- .../xpack/esql/EsqlTestUtils.java | 64 +++++++++++++++++++ .../xpack/esql/analysis/AnalyzerTests.java | 49 ++++++++------ 2 files changed, 92 insertions(+), 21 deletions(-) diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java b/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java index d89c65a620a98..4224eaf7b088f 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java @@ -56,12 +56,15 @@ import org.elasticsearch.xpack.esql.action.EsqlQueryResponse; import org.elasticsearch.xpack.esql.analysis.EnrichResolution; import org.elasticsearch.xpack.esql.analysis.Verifier; +import org.elasticsearch.xpack.esql.core.expression.Alias; import org.elasticsearch.xpack.esql.core.expression.Attribute; import org.elasticsearch.xpack.esql.core.expression.Expression; import org.elasticsearch.xpack.esql.core.expression.FieldAttribute; import org.elasticsearch.xpack.esql.core.expression.FieldAttribute.FieldName; import org.elasticsearch.xpack.esql.core.expression.FoldContext; import org.elasticsearch.xpack.esql.core.expression.Literal; +import org.elasticsearch.xpack.esql.core.expression.NameId; +import org.elasticsearch.xpack.esql.core.expression.NamedExpression; import org.elasticsearch.xpack.esql.core.expression.ReferenceAttribute; import org.elasticsearch.xpack.esql.core.expression.predicate.regex.RLikePattern; import org.elasticsearch.xpack.esql.core.expression.predicate.regex.WildcardPattern; @@ -95,6 +98,8 @@ import org.elasticsearch.xpack.esql.plan.logical.local.EmptyLocalSupplier; import org.elasticsearch.xpack.esql.plan.logical.local.LocalRelation; import org.elasticsearch.xpack.esql.plan.logical.local.LocalSupplier; +import org.elasticsearch.xpack.esql.plan.physical.FragmentExec; +import org.elasticsearch.xpack.esql.plan.physical.PhysicalPlan; import org.elasticsearch.xpack.esql.planner.PlannerUtils; import org.elasticsearch.xpack.esql.plugin.EsqlPlugin; import org.elasticsearch.xpack.esql.plugin.QueryPragmas; @@ -103,6 +108,7 @@ import org.elasticsearch.xpack.esql.stats.SearchStats; import org.elasticsearch.xpack.esql.telemetry.Metrics; import org.elasticsearch.xpack.versionfield.Version; +import org.hamcrest.core.IsEqual; import org.junit.Assert; import java.io.BufferedReader; @@ -974,4 +980,62 @@ public static Exception unwrapIfWrappedInRemoteException(Exception e) { return e; } } + + /** + * Returns a matcher that matches if the examined object is logically equal to the specified + * operand, ignoring the {@link NameId}s of any {@link NamedExpression}s (e.g. {@link Alias} and {@link Attribute}). + */ + public static org.hamcrest.Matcher equalToIgnoringIds(T operand) { + return new IsEqualIgnoringIds(operand); + } + + private static class IsEqualIgnoringIds extends IsEqual { + @SuppressWarnings("unchecked") + IsEqualIgnoringIds(T operand) { + super((T) ignoreIds(operand)); + } + + @Override + public boolean matches(Object actualValue) { + return super.matches(ignoreIds(actualValue)); + } + } + + private static Object ignoreIds(Object node) { + return switch (node) { + case Expression expression -> ignoreIdsInExpression(expression); + case LogicalPlan plan -> ignoreIdsInLogicalPlan(plan); + case PhysicalPlan pplan -> ignoreIdsInPhysicalPlan(pplan); + case List list -> list.stream().map(EsqlTestUtils::ignoreIds).toList(); + case null, default -> node; + }; + } + + private static final NameId DUMMY_ID = new NameId(); + + private static Expression ignoreIdsInExpression(Expression expression) { + return expression.transformDown( + NamedExpression.class, + ne -> ne instanceof Alias alias ? alias.withId(DUMMY_ID) : ne instanceof Attribute attr ? attr.withId(DUMMY_ID) : ne + ); + } + + private static LogicalPlan ignoreIdsInLogicalPlan(LogicalPlan plan) { + return plan.transformExpressionsDown( + NamedExpression.class, + ne -> ne instanceof Alias alias ? alias.withId(DUMMY_ID) : ne instanceof Attribute attr ? attr.withId(DUMMY_ID) : ne + ); + } + + private static PhysicalPlan ignoreIdsInPhysicalPlan(PhysicalPlan plan) { + PhysicalPlan ignoredInPhysicalNodes = plan.transformExpressionsDown( + NamedExpression.class, + ne -> ne instanceof Alias alias ? alias.withId(DUMMY_ID) : ne instanceof Attribute attr ? attr.withId(DUMMY_ID) : ne + ); + return ignoredInPhysicalNodes.transformDown(FragmentExec.class, fragmentExec -> { + LogicalPlan fragment = fragmentExec.fragment(); + LogicalPlan ignoredInFragment = ignoreIdsInLogicalPlan(fragment); + return fragmentExec.withFragment(ignoredInFragment); + }); + } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java index 896f9d7036b1f..3fb3c66879405 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java @@ -117,6 +117,7 @@ import static org.elasticsearch.xpack.esql.EsqlTestUtils.as; import static org.elasticsearch.xpack.esql.EsqlTestUtils.configuration; import static org.elasticsearch.xpack.esql.EsqlTestUtils.emptyInferenceResolution; +import static org.elasticsearch.xpack.esql.EsqlTestUtils.equalToIgnoringIds; import static org.elasticsearch.xpack.esql.EsqlTestUtils.getAttributeByName; import static org.elasticsearch.xpack.esql.EsqlTestUtils.paramAsConstant; import static org.elasticsearch.xpack.esql.EsqlTestUtils.paramAsIdentifier; @@ -215,7 +216,10 @@ public void testAttributeResolution() { var limit = as(plan, Limit.class); var eval = as(limit.child(), Eval.class); assertEquals(1, eval.fields().size()); - assertEquals(new Alias(EMPTY, "e", new FieldAttribute(EMPTY, "emp_no", idx.mapping().get("emp_no"))), eval.fields().get(0)); + assertThat( + eval.fields().get(0), + equalToIgnoringIds(new Alias(EMPTY, "e", new FieldAttribute(EMPTY, "emp_no", idx.mapping().get("emp_no")))) + ); assertEquals(2, eval.output().size()); Attribute empNo = eval.output().get(0); @@ -272,7 +276,10 @@ public void testRowAttributeResolution() { var limit = as(plan, Limit.class); var eval = as(limit.child(), Eval.class); assertEquals(1, eval.fields().size()); - assertEquals(new Alias(EMPTY, "e", new ReferenceAttribute(EMPTY, "emp_no", DataType.INTEGER)), eval.fields().get(0)); + assertThat( + eval.fields().get(0), + equalToIgnoringIds(new Alias(EMPTY, "e", new ReferenceAttribute(EMPTY, "emp_no", DataType.INTEGER))) + ); assertEquals(2, eval.output().size()); Attribute empNo = eval.output().get(0); @@ -3166,8 +3173,8 @@ public void testResolveInsist_fieldDoesNotExist_createsUnmappedField() { var insist = as(limit.child(), Insist.class); assertThat(insist.output(), hasSize(analyze("FROM test").output().size() + 1)); var expectedAttribute = new FieldAttribute(Source.EMPTY, "foo", new PotentiallyUnmappedKeywordEsField("foo")); - assertThat(insist.insistedAttributes(), is(List.of(expectedAttribute))); - assertThat(insist.output().getLast(), is(expectedAttribute)); + assertThat(insist.insistedAttributes(), equalToIgnoringIds(List.of(expectedAttribute))); + assertThat(insist.output().getLast(), equalToIgnoringIds(expectedAttribute)); } public void testResolveInsist_multiIndexFieldPartiallyMappedWithSingleKeywordType_createsUnmappedField() { @@ -3335,7 +3342,7 @@ public void testBasicFork() { List projectColumns = project.expressions().stream().map(exp -> as(exp, Attribute.class).name()).toList(); assertThat(projectColumns, equalTo(expectedOutput)); Eval eval = as(project.child(), Eval.class); - assertThat(as(eval.fields().get(0), Alias.class), equalTo(alias("_fork", string("fork1")))); + assertThat(as(eval.fields().get(0), Alias.class), equalToIgnoringIds(alias("_fork", string("fork1")))); Filter filter = as(eval.child(), Filter.class); assertThat(as(filter.condition(), GreaterThan.class).right(), equalTo(literal(1))); @@ -3352,7 +3359,7 @@ public void testBasicFork() { projectColumns = project.expressions().stream().map(exp -> as(exp, Attribute.class).name()).toList(); assertThat(projectColumns, equalTo(expectedOutput)); eval = as(project.child(), Eval.class); - assertThat(as(eval.fields().get(0), Alias.class), equalTo(alias("_fork", string("fork2")))); + assertThat(as(eval.fields().get(0), Alias.class), equalToIgnoringIds(alias("_fork", string("fork2")))); filter = as(eval.child(), Filter.class); assertThat(as(filter.condition(), GreaterThan.class).right(), equalTo(literal(2))); @@ -3369,7 +3376,7 @@ public void testBasicFork() { projectColumns = project.expressions().stream().map(exp -> as(exp, Attribute.class).name()).toList(); assertThat(projectColumns, equalTo(expectedOutput)); eval = as(project.child(), Eval.class); - assertThat(as(eval.fields().get(0), Alias.class), equalTo(alias("_fork", string("fork3")))); + assertThat(as(eval.fields().get(0), Alias.class), equalToIgnoringIds(alias("_fork", string("fork3")))); limit = as(eval.child(), Limit.class); assertThat(as(limit.limit(), Literal.class).value(), equalTo(7)); var orderBy = as(limit.child(), OrderBy.class); @@ -3388,7 +3395,7 @@ public void testBasicFork() { projectColumns = project.expressions().stream().map(exp -> as(exp, Attribute.class).name()).toList(); assertThat(projectColumns, equalTo(expectedOutput)); eval = as(project.child(), Eval.class); - assertThat(as(eval.fields().get(0), Alias.class), equalTo(alias("_fork", string("fork4")))); + assertThat(as(eval.fields().get(0), Alias.class), equalToIgnoringIds(alias("_fork", string("fork4")))); orderBy = as(eval.child(), OrderBy.class); filter = as(orderBy.child(), Filter.class); assertThat(as(filter.condition(), Equals.class).right(), equalTo(string("Chris"))); @@ -3403,7 +3410,7 @@ public void testBasicFork() { projectColumns = project.expressions().stream().map(exp -> as(exp, Attribute.class).name()).toList(); assertThat(projectColumns, equalTo(expectedOutput)); eval = as(project.child(), Eval.class); - assertThat(as(eval.fields().get(0), Alias.class), equalTo(alias("_fork", string("fork5")))); + assertThat(as(eval.fields().get(0), Alias.class), equalToIgnoringIds(alias("_fork", string("fork5")))); limit = as(eval.child(), Limit.class); assertThat(as(limit.limit(), Literal.class).value(), equalTo(9)); filter = as(limit.child(), Filter.class); @@ -3449,7 +3456,7 @@ public void testForkBranchesWithDifferentSchemas() { } eval = as(eval.child(), Eval.class); - assertThat(as(eval.fields().get(0), Alias.class), equalTo(alias("_fork", string("fork1")))); + assertThat(as(eval.fields().get(0), Alias.class), equalToIgnoringIds(alias("_fork", string("fork1")))); limit = as(eval.child(), Limit.class); assertThat(as(limit.limit(), Literal.class).value(), equalTo(7)); var orderBy = as(limit.child(), OrderBy.class); @@ -3478,7 +3485,7 @@ public void testForkBranchesWithDifferentSchemas() { } eval = as(eval.child(), Eval.class); - assertThat(as(eval.fields().get(0), Alias.class), equalTo(alias("_fork", string("fork2")))); + assertThat(as(eval.fields().get(0), Alias.class), equalToIgnoringIds(alias("_fork", string("fork2")))); eval = as(eval.child(), Eval.class); Alias alias = as(eval.fields().get(0), Alias.class); assertThat(alias.name(), equalTo("xyz")); @@ -3508,7 +3515,7 @@ public void testForkBranchesWithDifferentSchemas() { } eval = as(eval.child(), Eval.class); - assertThat(as(eval.fields().get(0), Alias.class), equalTo(alias("_fork", string("fork3")))); + assertThat(as(eval.fields().get(0), Alias.class), equalToIgnoringIds(alias("_fork", string("fork3")))); eval = as(eval.child(), Eval.class); alias = as(eval.fields().get(0), Alias.class); @@ -3940,7 +3947,7 @@ public void testResolveRerankFields() { assertThat(rerank.queryText(), equalTo(string("italian food recipe"))); assertThat(rerank.inferenceId(), equalTo(string("reranking-inference-id"))); - assertThat(rerank.rerankFields(), equalTo(List.of(alias("title", titleAttribute)))); + assertThat(rerank.rerankFields(), equalToIgnoringIds(List.of(alias("title", titleAttribute)))); assertThat(rerank.scoreAttribute(), equalTo(getAttributeByName(relation.output(), MetadataAttribute.SCORE))); } @@ -3964,7 +3971,7 @@ public void testResolveRerankFields() { assertThat(rerank.rerankFields(), hasSize(3)); Attribute titleAttribute = getAttributeByName(relation.output(), "title"); assertThat(titleAttribute, notNullValue()); - assertThat(rerank.rerankFields().get(0), equalTo(alias("title", titleAttribute))); + assertThat(rerank.rerankFields().get(0), equalToIgnoringIds(alias("title", titleAttribute))); Attribute descriptionAttribute = getAttributeByName(relation.output(), "description"); assertThat(descriptionAttribute, notNullValue()); @@ -3977,7 +3984,7 @@ public void testResolveRerankFields() { Attribute yearAttribute = getAttributeByName(relation.output(), "year"); assertThat(yearAttribute, notNullValue()); - assertThat(rerank.rerankFields().get(2), equalTo(alias("yearRenamed", yearAttribute))); + assertThat(rerank.rerankFields().get(2), equalToIgnoringIds(alias("yearRenamed", yearAttribute))); assertThat(rerank.scoreAttribute(), equalTo(getAttributeByName(relation.output(), MetadataAttribute.SCORE))); } @@ -4028,7 +4035,7 @@ public void testResolveRerankScoreField() { EsRelation relation = as(filter.child(), EsRelation.class); assertThat(relation.output().stream().noneMatch(attr -> attr.name().equals(MetadataAttribute.SCORE)), is(true)); - assertThat(rerank.scoreAttribute(), equalTo(MetadataAttribute.create(EMPTY, MetadataAttribute.SCORE))); + assertThat(rerank.scoreAttribute(), equalToIgnoringIds(MetadataAttribute.create(EMPTY, MetadataAttribute.SCORE))); assertThat(rerank.output(), hasItem(rerank.scoreAttribute())); } @@ -4129,12 +4136,12 @@ public void testRerankFieldValidTypes() { EsRelation relation = as(rerank.child(), EsRelation.class); Attribute fieldAttribute = getAttributeByName(relation.output(), fieldName); if (DataType.isString(fieldAttribute.dataType())) { - assertThat(rerank.rerankFields(), equalTo(List.of(alias(fieldName, fieldAttribute)))); + assertThat(rerank.rerankFields(), equalToIgnoringIds(List.of(alias(fieldName, fieldAttribute)))); } else { assertThat( rerank.rerankFields(), - equalTo(List.of(alias(fieldName, new ToString(fieldAttribute.source(), fieldAttribute)))) + equalToIgnoringIds(List.of(alias(fieldName, new ToString(fieldAttribute.source(), fieldAttribute)))) ); } } @@ -4192,7 +4199,7 @@ public void testResolveCompletionTargetField() { """, "mapping-books.json"); Completion completion = as(as(plan, Limit.class).child(), Completion.class); - assertThat(completion.targetField(), equalTo(referenceAttribute("translation", DataType.KEYWORD))); + assertThat(completion.targetField(), equalToIgnoringIds(referenceAttribute("translation", DataType.KEYWORD))); } public void testResolveCompletionDefaultTargetField() { @@ -4202,7 +4209,7 @@ public void testResolveCompletionDefaultTargetField() { """, "mapping-books.json"); Completion completion = as(as(plan, Limit.class).child(), Completion.class); - assertThat(completion.targetField(), equalTo(referenceAttribute("completion", DataType.KEYWORD))); + assertThat(completion.targetField(), equalToIgnoringIds(referenceAttribute("completion", DataType.KEYWORD))); } public void testResolveCompletionPrompt() { @@ -4235,7 +4242,7 @@ public void testResolveCompletionOutputFieldOverwriteInputField() { """, "mapping-books.json"); Completion completion = as(as(plan, Limit.class).child(), Completion.class); - assertThat(completion.targetField(), equalTo(referenceAttribute("description", DataType.KEYWORD))); + assertThat(completion.targetField(), equalToIgnoringIds(referenceAttribute("description", DataType.KEYWORD))); EsRelation esRelation = as(completion.child(), EsRelation.class); assertThat(getAttributeByName(completion.output(), "description"), equalTo(completion.targetField())); From f5add18d27a3c764a5ff74d0b5239abedb631e39 Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Fri, 26 Sep 2025 17:30:20 +0200 Subject: [PATCH 23/38] Fix equality for failures UnresolvedAttribute's ids specifically shouldn't matter here. --- .../xpack/esql/core/expression/Attribute.java | 6 +++--- .../esql/core/expression/EmptyAttribute.java | 2 +- .../esql/core/expression/FieldAttribute.java | 2 +- .../esql/core/expression/MetadataAttribute.java | 2 +- .../xpack/esql/core/expression/NameId.java | 8 -------- .../esql/core/expression/TypedAttribute.java | 2 +- .../core/expression/UnresolvedAttribute.java | 2 +- .../xpack/esql/common/Failure.java | 17 +++++++++++++++++ .../xpack/esql/common/Failures.java | 8 ++++---- .../function/UnsupportedAttribute.java | 2 +- 10 files changed, 30 insertions(+), 21 deletions(-) diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java index 03fd466092173..474de5690aa5a 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java @@ -215,14 +215,14 @@ protected Expression canonicalize() { *

* Does not perform the usual instance and class equality checks, those are already done in {@link NamedExpression#equals(Object)} */ - protected boolean nonSemanticEquals(Attribute other) { + public boolean nonSemanticEquals(Attribute other) { return super.innerEquals(other) && Objects.equals(qualifier, other.qualifier) && Objects.equals(nullability, other.nullability); } /** * Hashcode that's consistent with {@link #nonSemanticEquals(Attribute)}. Hashes everything but the id. */ - protected int nonSemanticHashCode() { + public int nonSemanticHashCode() { return Objects.hash(super.hashCode(), qualifier, nullability); } @@ -232,7 +232,7 @@ protected int nonSemanticHashCode() { @Override @SuppressWarnings("checkstyle:EqualsHashCode")// equals is implemented in parent. See innerEquals instead public int hashCode() { - return Objects.hash(super.hashCode(), id(), nonSemanticHashCode()); + return Objects.hash(id(), nonSemanticHashCode()); } /** diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/EmptyAttribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/EmptyAttribute.java index fd9bc66dac138..55b6eb649da2c 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/EmptyAttribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/EmptyAttribute.java @@ -84,7 +84,7 @@ public int nonSemanticHashCode() { } @Override - protected boolean nonSemanticEquals(Attribute o) { + public boolean nonSemanticEquals(Attribute o) { return true; } diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/FieldAttribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/FieldAttribute.java index 5d88d60ca444d..ce361de46b701 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/FieldAttribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/FieldAttribute.java @@ -234,7 +234,7 @@ public int nonSemanticHashCode() { } @Override - protected boolean nonSemanticEquals(Attribute o) { + public boolean nonSemanticEquals(Attribute o) { var other = (FieldAttribute) o; return super.nonSemanticEquals(other) && Objects.equals(parentName, other.parentName) && Objects.equals(field, other.field); } diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/MetadataAttribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/MetadataAttribute.java index e608b128878f1..1593326612338 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/MetadataAttribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/MetadataAttribute.java @@ -174,7 +174,7 @@ public int nonSemanticHashCode() { } @Override - protected boolean nonSemanticEquals(Attribute o) { + public boolean nonSemanticEquals(Attribute o) { var other = (MetadataAttribute) o; return super.nonSemanticEquals(other) && searchable == other.searchable; } diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/NameId.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/NameId.java index 28728c6f265af..19294a60ddd0a 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/NameId.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/NameId.java @@ -39,14 +39,6 @@ public NameId(long id) { this.id = id; } - /** - * For testing only. Otherwise, we only use name ids for equality checks and de-/serialization and don't rely on their exact - * representation as long values. - */ - public long id() { - return id; - } - @Override public int hashCode() { return Long.hashCode(id); diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypedAttribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypedAttribute.java index f7d035077d099..224605c3308ec 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypedAttribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypedAttribute.java @@ -55,7 +55,7 @@ public int nonSemanticHashCode() { } @Override - protected boolean nonSemanticEquals(Attribute o) { + public boolean nonSemanticEquals(Attribute o) { var other = (TypedAttribute) o; return super.nonSemanticEquals(other) && dataType == other.dataType; } diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedAttribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedAttribute.java index 9a4c97e915a67..1f0c2d78a38d9 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedAttribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedAttribute.java @@ -180,7 +180,7 @@ public int nonSemanticHashCode() { * distinguish the attributes generated by the {@code EVAL} from attributes referenced by it. */ @Override - protected boolean nonSemanticEquals(Attribute o) { + public boolean nonSemanticEquals(Attribute o) { var other = (UnresolvedAttribute) o; return super.nonSemanticEquals(other) && Objects.equals(resolutionMetadata, other.resolutionMetadata) diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/common/Failure.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/common/Failure.java index e5d0fb7ba0b3d..b805870966aff 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/common/Failure.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/common/Failure.java @@ -7,6 +7,7 @@ package org.elasticsearch.xpack.esql.common; +import org.elasticsearch.xpack.esql.core.expression.UnresolvedAttribute; import org.elasticsearch.xpack.esql.core.tree.Location; import org.elasticsearch.xpack.esql.core.tree.Node; import org.elasticsearch.xpack.esql.core.util.StringUtils; @@ -37,9 +38,15 @@ public String message() { @Override public int hashCode() { + if (node instanceof UnresolvedAttribute ua) { + return ua.nonSemanticHashCode(); + } return Objects.hash(node); } + /** + * Equality is based on the contained node, the failure is "attached" to it. + */ @Override public boolean equals(Object obj) { if (this == obj) { @@ -51,6 +58,16 @@ public boolean equals(Object obj) { } Failure other = (Failure) obj; + + // When deduplicating failures, it's important to ignore the NameIds of UnresolvedAttributes. + // Otherwise, two failures will be emitted to the user for e.g. + // `FROM test | STATS max(unknown) by unknown` because the two `unknown` attributes will have differentNameIds - even though they + // clearly refer to the same problem. + if (node instanceof UnresolvedAttribute ua + && other.node instanceof UnresolvedAttribute otherUa + && ua.getClass() == otherUa.getClass()) { + return ua.nonSemanticEquals(otherUa); + } return Objects.equals(node, other.node); } diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/common/Failures.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/common/Failures.java index fd25cb427d95b..1720cd3266796 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/common/Failures.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/common/Failures.java @@ -7,16 +7,16 @@ package org.elasticsearch.xpack.esql.common; -import java.util.Collection; import java.util.LinkedHashSet; import java.util.Objects; +import java.util.Set; /** - * Glorified list for managing {@link Failure}s. + * Glorified set for managing {@link Failure}s. */ public class Failures { - private final Collection failures; + private final Set failures; public Failures() { this.failures = new LinkedHashSet<>(); @@ -33,7 +33,7 @@ public boolean hasFailures() { return failures.size() > 0; } - public Collection failures() { + public Set failures() { return failures; } diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttribute.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttribute.java index cc7df8d8a7bc5..6ae373b49a260 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttribute.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttribute.java @@ -183,7 +183,7 @@ public int nonSemanticHashCode() { } @Override - protected boolean nonSemanticEquals(Attribute o) { + public boolean nonSemanticEquals(Attribute o) { var other = (UnsupportedAttribute) o; return super.nonSemanticEquals(other) && hasCustomMessage == other.hasCustomMessage && Objects.equals(message, other.message); } From 9d9ad868b1d196c3a072f85aea834c8f36a6a373 Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Fri, 26 Sep 2025 17:35:49 +0200 Subject: [PATCH 24/38] Fix some more tests --- .../expression/function/aggregate/AvgSerializationTests.java | 3 ++- .../expression/function/scalar/conditional/CaseTests.java | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/AvgSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/AvgSerializationTests.java index 5d6fa21e20813..95654eb24b211 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/AvgSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/AvgSerializationTests.java @@ -10,6 +10,7 @@ import org.elasticsearch.common.io.stream.BytesStreamOutput; import org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput; import org.elasticsearch.common.io.stream.StreamInput; +import org.elasticsearch.xpack.esql.SerializationTestUtils; import org.elasticsearch.xpack.esql.core.expression.Expression; import org.elasticsearch.xpack.esql.core.tree.NodeInfo; import org.elasticsearch.xpack.esql.core.tree.Source; @@ -80,7 +81,7 @@ public void testSerializeOldAvg() throws IOException { PlanStreamOutput planOut = new PlanStreamOutput(out, configuration()); planOut.writeNamedWriteable(oldAvg); try (StreamInput in = new NamedWriteableAwareStreamInput(out.bytes().streamInput(), getNamedWriteableRegistry())) { - PlanStreamInput planIn = new PlanStreamInput(in, getNamedWriteableRegistry(), configuration()); + PlanStreamInput planIn = new PlanStreamInput(in, getNamedWriteableRegistry(), configuration(), new SerializationTestUtils.TestNameIdMapper()); Avg serialized = (Avg) planIn.readNamedWriteable(categoryClass()); assertThat(serialized.source(), equalTo(oldAvg.source())); assertThat(serialized.field(), equalTo(oldAvg.field())); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/CaseTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/CaseTests.java index a538f17969bce..d4ad5981efac1 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/CaseTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/CaseTests.java @@ -31,6 +31,7 @@ import java.util.stream.Stream; import static java.util.Collections.unmodifiableList; +import static org.elasticsearch.xpack.esql.EsqlTestUtils.equalToIgnoringIds; import static org.elasticsearch.xpack.esql.EsqlTestUtils.randomLiteral; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.sameInstance; @@ -808,14 +809,14 @@ public void testPartialFold() { return; } if (extra().expectedPartialFold.size() == 1) { - assertThat(c.partiallyFold(FoldContext.small()), equalTo(extra().expectedPartialFold.get(0).asField())); + assertThat(c.partiallyFold(FoldContext.small()), equalToIgnoringIds(extra().expectedPartialFold.get(0).asField())); return; } Case expected = build( Source.synthetic("expected"), extra().expectedPartialFold.stream().map(TestCaseSupplier.TypedData::asField).toList() ); - assertThat(c.partiallyFold(FoldContext.small()), equalTo(expected)); + assertThat(c.partiallyFold(FoldContext.small()), equalToIgnoringIds(expected)); } private static Function addWarnings(List warnings) { From c73b45d9cf28b086759a047a923f1f9811a61b51 Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Fri, 26 Sep 2025 18:08:21 +0200 Subject: [PATCH 25/38] Fix some more serialization tests --- .../xpack/esql/plugin/DataNodeRequest.java | 12 +++++++++++- .../function/aggregate/AvgSerializationTests.java | 7 ++++++- .../function/aggregate/SumSerializationTests.java | 8 +++++++- .../plugin/DataNodeRequestSerializationTests.java | 4 ++-- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/DataNodeRequest.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/DataNodeRequest.java index a4bc42fdc29b4..5b4f6575dfbc9 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/DataNodeRequest.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/DataNodeRequest.java @@ -78,6 +78,13 @@ final class DataNodeRequest extends AbstractTransportRequest implements IndicesR } DataNodeRequest(StreamInput in) throws IOException { + this(in, null); + } + + /** + * @param idMapper non-null for testing only, never in production! + */ + DataNodeRequest(StreamInput in, PlanStreamInput.NameIdMapper idMapper) throws IOException { super(in); this.sessionId = in.readString(); this.configuration = new Configuration( @@ -87,7 +94,10 @@ final class DataNodeRequest extends AbstractTransportRequest implements IndicesR this.clusterAlias = in.readString(); this.shardIds = in.readCollectionAsList(ShardId::new); this.aliasFilters = in.readMap(Index::new, AliasFilter::readFrom); - this.plan = new PlanStreamInput(in, in.namedWriteableRegistry(), configuration).readNamedWriteable(PhysicalPlan.class); + PlanStreamInput pin = idMapper == null + ? new PlanStreamInput(in, in.namedWriteableRegistry(), configuration) + : new PlanStreamInput(in, in.namedWriteableRegistry(), configuration, idMapper); + this.plan = pin.readNamedWriteable(PhysicalPlan.class); this.indices = in.readStringArray(); this.indicesOptions = IndicesOptions.readIndicesOptions(in); if (in.getTransportVersion().onOrAfter(TransportVersions.ESQL_ENABLE_NODE_LEVEL_REDUCTION)) { diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/AvgSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/AvgSerializationTests.java index 95654eb24b211..d9f30f5dd8b05 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/AvgSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/AvgSerializationTests.java @@ -81,7 +81,12 @@ public void testSerializeOldAvg() throws IOException { PlanStreamOutput planOut = new PlanStreamOutput(out, configuration()); planOut.writeNamedWriteable(oldAvg); try (StreamInput in = new NamedWriteableAwareStreamInput(out.bytes().streamInput(), getNamedWriteableRegistry())) { - PlanStreamInput planIn = new PlanStreamInput(in, getNamedWriteableRegistry(), configuration(), new SerializationTestUtils.TestNameIdMapper()); + PlanStreamInput planIn = new PlanStreamInput( + in, + getNamedWriteableRegistry(), + configuration(), + new SerializationTestUtils.TestNameIdMapper() + ); Avg serialized = (Avg) planIn.readNamedWriteable(categoryClass()); assertThat(serialized.source(), equalTo(oldAvg.source())); assertThat(serialized.field(), equalTo(oldAvg.field())); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SumSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SumSerializationTests.java index f15d8bb96cf24..a30c075efbc1f 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SumSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/SumSerializationTests.java @@ -10,6 +10,7 @@ import org.elasticsearch.common.io.stream.BytesStreamOutput; import org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput; import org.elasticsearch.common.io.stream.StreamInput; +import org.elasticsearch.xpack.esql.SerializationTestUtils; import org.elasticsearch.xpack.esql.core.expression.Expression; import org.elasticsearch.xpack.esql.core.tree.NodeInfo; import org.elasticsearch.xpack.esql.core.tree.Source; @@ -80,7 +81,12 @@ public void testSerializeOldSum() throws IOException { PlanStreamOutput planOut = new PlanStreamOutput(out, configuration()); planOut.writeNamedWriteable(oldSum); try (StreamInput in = new NamedWriteableAwareStreamInput(out.bytes().streamInput(), getNamedWriteableRegistry())) { - PlanStreamInput planIn = new PlanStreamInput(in, getNamedWriteableRegistry(), configuration()); + PlanStreamInput planIn = new PlanStreamInput( + in, + getNamedWriteableRegistry(), + configuration(), + new SerializationTestUtils.TestNameIdMapper() + ); Sum serialized = (Sum) planIn.readNamedWriteable(categoryClass()); assertThat(serialized.source(), equalTo(oldSum.source())); assertThat(serialized.field(), equalTo(oldSum.field())); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plugin/DataNodeRequestSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plugin/DataNodeRequestSerializationTests.java index 1a1d981ca0ba1..6c4e2826cdf59 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plugin/DataNodeRequestSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plugin/DataNodeRequestSerializationTests.java @@ -19,6 +19,7 @@ import org.elasticsearch.search.internal.AliasFilter; import org.elasticsearch.test.AbstractWireSerializingTestCase; import org.elasticsearch.xpack.esql.EsqlTestUtils; +import org.elasticsearch.xpack.esql.SerializationTestUtils; import org.elasticsearch.xpack.esql.analysis.Analyzer; import org.elasticsearch.xpack.esql.analysis.AnalyzerContext; import org.elasticsearch.xpack.esql.core.expression.FoldContext; @@ -50,10 +51,9 @@ import static org.elasticsearch.xpack.esql.EsqlTestUtils.withDefaultLimitWarning; public class DataNodeRequestSerializationTests extends AbstractWireSerializingTestCase { - @Override protected Writeable.Reader instanceReader() { - return DataNodeRequest::new; + return in -> new DataNodeRequest(in, new SerializationTestUtils.TestNameIdMapper()); } @Override From e40f95f513bb36c03df8a5b5e026fe1c3c8ffba7 Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Fri, 3 Oct 2025 10:21:06 +0200 Subject: [PATCH 26/38] Comment capability formatting --- .../org/elasticsearch/xpack/esql/action/EsqlCapabilities.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java index 9dd37dad98d19..7b06ad371e260 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java @@ -1599,6 +1599,9 @@ public enum Cap { * Fix attribute equality to respect the name id of the attribute. */ ATTRIBUTE_EQUALS_RESPECTS_NAME_ID, + + // Last capability should still have a comma for fewer merge conflicts when adding new ones :) + // Also, this comment prevents the semicolon from being on the previous capability when Spotless formats the file. ; private final boolean enabled; From 9800b8ef865a3d189a61393c136a1317d60d6fea Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Fri, 3 Oct 2025 11:05:32 +0200 Subject: [PATCH 27/38] Fix some more serialization tests --- .../xpack/esql/expression/AliasTests.java | 30 ++---------------- .../plan/AbstractNodeSerializationTests.java | 5 +-- .../esql/type/AbstractEsFieldTypeTests.java | 22 ++++++------- .../xpack/esql/type/DateEsFieldTests.java | 2 +- .../xpack/esql/type/EsFieldTests.java | 2 +- .../esql/type/InvalidMappedFieldTests.java | 2 +- .../xpack/esql/type/KeywordEsFieldTests.java | 2 +- .../esql/type/MultiTypeEsFieldTests.java | 31 +++++-------------- .../xpack/esql/type/TextEsFieldTests.java | 2 +- .../esql/type/UnsupportedEsFieldTests.java | 2 +- 10 files changed, 30 insertions(+), 70 deletions(-) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AliasTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AliasTests.java index 7bb8ab3e147e2..83b215aa8332b 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AliasTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AliasTests.java @@ -7,24 +7,16 @@ package org.elasticsearch.xpack.esql.expression; -import org.elasticsearch.TransportVersion; -import org.elasticsearch.common.io.stream.NamedWriteableRegistry; -import org.elasticsearch.test.AbstractWireTestCase; import org.elasticsearch.xpack.esql.core.expression.Alias; import org.elasticsearch.xpack.esql.core.expression.Expression; import org.elasticsearch.xpack.esql.core.expression.NameId; -import org.elasticsearch.xpack.esql.core.expression.NamedExpression; import org.elasticsearch.xpack.esql.core.tree.Source; import org.elasticsearch.xpack.esql.core.tree.SourceTests; import org.elasticsearch.xpack.esql.expression.function.ReferenceAttributeTests; -import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput; -import org.elasticsearch.xpack.esql.io.stream.PlanStreamOutput; import java.io.IOException; -import static org.hamcrest.Matchers.equalTo; - -public class AliasTests extends AbstractWireTestCase { +public class AliasTests extends AbstractExpressionSerializationTests { public static Alias randomAlias() { Source source = SourceTests.randomSource(); String name = randomAlphaOfLength(5); @@ -54,23 +46,7 @@ protected Alias mutateInstance(Alias instance) throws IOException { } @Override - protected Alias copyInstance(Alias instance, TransportVersion version) throws IOException { - return copyInstance( - instance, - getNamedWriteableRegistry(), - (out, v) -> new PlanStreamOutput(out, null).writeNamedWriteable(v), - in -> { - PlanStreamInput pin = new PlanStreamInput(in, in.namedWriteableRegistry(), null); - Alias deser = (Alias) pin.readNamedWriteable(NamedExpression.class); - assertThat(deser.id(), equalTo(pin.mapNameId(Long.parseLong(instance.id().toString())))); - return deser; - }, - version - ); - } - - @Override - protected final NamedWriteableRegistry getNamedWriteableRegistry() { - return new NamedWriteableRegistry(ExpressionWritables.allExpressions()); + protected boolean alwaysEmptySource() { + return true; } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plan/AbstractNodeSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plan/AbstractNodeSerializationTests.java index e8eed17944b4a..d986b3c41b1ae 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plan/AbstractNodeSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plan/AbstractNodeSerializationTests.java @@ -28,8 +28,9 @@ import static org.hamcrest.Matchers.sameInstance; /** - * Superclass for serialization tests for all {@link Node} subclasses - * @param + * Superclass for serialization tests for all {@link Node} subclasses. + * Useful because it provides a {@link #configuration()} method to access a random + * {@link Configuration} and respects {@link org.elasticsearch.xpack.esql.core.expression.NameId}s. */ public abstract class AbstractNodeSerializationTests> extends AbstractWireTestCase { /** diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/AbstractEsFieldTypeTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/AbstractEsFieldTypeTests.java index 44a83f9c964c2..d6321d9880de3 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/AbstractEsFieldTypeTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/AbstractEsFieldTypeTests.java @@ -14,16 +14,18 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.test.AbstractWireTestCase; import org.elasticsearch.xpack.esql.EsqlTestUtils; +import org.elasticsearch.xpack.esql.SerializationTestUtils; import org.elasticsearch.xpack.esql.core.type.EsField; import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput; import org.elasticsearch.xpack.esql.io.stream.PlanStreamOutput; +import org.elasticsearch.xpack.esql.session.Configuration; import java.io.IOException; import java.util.List; import java.util.Map; import java.util.TreeMap; -public abstract class AbstractEsFieldTypeTests extends AbstractWireTestCase { +public abstract class AbstractEsFieldTypeTests extends AbstractWireTestCase { public static EsField randomAnyEsField(int maxDepth) { return switch (between(0, 5)) { case 0 -> EsFieldTests.randomEsField(maxDepth); @@ -39,17 +41,15 @@ public static EsField randomAnyEsField(int maxDepth) { @Override protected abstract T createTestInstance(); - protected abstract T mutate(T instance); - @Override - protected EsField copyInstance(EsField instance, TransportVersion version) throws IOException { + protected T copyInstance(T instance, TransportVersion version) throws IOException { NamedWriteableRegistry namedWriteableRegistry = getNamedWriteableRegistry(); try (BytesStreamOutput output = new BytesStreamOutput(); var pso = new PlanStreamOutput(output, EsqlTestUtils.TEST_CFG)) { pso.setTransportVersion(version); instance.writeTo(pso); try ( StreamInput in = new NamedWriteableAwareStreamInput(output.bytes().streamInput(), namedWriteableRegistry); - var psi = new PlanStreamInput(in, in.namedWriteableRegistry(), EsqlTestUtils.TEST_CFG) + var psi = new PlanStreamInput(in, in.namedWriteableRegistry(), config(), new SerializationTestUtils.TestNameIdMapper()) ) { psi.setTransportVersion(version); return EsField.readFrom(psi); @@ -57,6 +57,10 @@ protected EsField copyInstance(EsField instance, TransportVersion version) throw } } + protected Configuration config() { + return EsqlTestUtils.TEST_CFG; + } + /** * Generate sub-properties. * @param maxDepth the maximum number of levels of properties to make @@ -77,13 +81,7 @@ static Map randomProperties(int maxDepth) { } @Override - @SuppressWarnings("unchecked") - protected final T mutateInstance(EsField instance) throws IOException { - return mutate((T) instance); - } - - @Override - protected final NamedWriteableRegistry getNamedWriteableRegistry() { + protected NamedWriteableRegistry getNamedWriteableRegistry() { return new NamedWriteableRegistry(List.of()); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/DateEsFieldTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/DateEsFieldTests.java index a7cf5b499e7ee..ce528451e4830 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/DateEsFieldTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/DateEsFieldTests.java @@ -28,7 +28,7 @@ protected DateEsField createTestInstance() { } @Override - protected DateEsField mutate(DateEsField instance) { + protected DateEsField mutateInstance(DateEsField instance) { String name = instance.getName(); Map properties = instance.getProperties(); boolean aggregatable = instance.isAggregatable(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/EsFieldTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/EsFieldTests.java index c29cbde8a7877..bac69261f24b5 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/EsFieldTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/EsFieldTests.java @@ -29,7 +29,7 @@ protected EsField createTestInstance() { } @Override - protected EsField mutate(EsField instance) { + protected EsField mutateInstance(EsField instance) { String name = instance.getName(); DataType esDataType = instance.getDataType(); Map properties = instance.getProperties(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/InvalidMappedFieldTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/InvalidMappedFieldTests.java index c66088b0695d4..fc35e940a8c13 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/InvalidMappedFieldTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/InvalidMappedFieldTests.java @@ -26,7 +26,7 @@ protected InvalidMappedField createTestInstance() { } @Override - protected InvalidMappedField mutate(InvalidMappedField instance) { + protected InvalidMappedField mutateInstance(InvalidMappedField instance) { String name = instance.getName(); String errorMessage = instance.errorMessage(); Map properties = instance.getProperties(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/KeywordEsFieldTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/KeywordEsFieldTests.java index 9441b2e896f10..c451ed5e12958 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/KeywordEsFieldTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/KeywordEsFieldTests.java @@ -31,7 +31,7 @@ protected KeywordEsField createTestInstance() { } @Override - protected KeywordEsField mutate(KeywordEsField instance) { + protected KeywordEsField mutateInstance(KeywordEsField instance) { String name = instance.getName(); Map properties = instance.getProperties(); boolean hasDocValues = instance.isAggregatable(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/MultiTypeEsFieldTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/MultiTypeEsFieldTests.java index f64d2417aff1d..e4ed99dd0785a 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/MultiTypeEsFieldTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/MultiTypeEsFieldTests.java @@ -7,9 +7,7 @@ package org.elasticsearch.xpack.esql.type; -import org.elasticsearch.TransportVersion; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; -import org.elasticsearch.test.AbstractWireTestCase; import org.elasticsearch.xpack.esql.core.expression.Expression; import org.elasticsearch.xpack.esql.core.expression.FieldAttribute; import org.elasticsearch.xpack.esql.core.tree.Source; @@ -29,8 +27,6 @@ import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToLong; import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToString; import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToVersion; -import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput; -import org.elasticsearch.xpack.esql.io.stream.PlanStreamOutput; import org.elasticsearch.xpack.esql.session.Configuration; import org.junit.Before; @@ -45,18 +41,10 @@ /** * This test was originally based on the tests for sub-classes of EsField, like InvalidMappedFieldTests. - * However, it has a few important differences: - *

    - *
  • It is not in the esql.core module, but in the esql module, in order to have access to the sub-classes of AbstractConvertFunction, - * like ToString, which are important conversion Expressions used in the union-types feature.
  • - *
  • It extends AbstractNamedWriteableTestCase instead of AbstractEsFieldTypeTests, - * in order to wrap the StreamInput with a PlanStreamInput, since Expression is not yet fully supported in the new - * serialization approach (NamedWritable).
  • - *
- * These differences can be minimized once Expression is fully supported in the new serialization approach, and the esql and esql.core - * modules are merged, or at least the relevant classes are moved. + * However, it needs access to the sub-classes of AbstractConvertFunction, like ToString, which are important conversion Expressions + * used in the union-types feature. */ -public class MultiTypeEsFieldTests extends AbstractWireTestCase { +public class MultiTypeEsFieldTests extends AbstractEsFieldTypeTests { private Configuration config; @@ -65,6 +53,11 @@ public void initConfig() { config = randomConfiguration(); } + @Override + protected Configuration config() { + return config; + } + @Override protected MultiTypeEsField createTestInstance() { String name = randomAlphaOfLength(4); @@ -99,14 +92,6 @@ protected final NamedWriteableRegistry getNamedWriteableRegistry() { return new NamedWriteableRegistry(entries); } - @Override - protected final MultiTypeEsField copyInstance(MultiTypeEsField instance, TransportVersion version) throws IOException { - return copyInstance(instance, getNamedWriteableRegistry(), (out, v) -> v.writeTo(new PlanStreamOutput(out, config)), in -> { - PlanStreamInput pin = new PlanStreamInput(in, in.namedWriteableRegistry(), config); - return EsField.readFrom(pin); - }, version); - } - private static Map randomConvertExpressions(String name, boolean toString, DataType dataType) { Map indexToConvertExpressions = new HashMap<>(); if (toString) { diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/TextEsFieldTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/TextEsFieldTests.java index cc2270d94ddfd..2aa4d5e70c5c6 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/TextEsFieldTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/TextEsFieldTests.java @@ -28,7 +28,7 @@ protected TextEsField createTestInstance() { } @Override - protected TextEsField mutate(TextEsField instance) { + protected TextEsField mutateInstance(TextEsField instance) { String name = instance.getName(); Map properties = instance.getProperties(); boolean hasDocValues = instance.isAggregatable(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/UnsupportedEsFieldTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/UnsupportedEsFieldTests.java index 908cdb279613c..c9de76f9425f9 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/UnsupportedEsFieldTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/UnsupportedEsFieldTests.java @@ -32,7 +32,7 @@ protected UnsupportedEsField createTestInstance() { } @Override - protected UnsupportedEsField mutate(UnsupportedEsField instance) { + protected UnsupportedEsField mutateInstance(UnsupportedEsField instance) { String name = instance.getName(); List originalTypes = instance.getOriginalTypes(); String inherited = instance.getInherited(); From 53d50e962e41fb4c7ad1ae00684dd02c401619ef Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Fri, 3 Oct 2025 11:58:44 +0200 Subject: [PATCH 28/38] Fix some more tests --- .../core/expression/UnresolvedAttribute.java | 6 + .../xpack/esql/EsqlTestUtils.java | 21 ++ .../esql/optimizer/OptimizerRulesTests.java | 4 +- .../parser/AbstractStatementParserTests.java | 4 +- .../esql/parser/StatementParserTests.java | 357 +++++++++--------- 5 files changed, 220 insertions(+), 172 deletions(-) diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedAttribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedAttribute.java index 1f0c2d78a38d9..73d0068a53806 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedAttribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedAttribute.java @@ -112,6 +112,12 @@ protected Attribute clone( return this; } + // Cannot just use the super method because that requires a data type. + @Override + public UnresolvedAttribute withId(NameId id) { + return new UnresolvedAttribute(source(), qualifier(), name(), id, unresolvedMessage(), resolutionMetadata()); + } + public UnresolvedAttribute withUnresolvedMessage(String unresolvedMessage) { return new UnresolvedAttribute(source(), qualifier(), name(), id(), unresolvedMessage, resolutionMetadata()); } diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java b/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java index 3b27e2e9976d8..88c34d6b4d188 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java @@ -97,6 +97,7 @@ import org.elasticsearch.xpack.esql.parser.QueryParam; import org.elasticsearch.xpack.esql.plan.logical.Enrich; import org.elasticsearch.xpack.esql.plan.logical.EsRelation; +import org.elasticsearch.xpack.esql.plan.logical.Explain; import org.elasticsearch.xpack.esql.plan.logical.Limit; import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan; import org.elasticsearch.xpack.esql.plan.logical.local.EmptyLocalSupplier; @@ -113,6 +114,8 @@ import org.elasticsearch.xpack.esql.stats.SearchStats; import org.elasticsearch.xpack.esql.telemetry.Metrics; import org.elasticsearch.xpack.versionfield.Version; +import org.hamcrest.Matcher; +import org.hamcrest.collection.IsIterableContainingInAnyOrder; import org.hamcrest.core.IsEqual; import org.junit.Assert; @@ -1015,6 +1018,10 @@ public static Exception unwrapIfWrappedInRemoteException(Exception e) { } } + public static void assertEqualsIgnoringIds(Object expected, Object actual) { + assertThat(actual, equalToIgnoringIds(expected)); + } + /** * Returns a matcher that matches if the examined object is logically equal to the specified * operand, ignoring the {@link NameId}s of any {@link NamedExpression}s (e.g. {@link Alias} and {@link Attribute}). @@ -1023,6 +1030,16 @@ public static org.hamcrest.Matcher equalToIgnoringIds(T operand) { return new IsEqualIgnoringIds(operand); } + @SafeVarargs + public static org.hamcrest.Matcher> containsInAnyOrderIgnoringIds(T... items) { + List> matchers = new ArrayList<>(); + for (T item : items) { + matchers.add(equalToIgnoringIds(item)); + } + + return new IsIterableContainingInAnyOrder<>(matchers); + } + private static class IsEqualIgnoringIds extends IsEqual { @SuppressWarnings("unchecked") IsEqualIgnoringIds(T operand) { @@ -1055,6 +1072,10 @@ private static Expression ignoreIdsInExpression(Expression expression) { } private static LogicalPlan ignoreIdsInLogicalPlan(LogicalPlan plan) { + if (plan instanceof Explain explain) { + return new Explain(explain.source(), ignoreIdsInLogicalPlan(explain.query())); + } + return plan.transformExpressionsDown( NamedExpression.class, ne -> ne instanceof Alias alias ? alias.withId(DUMMY_ID) : ne instanceof Attribute attr ? attr.withId(DUMMY_ID) : ne diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/OptimizerRulesTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/OptimizerRulesTests.java index fe4fd96120a01..e7166a5430f1c 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/OptimizerRulesTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/OptimizerRulesTests.java @@ -29,11 +29,11 @@ import java.util.Collections; import java.util.List; +import static org.elasticsearch.xpack.esql.EsqlTestUtils.containsInAnyOrderIgnoringIds; import static org.elasticsearch.xpack.esql.EsqlTestUtils.rangeOf; import static org.elasticsearch.xpack.esql.core.type.DataType.BOOLEAN; import static org.elasticsearch.xpack.esql.core.util.TestUtils.getFieldAttribute; import static org.elasticsearch.xpack.esql.core.util.TestUtils.of; -import static org.hamcrest.Matchers.containsInAnyOrder; public class OptimizerRulesTests extends ESTestCase { @@ -139,6 +139,6 @@ protected Expression rule(Expression e, LogicalOptimizerContext ctx) { var alias = new Alias(new Source(1, 18, "x=f1+1"), "x", add); // contains expressions only from EVAL - assertThat(rule.appliedTo, containsInAnyOrder(alias, add, attribute, literal)); + assertThat(rule.appliedTo, containsInAnyOrderIgnoringIds(alias, add, attribute, literal)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/AbstractStatementParserTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/AbstractStatementParserTests.java index 07ab624e4a2a9..d8ddedeb44fcb 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/AbstractStatementParserTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/AbstractStatementParserTests.java @@ -29,11 +29,11 @@ import java.util.List; import java.util.Map; +import static org.elasticsearch.xpack.esql.EsqlTestUtils.equalToIgnoringIds; import static org.elasticsearch.xpack.esql.core.tree.Source.EMPTY; import static org.elasticsearch.xpack.esql.core.util.NumericUtils.asLongUnsigned; import static org.elasticsearch.xpack.esql.expression.function.FunctionResolutionStrategy.DEFAULT; import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.equalTo; abstract class AbstractStatementParserTests extends ESTestCase { @@ -46,7 +46,7 @@ void assertStatement(String statement, LogicalPlan expected) { } catch (Exception e) { throw new AssertionError("parsing error for [" + statement + "]", e); } - assertThat(statement, actual, equalTo(expected)); + assertThat(statement, actual, equalToIgnoringIds(expected)); } LogicalPlan statement(String query, String arg) { diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java index db83bcc549dfa..6f80c063799ad 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java @@ -83,6 +83,8 @@ import java.util.stream.Stream; import static org.elasticsearch.xpack.esql.EsqlTestUtils.as; +import static org.elasticsearch.xpack.esql.EsqlTestUtils.assertEqualsIgnoringIds; +import static org.elasticsearch.xpack.esql.EsqlTestUtils.equalToIgnoringIds; import static org.elasticsearch.xpack.esql.EsqlTestUtils.paramAsConstant; import static org.elasticsearch.xpack.esql.EsqlTestUtils.paramAsIdentifier; import static org.elasticsearch.xpack.esql.EsqlTestUtils.paramAsPattern; @@ -120,14 +122,14 @@ public class StatementParserTests extends AbstractStatementParserTests { private static final LogicalPlan PROCESSING_CMD_INPUT = new Row(EMPTY, List.of(new Alias(EMPTY, "a", integer(1)))); public void testRowCommand() { - assertEquals( + assertEqualsIgnoringIds( new Row(EMPTY, List.of(new Alias(EMPTY, "a", integer(1)), new Alias(EMPTY, "b", integer(2)))), statement("row a = 1, b = 2") ); } public void testRowCommandImplicitFieldName() { - assertEquals( + assertEqualsIgnoringIds( new Row( EMPTY, List.of(new Alias(EMPTY, "1", integer(1)), new Alias(EMPTY, "2", integer(2)), new Alias(EMPTY, "c", integer(3))) @@ -137,94 +139,106 @@ public void testRowCommandImplicitFieldName() { } public void testRowCommandLong() { - assertEquals(new Row(EMPTY, List.of(new Alias(EMPTY, "c", literalLong(2147483648L)))), statement("row c = 2147483648")); + assertEqualsIgnoringIds(new Row(EMPTY, List.of(new Alias(EMPTY, "c", literalLong(2147483648L)))), statement("row c = 2147483648")); } public void testRowCommandHugeInt() { - assertEquals( + assertEqualsIgnoringIds( new Row(EMPTY, List.of(new Alias(EMPTY, "c", literalUnsignedLong("9223372036854775808")))), statement("row c = 9223372036854775808") ); - assertEquals( + assertEqualsIgnoringIds( new Row(EMPTY, List.of(new Alias(EMPTY, "c", literalDouble(18446744073709551616.)))), statement("row c = 18446744073709551616") ); } public void testRowCommandHugeNegativeInt() { - assertEquals( + assertEqualsIgnoringIds( new Row(EMPTY, List.of(new Alias(EMPTY, "c", literalDouble(-92233720368547758080d)))), statement("row c = -92233720368547758080") ); - assertEquals( + assertEqualsIgnoringIds( new Row(EMPTY, List.of(new Alias(EMPTY, "c", literalDouble(-18446744073709551616d)))), statement("row c = -18446744073709551616") ); } public void testRowCommandDouble() { - assertEquals(new Row(EMPTY, List.of(new Alias(EMPTY, "c", literalDouble(1.0)))), statement("row c = 1.0")); + assertEqualsIgnoringIds(new Row(EMPTY, List.of(new Alias(EMPTY, "c", literalDouble(1.0)))), statement("row c = 1.0")); } public void testRowCommandMultivalueInt() { - assertEquals(new Row(EMPTY, List.of(new Alias(EMPTY, "c", integers(1, 2, -5)))), statement("row c = [1, 2, -5]")); + assertEqualsIgnoringIds(new Row(EMPTY, List.of(new Alias(EMPTY, "c", integers(1, 2, -5)))), statement("row c = [1, 2, -5]")); } public void testRowCommandMultivalueLong() { - assertEquals( + assertEqualsIgnoringIds( new Row(EMPTY, List.of(new Alias(EMPTY, "c", literalLongs(2147483648L, 2147483649L, -434366649L)))), statement("row c = [2147483648, 2147483649, -434366649]") ); } public void testRowCommandMultivalueLongAndInt() { - assertEquals(new Row(EMPTY, List.of(new Alias(EMPTY, "c", literalLongs(2147483648L, 1L)))), statement("row c = [2147483648, 1]")); + assertEqualsIgnoringIds( + new Row(EMPTY, List.of(new Alias(EMPTY, "c", literalLongs(2147483648L, 1L)))), + statement("row c = [2147483648, 1]") + ); } public void testRowCommandMultivalueHugeInts() { - assertEquals( + assertEqualsIgnoringIds( new Row(EMPTY, List.of(new Alias(EMPTY, "c", literalDoubles(18446744073709551616., 18446744073709551617.)))), statement("row c = [18446744073709551616, 18446744073709551617]") ); - assertEquals( + assertEqualsIgnoringIds( new Row(EMPTY, List.of(new Alias(EMPTY, "c", literalUnsignedLongs("9223372036854775808", "9223372036854775809")))), statement("row c = [9223372036854775808, 9223372036854775809]") ); } public void testRowCommandMultivalueHugeIntAndNormalInt() { - assertEquals( + assertEqualsIgnoringIds( new Row(EMPTY, List.of(new Alias(EMPTY, "c", literalDoubles(18446744073709551616., 1.0)))), statement("row c = [18446744073709551616, 1]") ); - assertEquals( + assertEqualsIgnoringIds( new Row(EMPTY, List.of(new Alias(EMPTY, "c", literalUnsignedLongs("9223372036854775808", "1")))), statement("row c = [9223372036854775808, 1]") ); } public void testRowCommandMultivalueDouble() { - assertEquals(new Row(EMPTY, List.of(new Alias(EMPTY, "c", literalDoubles(1.0, 2.0, -3.4)))), statement("row c = [1.0, 2.0, -3.4]")); + assertEqualsIgnoringIds( + new Row(EMPTY, List.of(new Alias(EMPTY, "c", literalDoubles(1.0, 2.0, -3.4)))), + statement("row c = [1.0, 2.0, -3.4]") + ); } public void testRowCommandBoolean() { - assertEquals(new Row(EMPTY, List.of(new Alias(EMPTY, "c", literalBoolean(false)))), statement("row c = false")); + assertEqualsIgnoringIds(new Row(EMPTY, List.of(new Alias(EMPTY, "c", literalBoolean(false)))), statement("row c = false")); } public void testRowCommandMultivalueBoolean() { - assertEquals(new Row(EMPTY, List.of(new Alias(EMPTY, "c", literalBooleans(false, true)))), statement("row c = [false, true]")); + assertEqualsIgnoringIds( + new Row(EMPTY, List.of(new Alias(EMPTY, "c", literalBooleans(false, true)))), + statement("row c = [false, true]") + ); } public void testRowCommandString() { - assertEquals(new Row(EMPTY, List.of(new Alias(EMPTY, "c", literalString("chicken")))), statement("row c = \"chicken\"")); + assertEqualsIgnoringIds(new Row(EMPTY, List.of(new Alias(EMPTY, "c", literalString("chicken")))), statement("row c = \"chicken\"")); } public void testRowCommandMultivalueString() { - assertEquals(new Row(EMPTY, List.of(new Alias(EMPTY, "c", literalStrings("cat", "dog")))), statement("row c = [\"cat\", \"dog\"]")); + assertEqualsIgnoringIds( + new Row(EMPTY, List.of(new Alias(EMPTY, "c", literalStrings("cat", "dog")))), + statement("row c = [\"cat\", \"dog\"]") + ); } public void testRowCommandWithEscapedFieldName() { - assertEquals( + assertEqualsIgnoringIds( new Row( EMPTY, List.of( @@ -238,14 +252,14 @@ public void testRowCommandWithEscapedFieldName() { } public void testCompositeCommand() { - assertEquals( + assertEqualsIgnoringIds( new Filter(EMPTY, new Row(EMPTY, List.of(new Alias(EMPTY, "a", integer(1)))), TRUE), statement("row a = 1 | where true") ); } public void testMultipleCompositeCommands() { - assertEquals( + assertEqualsIgnoringIds( new Filter( EMPTY, new Filter(EMPTY, new Filter(EMPTY, new Row(EMPTY, List.of(new Alias(EMPTY, "a", integer(1)))), TRUE), FALSE), @@ -256,12 +270,12 @@ public void testMultipleCompositeCommands() { } public void testEval() { - assertEquals( + assertEqualsIgnoringIds( new Eval(EMPTY, PROCESSING_CMD_INPUT, List.of(new Alias(EMPTY, "b", attribute("a")))), processingCommand("eval b = a") ); - assertEquals( + assertEqualsIgnoringIds( new Eval( EMPTY, PROCESSING_CMD_INPUT, @@ -272,9 +286,12 @@ public void testEval() { } public void testEvalImplicitNames() { - assertEquals(new Eval(EMPTY, PROCESSING_CMD_INPUT, List.of(new Alias(EMPTY, "a", attribute("a")))), processingCommand("eval a")); + assertEqualsIgnoringIds( + new Eval(EMPTY, PROCESSING_CMD_INPUT, List.of(new Alias(EMPTY, "a", attribute("a")))), + processingCommand("eval a") + ); - assertEquals( + assertEqualsIgnoringIds( new Eval( EMPTY, PROCESSING_CMD_INPUT, @@ -291,7 +308,7 @@ public void testEvalImplicitNames() { } public void testStatsWithGroups() { - assertEquals( + assertEqualsIgnoringIds( new Aggregate( EMPTY, PROCESSING_CMD_INPUT, @@ -307,7 +324,7 @@ public void testStatsWithGroups() { } public void testStatsWithoutGroups() { - assertEquals( + assertEqualsIgnoringIds( new Aggregate( EMPTY, PROCESSING_CMD_INPUT, @@ -322,7 +339,7 @@ public void testStatsWithoutGroups() { } public void testStatsWithoutAggs() { - assertEquals( + assertEqualsIgnoringIds( new Aggregate(EMPTY, PROCESSING_CMD_INPUT, List.of(attribute("a")), List.of(attribute("a"))), processingCommand("stats by a") ); @@ -357,7 +374,7 @@ public void testStatsWithGroupKeyAndAggFilter() { var a = attribute("a"); var f = new UnresolvedFunction(EMPTY, "min", DEFAULT, List.of(a)); var filter = new Alias(EMPTY, "min(a) where a > 1", new FilteredExpression(EMPTY, f, new GreaterThan(EMPTY, a, integer(1)))); - assertEquals( + assertEqualsIgnoringIds( new Aggregate(EMPTY, PROCESSING_CMD_INPUT, List.of(a), List.of(filter, a)), processingCommand("stats min(a) where a > 1 by a") ); @@ -380,7 +397,7 @@ public void testStatsWithGroupKeyAndMixedAggAndFilter() { var avg_filter_ex = new GreaterThan(EMPTY, new Div(EMPTY, a, integer(2)), integer(100)); var avg_filter = new Alias(EMPTY, "avg", new FilteredExpression(EMPTY, avg, avg_filter_ex)); - assertEquals( + assertEqualsIgnoringIds( new Aggregate(EMPTY, PROCESSING_CMD_INPUT, List.of(a), List.of(min_alias, max_filter, avg_filter, a)), processingCommand(""" stats @@ -396,7 +413,10 @@ public void testStatsWithoutGroupKeyMixedAggAndFilter() { var a = attribute("a"); var f = new UnresolvedFunction(EMPTY, "min", DEFAULT, List.of(a)); var filter = new Alias(EMPTY, "min(a) where a > 1", new FilteredExpression(EMPTY, f, new GreaterThan(EMPTY, a, integer(1)))); - assertEquals(new Aggregate(EMPTY, PROCESSING_CMD_INPUT, List.of(), List.of(filter)), processingCommand("stats min(a) where a > 1")); + assertEqualsIgnoringIds( + new Aggregate(EMPTY, PROCESSING_CMD_INPUT, List.of(), List.of(filter)), + processingCommand("stats min(a) where a > 1") + ); } public void testInlineStatsWithGroups() { @@ -407,7 +427,7 @@ public void testInlineStatsWithGroups() { var query = cmd + " b = MIN(a) BY c, d.e"; assertThat( processingCommand(query), - is( + equalToIgnoringIds( new InlineStats( EMPTY, new Aggregate( @@ -432,19 +452,17 @@ public void testInlineStatsWithoutGroups() { } for (var cmd : List.of("INLINE STATS", "INLINESTATS")) { var query = cmd + " MIN(a), c = 1"; - assertThat( + assertEqualsIgnoringIds( processingCommand(query), - is( - new InlineStats( + new InlineStats( + EMPTY, + new Aggregate( EMPTY, - new Aggregate( - EMPTY, - PROCESSING_CMD_INPUT, - List.of(), - List.of( - new Alias(EMPTY, "MIN(a)", new UnresolvedFunction(EMPTY, "MIN", DEFAULT, List.of(attribute("a")))), - new Alias(EMPTY, "c", integer(1)) - ) + PROCESSING_CMD_INPUT, + List.of(), + List.of( + new Alias(EMPTY, "MIN(a)", new UnresolvedFunction(EMPTY, "MIN", DEFAULT, List.of(attribute("a")))), + new Alias(EMPTY, "c", integer(1)) ) ) ) @@ -503,7 +521,7 @@ public void testInlineStatsWithinFork() { // first subplan var eval = as(subPlans.get(0), Eval.class); - assertThat(as(eval.fields().get(0), Alias.class), equalTo(alias("_fork", literalString("fork1")))); + assertThat(as(eval.fields().get(0), Alias.class), equalToIgnoringIds(alias("_fork", literalString("fork1")))); var limit = as(eval.child(), Limit.class); assertThat(limit.limit(), instanceOf(Literal.class)); assertThat(((Literal) limit.limit()).value(), equalTo(11)); @@ -515,7 +533,7 @@ public void testInlineStatsWithinFork() { // second subplan eval = as(subPlans.get(1), Eval.class); - assertThat(as(eval.fields().get(0), Alias.class), equalTo(alias("_fork", literalString("fork2")))); + assertThat(as(eval.fields().get(0), Alias.class), equalToIgnoringIds(alias("_fork", literalString("fork2")))); var aggregate = as(eval.child(), Aggregate.class); assertThat(aggregate.aggregates().size(), equalTo(1)); var alias = as(aggregate.aggregates().get(0), Alias.class); @@ -526,7 +544,7 @@ public void testInlineStatsWithinFork() { // third subplan eval = as(subPlans.get(2), Eval.class); - assertThat(as(eval.fields().get(0), Alias.class), equalTo(alias("_fork", literalString("fork3")))); + assertThat(as(eval.fields().get(0), Alias.class), equalToIgnoringIds(alias("_fork", literalString("fork3")))); var inlineStats = as(eval.child(), InlineStats.class); aggregate = as(inlineStats.child(), Aggregate.class); assertThat(aggregate.aggregates().size(), equalTo(1)); @@ -936,12 +954,15 @@ public void testInvalidCharacterInIndexPattern() { } private void clustersAndIndices(String command, String indexString1, String indexString2) { - assertEquals(unresolvedRelation(indexString1 + "," + indexString2), statement(command, indexString1 + ", " + indexString2)); - assertEquals( + assertEqualsIgnoringIds( + unresolvedRelation(indexString1 + "," + indexString2), + statement(command, indexString1 + ", " + indexString2) + ); + assertEqualsIgnoringIds( unresolvedRelation(indexString1 + "," + indexString2), statement(command, indexString1 + ", \"" + indexString2 + "\"") ); - assertEquals( + assertEqualsIgnoringIds( unresolvedRelation(indexString1 + ", " + indexString2), statement(command, "\"" + indexString1 + ", " + indexString2 + "\"") ); @@ -1008,7 +1029,7 @@ public void testIdentifierAsFieldName() { assertThat(((UnresolvedAttribute) comparison.left()).name(), equalTo(expectedIdentifiers[j])); assertThat(comparison.right(), instanceOf(Literal.class)); assertThat(((Literal) comparison.right()).value(), equalTo(123)); - assertThat(filter.child(), equalTo(PROCESSING_CMD_INPUT)); + assertThat(filter.child(), equalToIgnoringIds(PROCESSING_CMD_INPUT)); } } } @@ -1017,7 +1038,7 @@ public void testBooleanLiteralCondition() { LogicalPlan where = processingCommand("where true"); assertThat(where, instanceOf(Filter.class)); Filter w = (Filter) where; - assertThat(w.child(), equalTo(PROCESSING_CMD_INPUT)); + assertThat(w.child(), equalToIgnoringIds(PROCESSING_CMD_INPUT)); assertThat(w.condition(), equalTo(TRUE)); } @@ -1081,7 +1102,7 @@ public void testBasicSortCommand() { public void testSubquery() { assumeTrue("Requires EXPLAIN capability", EsqlCapabilities.Cap.EXPLAIN.isEnabled()); - assertEquals(new Explain(EMPTY, PROCESSING_CMD_INPUT), statement("explain ( row a = 1 )")); + assertEqualsIgnoringIds(new Explain(EMPTY, PROCESSING_CMD_INPUT), statement("explain ( row a = 1 )")); } public void testBlockComments() { @@ -1094,7 +1115,7 @@ public void testBlockComments() { do { String queryWithComment = query.substring(0, wsIndex) + "/*explain ( \nfrom bar ) */" + query.substring(wsIndex + 1); - assertEquals(expected, statement(queryWithComment)); + assertEqualsIgnoringIds(expected, statement(queryWithComment)); wsIndex = query.indexOf(' ', wsIndex + 1); } while (wsIndex >= 0); @@ -1110,7 +1131,7 @@ public void testSingleLineComments() { do { String queryWithComment = query.substring(0, wsIndex) + "//explain ( from bar ) \n" + query.substring(wsIndex + 1); - assertEquals(expected, statement(queryWithComment)); + assertEqualsIgnoringIds(expected, statement(queryWithComment)); wsIndex = query.indexOf(' ', wsIndex + 1); } while (wsIndex >= 0); @@ -1122,7 +1143,7 @@ public void testNewLines() { LogicalPlan reference = statement(queryFun.apply(delims[0])); for (int i = 1; i < delims.length; i++) { LogicalPlan candidate = statement(queryFun.apply(delims[i])); - assertThat(candidate, equalTo(reference)); + assertThat(candidate, equalToIgnoringIds(reference)); } } @@ -1239,7 +1260,7 @@ public void testDissectPattern() { Dissect dissect = (Dissect) cmd; assertEquals("%{foo}", dissect.parser().pattern()); assertEquals("", dissect.parser().appendSeparator()); - assertEquals(List.of(referenceAttribute("foo", KEYWORD)), dissect.extractedFields()); + assertEqualsIgnoringIds(List.of(referenceAttribute("foo", KEYWORD)), dissect.extractedFields()); for (String separatorName : List.of("append_separator", "APPEND_SEPARATOR", "AppEnd_SeparAtor")) { cmd = processingCommand("dissect a \"%{foo}\" " + separatorName + "=\",\""); @@ -1247,7 +1268,7 @@ public void testDissectPattern() { dissect = (Dissect) cmd; assertEquals("%{foo}", dissect.parser().pattern()); assertEquals(",", dissect.parser().appendSeparator()); - assertEquals(List.of(referenceAttribute("foo", KEYWORD)), dissect.extractedFields()); + assertEqualsIgnoringIds(List.of(referenceAttribute("foo", KEYWORD)), dissect.extractedFields()); } for (Tuple queryWithUnexpectedCmd : List.of( @@ -1272,7 +1293,7 @@ public void testGrokPattern() { assertEquals(Grok.class, cmd.getClass()); Grok grok = (Grok) cmd; assertEquals("%{WORD:foo}", grok.parser().pattern()); - assertEquals(List.of(referenceAttribute("foo", KEYWORD)), grok.extractedFields()); + assertEqualsIgnoringIds(List.of(referenceAttribute("foo", KEYWORD)), grok.extractedFields()); expectThrows( ParsingException.class, @@ -1284,7 +1305,7 @@ public void testGrokPattern() { assertEquals(Grok.class, cmd.getClass()); grok = (Grok) cmd; assertEquals("%{WORD:foo} %{WORD:foo}", grok.parser().pattern()); - assertEquals(List.of(referenceAttribute("foo", KEYWORD)), grok.extractedFields()); + assertEqualsIgnoringIds(List.of(referenceAttribute("foo", KEYWORD)), grok.extractedFields()); expectError( "row a = \"foo bar\" | GROK a \"%{NUMBER:foo} %{WORD:foo}\"", @@ -1324,7 +1345,7 @@ public void testLikeRLike() { } public void testEnrich() { - assertEquals( + assertEqualsIgnoringIds( new Enrich( EMPTY, PROCESSING_CMD_INPUT, @@ -1338,7 +1359,7 @@ public void testEnrich() { processingCommand("enrich countries") ); - assertEquals( + assertEqualsIgnoringIds( new Enrich( EMPTY, PROCESSING_CMD_INPUT, @@ -1353,7 +1374,7 @@ public void testEnrich() { ); Enrich.Mode mode = randomFrom(Enrich.Mode.values()); - assertEquals( + assertEqualsIgnoringIds( new Enrich( EMPTY, PROCESSING_CMD_INPUT, @@ -1404,7 +1425,7 @@ public void testMvExpand() { LogicalPlan cmd = processingCommand("mv_expand a"); assertEquals(MvExpand.class, cmd.getClass()); MvExpand expand = (MvExpand) cmd; - assertThat(expand.target(), equalTo(attribute("a"))); + assertThat(expand.target(), equalToIgnoringIds(attribute("a"))); } // see https://github.com/elastic/elasticsearch/issues/103331 @@ -1918,7 +1939,7 @@ public void testParamForIdentifier() { // TODO will be replaced by testDoubleParamsForIdentifier after providing an identifier with a single parameter marker is deprecated // field names can appear in eval/where/stats/sort/keep/drop/rename/dissect/grok/enrich/mvexpand // eval, where - assertEquals( + assertEqualsIgnoringIds( new Limit( EMPTY, new Literal(EMPTY, 1, INTEGER), @@ -1945,7 +1966,7 @@ public void testParamForIdentifier() { ) ); - assertEquals( + assertEqualsIgnoringIds( new Limit( EMPTY, new Literal(EMPTY, 1, INTEGER), @@ -1977,7 +1998,7 @@ public void testParamForIdentifier() { ); // stats, sort, mv_expand - assertEquals( + assertEqualsIgnoringIds( new MvExpand( EMPTY, new OrderBy( @@ -2011,7 +2032,7 @@ public void testParamForIdentifier() { ) ); - assertEquals( + assertEqualsIgnoringIds( new MvExpand( EMPTY, new OrderBy( @@ -2068,21 +2089,21 @@ public void testParamForIdentifier() { ); Limit limit = as(plan, Limit.class); Rename rename = as(limit.child(), Rename.class); - assertEquals(rename.renamings(), List.of(new Alias(EMPTY, "f.8", attribute("f7*.")))); + assertEqualsIgnoringIds(rename.renamings(), List.of(new Alias(EMPTY, "f.8", attribute("f7*.")))); Grok grok = as(rename.child(), Grok.class); - assertEquals(grok.input(), attribute("f.6.")); + assertEqualsIgnoringIds(grok.input(), attribute("f.6.")); assertEquals("%{WORD:foo}", grok.parser().pattern()); - assertEquals(List.of(referenceAttribute("foo", KEYWORD)), grok.extractedFields()); + assertEqualsIgnoringIds(List.of(referenceAttribute("foo", KEYWORD)), grok.extractedFields()); Dissect dissect = as(grok.child(), Dissect.class); - assertEquals(dissect.input(), attribute("f.5*")); + assertEqualsIgnoringIds(dissect.input(), attribute("f.5*")); assertEquals("%{bar}", dissect.parser().pattern()); assertEquals("", dissect.parser().appendSeparator()); - assertEquals(List.of(referenceAttribute("bar", KEYWORD)), dissect.extractedFields()); + assertEqualsIgnoringIds(List.of(referenceAttribute("bar", KEYWORD)), dissect.extractedFields()); Drop drop = as(dissect.child(), Drop.class); List removals = drop.removals(); - assertEquals(removals, List.of(attribute("f3."), attribute("f4.*"))); + assertEqualsIgnoringIds(removals, List.of(attribute("f3."), attribute("f4.*"))); Keep keep = as(drop.child(), Keep.class); - assertEquals(keep.projections(), List.of(attribute("f.1.*"), attribute("f.2"))); + assertEqualsIgnoringIds(keep.projections(), List.of(attribute("f.1.*"), attribute("f.2"))); plan = statement( """ @@ -2109,24 +2130,24 @@ public void testParamForIdentifier() { ); limit = as(plan, Limit.class); rename = as(limit.child(), Rename.class); - assertEquals(rename.renamings(), List.of(new Alias(EMPTY, "f11*..f.12", attribute("f.9*.f.10.")))); + assertEqualsIgnoringIds(rename.renamings(), List.of(new Alias(EMPTY, "f11*..f.12", attribute("f.9*.f.10.")))); grok = as(rename.child(), Grok.class); - assertEquals(grok.input(), attribute("f7*..f.8")); + assertEqualsIgnoringIds(grok.input(), attribute("f7*..f.8")); assertEquals("%{WORD:foo}", grok.parser().pattern()); - assertEquals(List.of(referenceAttribute("foo", KEYWORD)), grok.extractedFields()); + assertEqualsIgnoringIds(List.of(referenceAttribute("foo", KEYWORD)), grok.extractedFields()); dissect = as(grok.child(), Dissect.class); - assertEquals(dissect.input(), attribute("f.5*.f.6.")); + assertEqualsIgnoringIds(dissect.input(), attribute("f.5*.f.6.")); assertEquals("%{bar}", dissect.parser().pattern()); assertEquals("", dissect.parser().appendSeparator()); - assertEquals(List.of(referenceAttribute("bar", KEYWORD)), dissect.extractedFields()); + assertEqualsIgnoringIds(List.of(referenceAttribute("bar", KEYWORD)), dissect.extractedFields()); drop = as(dissect.child(), Drop.class); removals = drop.removals(); - assertEquals(removals, List.of(attribute("f3..f4.*"))); + assertEqualsIgnoringIds(removals, List.of(attribute("f3..f4.*"))); keep = as(drop.child(), Keep.class); - assertEquals(keep.projections(), List.of(attribute("f.1.*.f.2"))); + assertEqualsIgnoringIds(keep.projections(), List.of(attribute("f.1.*.f.2"))); // enrich - assertEquals( + assertEqualsIgnoringIds( new Enrich( EMPTY, relation("idx1"), @@ -2143,7 +2164,7 @@ public void testParamForIdentifier() { ) ); - assertEquals( + assertEqualsIgnoringIds( new Enrich( EMPTY, relation("idx1"), @@ -2203,7 +2224,7 @@ public void testParamForIdentifierPattern() { assertEquals(up.name(), "f.2*"); assertEquals(up.pattern(), "f.2*"); UnresolvedRelation ur = as(keep.child(), UnresolvedRelation.class); - assertEquals(ur, relation("test")); + assertEqualsIgnoringIds(ur, relation("test")); plan = statement( "from test | keep ?f1.?f2 | drop ?f3.?f4", @@ -2229,7 +2250,7 @@ public void testParamForIdentifierPattern() { assertEquals(up.name(), "f*1..f.2*"); assertEquals(up.pattern(), "f*1..f.2*"); ur = as(keep.child(), UnresolvedRelation.class); - assertEquals(ur, relation("test")); + assertEqualsIgnoringIds(ur, relation("test")); // mixed names and patterns plan = statement( @@ -2256,7 +2277,7 @@ public void testParamForIdentifierPattern() { assertEquals("f*1..f.2**", up.name()); assertEquals("f*1..`f.2*`*", up.pattern()); ur = as(keep.child(), UnresolvedRelation.class); - assertEquals(ur, relation("test")); + assertEqualsIgnoringIds(ur, relation("test")); } public void testParamInInvalidPosition() { @@ -2345,7 +2366,7 @@ public void testFieldContainingDotsAndNumbers() { LogicalPlan where = processingCommand("where `a.b.1m.4321`"); assertThat(where, instanceOf(Filter.class)); Filter w = (Filter) where; - assertThat(w.child(), equalTo(PROCESSING_CMD_INPUT)); + assertThat(w.child(), equalToIgnoringIds(PROCESSING_CMD_INPUT)); assertThat(Expressions.name(w.condition()), equalTo("a.b.1m.4321")); } @@ -2353,7 +2374,7 @@ public void testFieldQualifiedName() { LogicalPlan where = processingCommand("where a.b.`1m`.`4321`"); assertThat(where, instanceOf(Filter.class)); Filter w = (Filter) where; - assertThat(w.child(), equalTo(PROCESSING_CMD_INPUT)); + assertThat(w.child(), equalToIgnoringIds(PROCESSING_CMD_INPUT)); assertThat(Expressions.name(w.condition()), equalTo("a.b.1m.4321")); } @@ -2704,7 +2725,7 @@ public void testFunctionNamedParameterInMap() { expectedMap3.put("option3", List.of(1, 2, 3)); expectedMap3.put("option4", List.of(true, false)); - assertEquals( + assertEqualsIgnoringIds( new Filter( EMPTY, new Eval( @@ -2732,7 +2753,7 @@ public void testFunctionNamedParameterInMap() { ); // In stats, by and sort as function named parameters - assertEquals( + assertEqualsIgnoringIds( new OrderBy( EMPTY, new Aggregate( @@ -2774,16 +2795,16 @@ by fn2(f3, {"option1":["string1","string2"],"option2":[1,2,3],"option3":2.0,"opt | grok fn2(f3, {"option1":["string1","string2"],"option2":[1,2,3],"option3":2.0,"option4":true}) "%{WORD:foo}" """); Grok grok = as(plan, Grok.class); - assertEquals(function("fn2", List.of(attribute("f3"), mapExpression(expectedMap2))), grok.input()); + assertEqualsIgnoringIds(function("fn2", List.of(attribute("f3"), mapExpression(expectedMap2))), grok.input()); assertEquals("%{WORD:foo}", grok.parser().pattern()); - assertEquals(List.of(referenceAttribute("foo", KEYWORD)), grok.extractedFields()); + assertEqualsIgnoringIds(List.of(referenceAttribute("foo", KEYWORD)), grok.extractedFields()); Dissect dissect = as(grok.child(), Dissect.class); - assertEquals(function("fn1", List.of(attribute("f1"), attribute("f2"), mapExpression(expectedMap1))), dissect.input()); + assertEqualsIgnoringIds(function("fn1", List.of(attribute("f1"), attribute("f2"), mapExpression(expectedMap1))), dissect.input()); assertEquals("%{bar}", dissect.parser().pattern()); assertEquals("", dissect.parser().appendSeparator()); - assertEquals(List.of(referenceAttribute("bar", KEYWORD)), dissect.extractedFields()); + assertEqualsIgnoringIds(List.of(referenceAttribute("bar", KEYWORD)), dissect.extractedFields()); UnresolvedRelation ur = as(dissect.child(), UnresolvedRelation.class); - assertEquals(ur, relation("test")); + assertEqualsIgnoringIds(ur, relation("test")); } public void testFunctionNamedParameterInMapWithNamedParameters() { @@ -2803,7 +2824,7 @@ public void testFunctionNamedParameterInMapWithNamedParameters() { expectedMap3.put("option2", 2.0); expectedMap3.put("option3", List.of(1, 2, 3)); expectedMap3.put("option4", List.of(true, false)); - assertEquals( + assertEqualsIgnoringIds( new Filter( EMPTY, new Eval( @@ -2844,7 +2865,7 @@ public void testFunctionNamedParameterInMapWithNamedParameters() { ) ); - assertEquals( + assertEqualsIgnoringIds( new OrderBy( EMPTY, new Aggregate( @@ -2917,16 +2938,16 @@ public void testFunctionNamedParameterInMapWithNamedParameters() { ) ); Grok grok = as(plan, Grok.class); - assertEquals(function("fn2", List.of(attribute("f3"), mapExpression(expectedMap2))), grok.input()); + assertEqualsIgnoringIds(function("fn2", List.of(attribute("f3"), mapExpression(expectedMap2))), grok.input()); assertEquals("%{WORD:foo}", grok.parser().pattern()); - assertEquals(List.of(referenceAttribute("foo", KEYWORD)), grok.extractedFields()); + assertEqualsIgnoringIds(List.of(referenceAttribute("foo", KEYWORD)), grok.extractedFields()); Dissect dissect = as(grok.child(), Dissect.class); - assertEquals(function("fn1", List.of(attribute("f1"), attribute("f2"), mapExpression(expectedMap1))), dissect.input()); + assertEqualsIgnoringIds(function("fn1", List.of(attribute("f1"), attribute("f2"), mapExpression(expectedMap1))), dissect.input()); assertEquals("%{bar}", dissect.parser().pattern()); assertEquals("", dissect.parser().appendSeparator()); - assertEquals(List.of(referenceAttribute("bar", KEYWORD)), dissect.extractedFields()); + assertEqualsIgnoringIds(List.of(referenceAttribute("bar", KEYWORD)), dissect.extractedFields()); UnresolvedRelation ur = as(dissect.child(), UnresolvedRelation.class); - assertEquals(ur, relation("test")); + assertEqualsIgnoringIds(ur, relation("test")); } public void testFunctionNamedParameterWithCaseSensitiveKeys() { @@ -2939,7 +2960,7 @@ public void testFunctionNamedParameterWithCaseSensitiveKeys() { expectedMap2.put("Option", List.of(1, 2, 3)); expectedMap2.put("oPtion", 2.0); - assertEquals( + assertEqualsIgnoringIds( new Filter( EMPTY, new Eval( @@ -3693,7 +3714,7 @@ public void testValidFork() { // first subplan var eval = as(subPlans.get(0), Eval.class); - assertThat(as(eval.fields().get(0), Alias.class), equalTo(alias("_fork", literalString("fork1")))); + assertThat(as(eval.fields().get(0), Alias.class), equalToIgnoringIds(alias("_fork", literalString("fork1")))); var limit = as(eval.child(), Limit.class); assertThat(limit.limit(), instanceOf(Literal.class)); assertThat(((Literal) limit.limit()).value(), equalTo(11)); @@ -3705,7 +3726,7 @@ public void testValidFork() { // second subplan eval = as(subPlans.get(1), Eval.class); - assertThat(as(eval.fields().get(0), Alias.class), equalTo(alias("_fork", literalString("fork2")))); + assertThat(as(eval.fields().get(0), Alias.class), equalToIgnoringIds(alias("_fork", literalString("fork2")))); var orderBy = as(eval.child(), OrderBy.class); assertThat(orderBy.order().size(), equalTo(1)); Order order = orderBy.order().get(0); @@ -3719,7 +3740,7 @@ public void testValidFork() { // third subplan eval = as(subPlans.get(2), Eval.class); - assertThat(as(eval.fields().get(0), Alias.class), equalTo(alias("_fork", literalString("fork3")))); + assertThat(as(eval.fields().get(0), Alias.class), equalToIgnoringIds(alias("_fork", literalString("fork3")))); filter = as(eval.child(), Filter.class); match = (MatchOperator) filter.condition(); matchField = (UnresolvedAttribute) match.field(); @@ -3728,7 +3749,7 @@ public void testValidFork() { // fourth subplan eval = as(subPlans.get(3), Eval.class); - assertThat(as(eval.fields().get(0), Alias.class), equalTo(alias("_fork", literalString("fork4")))); + assertThat(as(eval.fields().get(0), Alias.class), equalToIgnoringIds(alias("_fork", literalString("fork4")))); orderBy = as(eval.child(), OrderBy.class); assertThat(orderBy.order().size(), equalTo(1)); order = orderBy.order().get(0); @@ -3737,16 +3758,16 @@ public void testValidFork() { // fifth subplan eval = as(subPlans.get(4), Eval.class); - assertThat(as(eval.fields().get(0), Alias.class), equalTo(alias("_fork", literalString("fork5")))); + assertThat(as(eval.fields().get(0), Alias.class), equalToIgnoringIds(alias("_fork", literalString("fork5")))); limit = as(eval.child(), Limit.class); assertThat(limit.limit(), instanceOf(Literal.class)); assertThat(((Literal) limit.limit()).value(), equalTo(5)); // sixth subplan eval = as(subPlans.get(5), Eval.class); - assertThat(as(eval.fields().get(0), Alias.class), equalTo(alias("_fork", literalString("fork6")))); + assertThat(as(eval.fields().get(0), Alias.class), equalToIgnoringIds(alias("_fork", literalString("fork6")))); eval = as(eval.child(), Eval.class); - assertThat(as(eval.fields().get(0), Alias.class), equalTo(alias("xyz", literalString("abc")))); + assertThat(as(eval.fields().get(0), Alias.class), equalToIgnoringIds(alias("xyz", literalString("abc")))); Aggregate aggregate = as(eval.child(), Aggregate.class); assertThat(aggregate.aggregates().size(), equalTo(2)); @@ -3931,9 +3952,9 @@ public void testRerankDefaultInferenceIdAndScoreAttribute() { var rerank = as(plan, Rerank.class); assertThat(rerank.inferenceId(), equalTo(literalString(".rerank-v1-elasticsearch"))); - assertThat(rerank.scoreAttribute(), equalTo(attribute("_score"))); + assertThat(rerank.scoreAttribute(), equalToIgnoringIds(attribute("_score"))); assertThat(rerank.queryText(), equalTo(literalString("query text"))); - assertThat(rerank.rerankFields(), equalTo(List.of(alias("title", attribute("title"))))); + assertThat(rerank.rerankFields(), equalToIgnoringIds(List.of(alias("title", attribute("title"))))); } public void testRerankEmptyOptions() { @@ -3941,9 +3962,9 @@ public void testRerankEmptyOptions() { var rerank = as(plan, Rerank.class); assertThat(rerank.inferenceId(), equalTo(literalString(".rerank-v1-elasticsearch"))); - assertThat(rerank.scoreAttribute(), equalTo(attribute("_score"))); + assertThat(rerank.scoreAttribute(), equalToIgnoringIds(attribute("_score"))); assertThat(rerank.queryText(), equalTo(literalString("query text"))); - assertThat(rerank.rerankFields(), equalTo(List.of(alias("title", attribute("title"))))); + assertThat(rerank.rerankFields(), equalToIgnoringIds(List.of(alias("title", attribute("title"))))); } public void testRerankInferenceId() { @@ -3952,8 +3973,8 @@ public void testRerankInferenceId() { assertThat(rerank.inferenceId(), equalTo(literalString("inferenceId"))); assertThat(rerank.queryText(), equalTo(literalString("query text"))); - assertThat(rerank.rerankFields(), equalTo(List.of(alias("title", attribute("title"))))); - assertThat(rerank.scoreAttribute(), equalTo(attribute("_score"))); + assertThat(rerank.rerankFields(), equalToIgnoringIds(List.of(alias("title", attribute("title"))))); + assertThat(rerank.scoreAttribute(), equalToIgnoringIds(attribute("_score"))); } public void testRerankScoreAttribute() { @@ -3961,9 +3982,9 @@ public void testRerankScoreAttribute() { var rerank = as(plan, Rerank.class); assertThat(rerank.inferenceId(), equalTo(literalString(".rerank-v1-elasticsearch"))); - assertThat(rerank.scoreAttribute(), equalTo(attribute("rerank_score"))); + assertThat(rerank.scoreAttribute(), equalToIgnoringIds(attribute("rerank_score"))); assertThat(rerank.queryText(), equalTo(literalString("query text"))); - assertThat(rerank.rerankFields(), equalTo(List.of(alias("title", attribute("title"))))); + assertThat(rerank.rerankFields(), equalToIgnoringIds(List.of(alias("title", attribute("title"))))); } public void testRerankInferenceIdAnddScoreAttribute() { @@ -3971,9 +3992,9 @@ public void testRerankInferenceIdAnddScoreAttribute() { var rerank = as(plan, Rerank.class); assertThat(rerank.inferenceId(), equalTo(literalString("inferenceId"))); - assertThat(rerank.scoreAttribute(), equalTo(attribute("rerank_score"))); + assertThat(rerank.scoreAttribute(), equalToIgnoringIds(attribute("rerank_score"))); assertThat(rerank.queryText(), equalTo(literalString("query text"))); - assertThat(rerank.rerankFields(), equalTo(List.of(alias("title", attribute("title"))))); + assertThat(rerank.rerankFields(), equalToIgnoringIds(List.of(alias("title", attribute("title"))))); } public void testRerankSingleField() { @@ -3982,8 +4003,8 @@ public void testRerankSingleField() { assertThat(rerank.queryText(), equalTo(literalString("query text"))); assertThat(rerank.inferenceId(), equalTo(literalString("inferenceID"))); - assertThat(rerank.rerankFields(), equalTo(List.of(alias("title", attribute("title"))))); - assertThat(rerank.scoreAttribute(), equalTo(attribute("_score"))); + assertThat(rerank.rerankFields(), equalToIgnoringIds(List.of(alias("title", attribute("title"))))); + assertThat(rerank.scoreAttribute(), equalToIgnoringIds(attribute("_score"))); } public void testRerankMultipleFields() { @@ -3996,7 +4017,7 @@ public void testRerankMultipleFields() { assertThat(rerank.inferenceId(), equalTo(literalString("inferenceID"))); assertThat( rerank.rerankFields(), - equalTo( + equalToIgnoringIds( List.of( alias("title", attribute("title")), alias("description", attribute("description")), @@ -4004,7 +4025,7 @@ public void testRerankMultipleFields() { ) ) ); - assertThat(rerank.scoreAttribute(), equalTo(attribute("_score"))); + assertThat(rerank.scoreAttribute(), equalToIgnoringIds(attribute("_score"))); } public void testRerankComputedFields() { @@ -4017,14 +4038,14 @@ public void testRerankComputedFields() { assertThat(rerank.inferenceId(), equalTo(literalString("inferenceID"))); assertThat( rerank.rerankFields(), - equalTo( + equalToIgnoringIds( List.of( alias("title", attribute("title")), alias("short_description", function("SUBSTRING", List.of(attribute("description"), integer(0), integer(100)))) ) ) ); - assertThat(rerank.scoreAttribute(), equalTo(attribute("_score"))); + assertThat(rerank.scoreAttribute(), equalToIgnoringIds(attribute("_score"))); } public void testRerankComputedFieldsWithoutName() { @@ -4048,8 +4069,8 @@ public void testRerankWithPositionalParameters() { assertThat(rerank.queryText(), equalTo(literalString("query text"))); assertThat(rerank.inferenceId(), equalTo(literalString("reranker"))); - assertThat(rerank.rerankFields(), equalTo(List.of(alias("title", attribute("title"))))); - assertThat(rerank.scoreAttribute(), equalTo(attribute("rerank_score"))); + assertThat(rerank.rerankFields(), equalToIgnoringIds(List.of(alias("title", attribute("title"))))); + assertThat(rerank.scoreAttribute(), equalToIgnoringIds(attribute("rerank_score"))); } public void testRerankWithNamedParameters() { @@ -4065,8 +4086,8 @@ public void testRerankWithNamedParameters() { assertThat(rerank.queryText(), equalTo(literalString("query text"))); assertThat(rerank.inferenceId(), equalTo(literalString("reranker"))); - assertThat(rerank.rerankFields(), equalTo(List.of(alias("title", attribute("title"))))); - assertThat(rerank.scoreAttribute(), equalTo(attribute("rerank_score"))); + assertThat(rerank.rerankFields(), equalToIgnoringIds(List.of(alias("title", attribute("title"))))); + assertThat(rerank.scoreAttribute(), equalToIgnoringIds(attribute("rerank_score"))); } public void testInvalidRerank() { @@ -4110,9 +4131,9 @@ public void testCompletionUsingFieldAsPrompt() { Completion.class ); - assertThat(plan.prompt(), equalTo(attribute("prompt_field"))); + assertThat(plan.prompt(), equalToIgnoringIds(attribute("prompt_field"))); assertThat(plan.inferenceId(), equalTo(literalString("inferenceID"))); - assertThat(plan.targetField(), equalTo(attribute("targetField"))); + assertThat(plan.targetField(), equalToIgnoringIds(attribute("targetField"))); } public void testCompletionUsingFunctionAsPrompt() { @@ -4121,17 +4142,17 @@ public void testCompletionUsingFunctionAsPrompt() { Completion.class ); - assertThat(plan.prompt(), equalTo(function("CONCAT", List.of(attribute("fieldA"), attribute("fieldB"))))); + assertThat(plan.prompt(), equalToIgnoringIds(function("CONCAT", List.of(attribute("fieldA"), attribute("fieldB"))))); assertThat(plan.inferenceId(), equalTo(literalString("inferenceID"))); - assertThat(plan.targetField(), equalTo(attribute("targetField"))); + assertThat(plan.targetField(), equalToIgnoringIds(attribute("targetField"))); } public void testCompletionDefaultFieldName() { var plan = as(processingCommand("COMPLETION prompt_field WITH{ \"inference_id\" : \"inferenceID\" }"), Completion.class); - assertThat(plan.prompt(), equalTo(attribute("prompt_field"))); + assertThat(plan.prompt(), equalToIgnoringIds(attribute("prompt_field"))); assertThat(plan.inferenceId(), equalTo(literalString("inferenceID"))); - assertThat(plan.targetField(), equalTo(attribute("completion"))); + assertThat(plan.targetField(), equalToIgnoringIds(attribute("completion"))); } public void testCompletionWithPositionalParameters() { @@ -4145,9 +4166,9 @@ public void testCompletionWithPositionalParameters() { Completion.class ); - assertThat(plan.prompt(), equalTo(attribute("prompt_field"))); + assertThat(plan.prompt(), equalToIgnoringIds(attribute("prompt_field"))); assertThat(plan.inferenceId(), equalTo(literalString("inferenceId"))); - assertThat(plan.targetField(), equalTo(attribute("completion"))); + assertThat(plan.targetField(), equalToIgnoringIds(attribute("completion"))); } public void testCompletionWithNamedParameters() { @@ -4161,9 +4182,9 @@ public void testCompletionWithNamedParameters() { Completion.class ); - assertThat(plan.prompt(), equalTo(attribute("prompt_field"))); + assertThat(plan.prompt(), equalToIgnoringIds(attribute("prompt_field"))); assertThat(plan.inferenceId(), equalTo(literalString("myInference"))); - assertThat(plan.targetField(), equalTo(attribute("completion"))); + assertThat(plan.targetField(), equalToIgnoringIds(attribute("completion"))); } public void testInvalidCompletion() { @@ -4357,7 +4378,7 @@ public void testDoubleParamsForIdentifier() { | eval {} = {}({}) | where {} == {} | limit 1""", params.get(0), params.get(1), params.get(2), params.get(3), params.get(4)); - assertEquals( + assertEqualsIgnoringIds( new Limit( EMPTY, new Literal(EMPTY, 1, INTEGER), @@ -4406,7 +4427,7 @@ public void testDoubleParamsForIdentifier() { params.get(6), params.get(7) ); - assertEquals( + assertEqualsIgnoringIds( new Limit( EMPTY, new Literal(EMPTY, 1, INTEGER), @@ -4452,7 +4473,7 @@ public void testDoubleParamsForIdentifier() { | stats y = {}({}) by {} | sort {} | mv_expand {}""", params.get(0), params.get(1), params.get(2), params.get(3), params.get(4)); - assertEquals( + assertEqualsIgnoringIds( new MvExpand( EMPTY, new OrderBy( @@ -4508,7 +4529,7 @@ public void testDoubleParamsForIdentifier() { params.get(7), params.get(8) ); - assertEquals( + assertEqualsIgnoringIds( new MvExpand( EMPTY, new OrderBy( @@ -4594,23 +4615,23 @@ public void testDoubleParamsForIdentifier() { UnresolvedRelation ur = as(join.right(), UnresolvedRelation.class); assertEquals(ur.indexPattern().indexPattern(), "idx"); assertEquals(join.config().type().joinName(), "LEFT OUTER"); - assertEquals(join.config().leftFields(), List.of(attribute("f9"))); + assertEqualsIgnoringIds(join.config().leftFields(), List.of(attribute("f9"))); Rename rename = as(join.left(), Rename.class); - assertEquals(rename.renamings(), List.of(new Alias(EMPTY, "f.8", attribute("f7*.")))); + assertEqualsIgnoringIds(rename.renamings(), List.of(new Alias(EMPTY, "f.8", attribute("f7*.")))); Grok grok = as(rename.child(), Grok.class); - assertEquals(grok.input(), attribute("f.6.")); + assertEqualsIgnoringIds(grok.input(), attribute("f.6.")); assertEquals("%{WORD:foo}", grok.parser().pattern()); - assertEquals(List.of(referenceAttribute("foo", KEYWORD)), grok.extractedFields()); + assertEqualsIgnoringIds(List.of(referenceAttribute("foo", KEYWORD)), grok.extractedFields()); Dissect dissect = as(grok.child(), Dissect.class); - assertEquals(dissect.input(), attribute("f.5*")); + assertEqualsIgnoringIds(dissect.input(), attribute("f.5*")); assertEquals("%{bar}", dissect.parser().pattern()); assertEquals("", dissect.parser().appendSeparator()); - assertEquals(List.of(referenceAttribute("bar", KEYWORD)), dissect.extractedFields()); + assertEqualsIgnoringIds(List.of(referenceAttribute("bar", KEYWORD)), dissect.extractedFields()); Drop drop = as(dissect.child(), Drop.class); List removals = drop.removals(); - assertEquals(removals, List.of(attribute("f3."), attribute("f4.*"))); + assertEqualsIgnoringIds(removals, List.of(attribute("f3."), attribute("f4.*"))); Keep keep = as(drop.child(), Keep.class); - assertEquals(keep.projections(), List.of(attribute("f.1.*"), attribute("f.2"))); + assertEqualsIgnoringIds(keep.projections(), List.of(attribute("f.1.*"), attribute("f.2"))); } namedDoubleParams = List.of( @@ -4703,23 +4724,23 @@ public void testDoubleParamsForIdentifier() { UnresolvedRelation ur = as(join.right(), UnresolvedRelation.class); assertEquals(ur.indexPattern().indexPattern(), "idx"); assertEquals(join.config().type().joinName(), "LEFT OUTER"); - assertEquals(join.config().leftFields(), List.of(attribute("f13.f14"))); + assertEqualsIgnoringIds(join.config().leftFields(), List.of(attribute("f13.f14"))); Rename rename = as(join.left(), Rename.class); - assertEquals(rename.renamings(), List.of(new Alias(EMPTY, "f11*..f.12", attribute("f.9*.f.10.")))); + assertEqualsIgnoringIds(rename.renamings(), List.of(new Alias(EMPTY, "f11*..f.12", attribute("f.9*.f.10.")))); Grok grok = as(rename.child(), Grok.class); - assertEquals(grok.input(), attribute("f7*..f.8")); + assertEqualsIgnoringIds(grok.input(), attribute("f7*..f.8")); assertEquals("%{WORD:foo}", grok.parser().pattern()); - assertEquals(List.of(referenceAttribute("foo", KEYWORD)), grok.extractedFields()); + assertEqualsIgnoringIds(List.of(referenceAttribute("foo", KEYWORD)), grok.extractedFields()); Dissect dissect = as(grok.child(), Dissect.class); - assertEquals(dissect.input(), attribute("f.5*.f.6.")); + assertEqualsIgnoringIds(dissect.input(), attribute("f.5*.f.6.")); assertEquals("%{bar}", dissect.parser().pattern()); assertEquals("", dissect.parser().appendSeparator()); - assertEquals(List.of(referenceAttribute("bar", KEYWORD)), dissect.extractedFields()); + assertEqualsIgnoringIds(List.of(referenceAttribute("bar", KEYWORD)), dissect.extractedFields()); Drop drop = as(dissect.child(), Drop.class); List removals = drop.removals(); - assertEquals(removals, List.of(attribute("f3..f4.*"))); + assertEqualsIgnoringIds(removals, List.of(attribute("f3..f4.*"))); Keep keep = as(drop.child(), Keep.class); - assertEquals(keep.projections(), List.of(attribute("f.1.*.f.2"))); + assertEqualsIgnoringIds(keep.projections(), List.of(attribute("f.1.*.f.2"))); } // enrich, lookup join @@ -4738,7 +4759,7 @@ public void testDoubleParamsForIdentifier() { params.get(1), params.get(2) ); - assertEquals( + assertEqualsIgnoringIds( new Enrich( EMPTY, relation("idx1"), @@ -4809,7 +4830,7 @@ public void testDoubleParamsForIdentifier() { params.get(4), params.get(5) ); - assertEquals( + assertEqualsIgnoringIds( new Enrich( EMPTY, relation("idx1"), @@ -4861,7 +4882,7 @@ public void testMixedSingleDoubleParams() { | eval {} = {}({}) | where {} == {} | limit 1""", params.get(0), params.get(1), params.get(2), params.get(3), params.get(4)); - assertEquals( + assertEqualsIgnoringIds( new Limit( EMPTY, new Literal(EMPTY, 1, INTEGER), @@ -4904,7 +4925,7 @@ public void testMixedSingleDoubleParams() { | stats y = {}({}) by {} | sort {} | mv_expand {}""", params.get(0), params.get(1), params.get(2), params.get(3), params.get(4)); - assertEquals( + assertEqualsIgnoringIds( new MvExpand( EMPTY, new OrderBy( @@ -4953,7 +4974,7 @@ public void testMixedSingleDoubleParams() { UnresolvedRelation ur = as(join.right(), UnresolvedRelation.class); assertEquals(ur.indexPattern().indexPattern(), "idx"); assertEquals(join.config().type().joinName(), "LEFT OUTER"); - assertEquals(join.config().leftFields(), List.of(attribute("f5"))); + assertEqualsIgnoringIds(join.config().leftFields(), List.of(attribute("f5"))); Drop drop = as(join.left(), Drop.class); List removals = drop.removals(); assertEquals(removals.size(), 2); @@ -4970,7 +4991,7 @@ public void testMixedSingleDoubleParams() { assertEquals(up.name(), "f.2*"); assertEquals(up.pattern(), "f.2*"); ur = as(keep.child(), UnresolvedRelation.class); - assertEquals(ur, relation("test")); + assertEqualsIgnoringIds(ur, relation("test")); // test random single and double params // commands in group1 take both constants(?) and identifiers(??) From 99dd677c2d27f1d91c1deb9b1c6fd41cfeb7d374 Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Fri, 3 Oct 2025 14:55:41 +0200 Subject: [PATCH 29/38] Update x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Alias.java --- .../org/elasticsearch/xpack/esql/core/expression/Alias.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Alias.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Alias.java index 22b0aa78ae282..dada0557febf2 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Alias.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Alias.java @@ -160,7 +160,7 @@ public int hashCode() { } /** - * Compared to e.g. {@link UnresolvedAttribute}, the id is part of equality for Alias because the {@link ReferenceAttribute} created + * The id is part of equality for Alias because the {@link ReferenceAttribute} created * by {@link #toAttribute()} uses it. */ @Override From 5afab2f3dc094183a3a9dca7df10292fecfcb6ed Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Mon, 6 Oct 2025 11:08:43 +0200 Subject: [PATCH 30/38] Simplify passing through test id mappers --- .../xpack/esql/io/stream/PlanStreamInput.java | 9 +++++---- .../elasticsearch/xpack/esql/plugin/DataNodeRequest.java | 7 +++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/io/stream/PlanStreamInput.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/io/stream/PlanStreamInput.java index daae00fae7ece..6544a307de470 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/io/stream/PlanStreamInput.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/io/stream/PlanStreamInput.java @@ -78,21 +78,22 @@ protected Map seen() { private final Configuration configuration; public PlanStreamInput(StreamInput streamInput, NamedWriteableRegistry namedWriteableRegistry, Configuration configuration) { - this(streamInput, namedWriteableRegistry, configuration, new NameIdMapper()); + this(streamInput, namedWriteableRegistry, configuration, null); } /** - * Public for testing, only. Use {@link #PlanStreamInput(StreamInput, NamedWriteableRegistry, Configuration)} in production. + * @param idMapper should always be null in production! Custom mappers are only used in tests to force ID values to be the same after + * serialization and deserialization, which is not the case when they are generated as usual. */ public PlanStreamInput( StreamInput streamInput, NamedWriteableRegistry namedWriteableRegistry, Configuration configuration, - NameIdMapper nameIdFunction + NameIdMapper idMapper ) { super(streamInput, namedWriteableRegistry); this.configuration = configuration; - this.nameIdFunction = nameIdFunction; + this.nameIdFunction = idMapper == null ? new NameIdMapper() : idMapper; } public Configuration configuration() throws IOException { diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/DataNodeRequest.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/DataNodeRequest.java index 5b4f6575dfbc9..67371030d6010 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/DataNodeRequest.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/DataNodeRequest.java @@ -82,7 +82,8 @@ final class DataNodeRequest extends AbstractTransportRequest implements IndicesR } /** - * @param idMapper non-null for testing only, never in production! + * @param idMapper should always be null in production! Custom mappers are only used in tests to force ID values to be the same after + * serialization and deserialization, which is not the case when they are generated as usual. */ DataNodeRequest(StreamInput in, PlanStreamInput.NameIdMapper idMapper) throws IOException { super(in); @@ -94,9 +95,7 @@ final class DataNodeRequest extends AbstractTransportRequest implements IndicesR this.clusterAlias = in.readString(); this.shardIds = in.readCollectionAsList(ShardId::new); this.aliasFilters = in.readMap(Index::new, AliasFilter::readFrom); - PlanStreamInput pin = idMapper == null - ? new PlanStreamInput(in, in.namedWriteableRegistry(), configuration) - : new PlanStreamInput(in, in.namedWriteableRegistry(), configuration, idMapper); + PlanStreamInput pin = new PlanStreamInput(in, in.namedWriteableRegistry(), configuration, idMapper); this.plan = pin.readNamedWriteable(PhysicalPlan.class); this.indices = in.readStringArray(); this.indicesOptions = IndicesOptions.readIndicesOptions(in); From 6c5bd8c94347fe047d24170c9ed34cbde864d2e3 Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Mon, 6 Oct 2025 12:09:25 +0200 Subject: [PATCH 31/38] Fix some more tests --- .../xpack/esql/EsqlTestUtils.java | 19 +++++++++++-- .../esql/plugin/ClusterComputeRequest.java | 9 +++++- .../scalar/conditional/CaseExtraTests.java | 25 ++++++++++------- .../esql/io/stream/PlanStreamOutputTests.java | 28 +++++++++++++++++-- ...IgnoreNullMetricsPhysicalPlannerTests.java | 3 +- .../optimizer/LogicalPlanOptimizerTests.java | 21 ++++++++------ .../xpack/esql/parser/ExpressionTests.java | 22 ++++++++------- .../xpack/esql/parser/QualifierTests.java | 7 +++-- .../ExchangeSinkExecSerializationTests.java | 10 ++++++- .../esql/plugin/ClusterRequestTests.java | 3 +- 10 files changed, 106 insertions(+), 41 deletions(-) diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java b/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java index 88c34d6b4d188..c6d5dc46c140a 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java @@ -116,6 +116,7 @@ import org.elasticsearch.xpack.versionfield.Version; import org.hamcrest.Matcher; import org.hamcrest.collection.IsIterableContainingInAnyOrder; +import org.hamcrest.collection.IsIterableContainingInOrder; import org.hamcrest.core.IsEqual; import org.junit.Assert; @@ -1019,7 +1020,11 @@ public static Exception unwrapIfWrappedInRemoteException(Exception e) { } public static void assertEqualsIgnoringIds(Object expected, Object actual) { - assertThat(actual, equalToIgnoringIds(expected)); + assertEqualsIgnoringIds("", expected, actual); + } + + public static void assertEqualsIgnoringIds(String reason, Object expected, Object actual) { + assertThat(reason, actual, equalToIgnoringIds(expected)); } /** @@ -1030,6 +1035,16 @@ public static org.hamcrest.Matcher equalToIgnoringIds(T operand) { return new IsEqualIgnoringIds(operand); } + @SafeVarargs + public static org.hamcrest.Matcher> containsIgnoringIds(T... items) { + List> matchers = new ArrayList<>(); + for (T item : items) { + matchers.add(equalToIgnoringIds(item)); + } + + return new IsIterableContainingInOrder<>(matchers); + } + @SafeVarargs public static org.hamcrest.Matcher> containsInAnyOrderIgnoringIds(T... items) { List> matchers = new ArrayList<>(); @@ -1052,7 +1067,7 @@ public boolean matches(Object actualValue) { } } - private static Object ignoreIds(Object node) { + public static Object ignoreIds(Object node) { return switch (node) { case Expression expression -> ignoreIdsInExpression(expression); case LogicalPlan plan -> ignoreIdsInLogicalPlan(plan); diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ClusterComputeRequest.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ClusterComputeRequest.java index d83ca4beef52c..28cef1bcab8ce 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ClusterComputeRequest.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ClusterComputeRequest.java @@ -60,6 +60,13 @@ final class ClusterComputeRequest extends AbstractTransportRequest implements In } ClusterComputeRequest(StreamInput in) throws IOException { + this(in, null); + } + + /** + * @param idMapper must always be null in production. Only used in tests to remap NameIds when deserializing. + */ + ClusterComputeRequest(StreamInput in, PlanStreamInput.NameIdMapper idMapper) throws IOException { super(in); this.clusterAlias = in.readString(); this.sessionId = in.readString(); @@ -67,7 +74,7 @@ final class ClusterComputeRequest extends AbstractTransportRequest implements In // TODO make EsqlConfiguration Releasable new BlockStreamInput(in, new BlockFactory(new NoopCircuitBreaker(CircuitBreaker.REQUEST), BigArrays.NON_RECYCLING_INSTANCE)) ); - this.plan = RemoteClusterPlan.from(new PlanStreamInput(in, in.namedWriteableRegistry(), configuration)); + this.plan = RemoteClusterPlan.from(new PlanStreamInput(in, in.namedWriteableRegistry(), configuration, idMapper)); this.indices = plan.originalIndices().indices(); } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/CaseExtraTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/CaseExtraTests.java index a7ca2a7a37e19..08c4649b548d4 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/CaseExtraTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/CaseExtraTests.java @@ -35,6 +35,7 @@ import java.util.stream.Stream; import static org.elasticsearch.compute.data.BlockUtils.toJavaObject; +import static org.elasticsearch.xpack.esql.EsqlTestUtils.equalToIgnoringIds; import static org.elasticsearch.xpack.esql.expression.function.AbstractFunctionTestCase.field; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.sameInstance; @@ -51,14 +52,14 @@ public void testElseValueExplicit() { field("first_cond", DataType.BOOLEAN), List.of(field("v", DataType.LONG), field("e", DataType.LONG)) ).children(), - equalTo(List.of(field("first_cond", DataType.BOOLEAN), field("v", DataType.LONG), field("e", DataType.LONG))) + equalToIgnoringIds(List.of(field("first_cond", DataType.BOOLEAN), field("v", DataType.LONG), field("e", DataType.LONG))) ); } public void testElseValueImplied() { assertThat( new Case(Source.synthetic("case"), field("first_cond", DataType.BOOLEAN), List.of(field("v", DataType.LONG))).children(), - equalTo(List.of(field("first_cond", DataType.BOOLEAN), field("v", DataType.LONG))) + equalToIgnoringIds(List.of(field("first_cond", DataType.BOOLEAN), field("v", DataType.LONG))) ); } @@ -71,7 +72,9 @@ public void testPartialFoldDropsFirstFalse() { assertThat(c.foldable(), equalTo(false)); assertThat( c.partiallyFold(FoldContext.small()), - equalTo(new Case(Source.synthetic("case"), field("last_cond", DataType.BOOLEAN), List.of(field("last", DataType.LONG)))) + equalToIgnoringIds( + new Case(Source.synthetic("case"), field("last_cond", DataType.BOOLEAN), List.of(field("last", DataType.LONG))) + ) ); } @@ -84,7 +87,9 @@ public void testPartialFoldMv() { assertThat(c.foldable(), equalTo(false)); assertThat( c.partiallyFold(FoldContext.small()), - equalTo(new Case(Source.synthetic("case"), field("last_cond", DataType.BOOLEAN), List.of(field("last", DataType.LONG)))) + equalToIgnoringIds( + new Case(Source.synthetic("case"), field("last_cond", DataType.BOOLEAN), List.of(field("last", DataType.LONG))) + ) ); } @@ -105,7 +110,7 @@ public void testPartialFoldFirst() { List.of(field("first", DataType.LONG), field("last", DataType.LONG)) ); assertThat(c.foldable(), equalTo(false)); - assertThat(c.partiallyFold(FoldContext.small()), equalTo(field("first", DataType.LONG))); + assertThat(c.partiallyFold(FoldContext.small()), equalToIgnoringIds(field("first", DataType.LONG))); } public void testPartialFoldFirstAfterKeepingUnknown() { @@ -122,7 +127,7 @@ public void testPartialFoldFirstAfterKeepingUnknown() { assertThat(c.foldable(), equalTo(false)); assertThat( c.partiallyFold(FoldContext.small()), - equalTo( + equalToIgnoringIds( new Case( Source.synthetic("case"), field("keep_me_cond", DataType.BOOLEAN), @@ -144,7 +149,7 @@ public void testPartialFoldSecond() { ) ); assertThat(c.foldable(), equalTo(false)); - assertThat(c.partiallyFold(FoldContext.small()), equalTo(field("second", DataType.LONG))); + assertThat(c.partiallyFold(FoldContext.small()), equalToIgnoringIds(field("second", DataType.LONG))); } public void testPartialFoldSecondAfterDroppingFalse() { @@ -159,7 +164,7 @@ public void testPartialFoldSecondAfterDroppingFalse() { ) ); assertThat(c.foldable(), equalTo(false)); - assertThat(c.partiallyFold(FoldContext.small()), equalTo(field("second", DataType.LONG))); + assertThat(c.partiallyFold(FoldContext.small()), equalToIgnoringIds(field("second", DataType.LONG))); } public void testPartialFoldLast() { @@ -174,7 +179,7 @@ public void testPartialFoldLast() { ) ); assertThat(c.foldable(), equalTo(false)); - assertThat(c.partiallyFold(FoldContext.small()), equalTo(field("last", DataType.LONG))); + assertThat(c.partiallyFold(FoldContext.small()), equalToIgnoringIds(field("last", DataType.LONG))); } public void testPartialFoldLastAfterKeepingUnknown() { @@ -191,7 +196,7 @@ public void testPartialFoldLastAfterKeepingUnknown() { assertThat(c.foldable(), equalTo(false)); assertThat( c.partiallyFold(FoldContext.small()), - equalTo( + equalToIgnoringIds( new Case( Source.synthetic("case"), field("keep_me_cond", DataType.BOOLEAN), diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/io/stream/PlanStreamOutputTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/io/stream/PlanStreamOutputTests.java index bb5f80b18e3cf..04b7bf6a626d0 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/io/stream/PlanStreamOutputTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/io/stream/PlanStreamOutputTests.java @@ -18,6 +18,7 @@ import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.TransportVersionUtils; import org.elasticsearch.xpack.esql.Column; +import org.elasticsearch.xpack.esql.SerializationTestUtils; import org.elasticsearch.xpack.esql.core.InvalidArgumentException; import org.elasticsearch.xpack.esql.core.expression.Attribute; import org.elasticsearch.xpack.esql.core.expression.NameId; @@ -143,7 +144,14 @@ public void testWriteMultipleAttributes() throws IOException { } } - try (PlanStreamInput in = new PlanStreamInput(out.bytes().streamInput(), REGISTRY, configuration)) { + try ( + PlanStreamInput in = new PlanStreamInput( + out.bytes().streamInput(), + REGISTRY, + configuration, + new SerializationTestUtils.TestNameIdMapper() + ) + ) { List readAttrs = new ArrayList<>(); for (int i = 0; i < occurrences; i++) { readAttrs.add(in.readNamedWriteable(Attribute.class)); @@ -181,7 +189,14 @@ public void testWriteEqualAttributesDifferentID() throws IOException { planStream.writeNamedWriteable(one); planStream.writeNamedWriteable(two); - try (PlanStreamInput in = new PlanStreamInput(out.bytes().streamInput(), REGISTRY, configuration)) { + try ( + PlanStreamInput in = new PlanStreamInput( + out.bytes().streamInput(), + REGISTRY, + configuration, + new SerializationTestUtils.TestNameIdMapper() + ) + ) { Attribute oneCopy = in.readNamedWriteable(Attribute.class); Attribute twoCopy = in.readNamedWriteable(Attribute.class); @@ -203,7 +218,14 @@ public void testWriteDifferentAttributesSameID() throws IOException { planStream.writeNamedWriteable(one); planStream.writeNamedWriteable(two); - try (PlanStreamInput in = new PlanStreamInput(out.bytes().streamInput(), REGISTRY, configuration)) { + try ( + PlanStreamInput in = new PlanStreamInput( + out.bytes().streamInput(), + REGISTRY, + configuration, + new SerializationTestUtils.TestNameIdMapper() + ) + ) { Attribute oneCopy = in.readNamedWriteable(Attribute.class); Attribute twoCopy = in.readNamedWriteable(Attribute.class); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/IgnoreNullMetricsPhysicalPlannerTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/IgnoreNullMetricsPhysicalPlannerTests.java index c89325d1bbd08..09962b694addd 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/IgnoreNullMetricsPhysicalPlannerTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/IgnoreNullMetricsPhysicalPlannerTests.java @@ -15,6 +15,7 @@ import org.elasticsearch.xpack.esql.session.Configuration; import static org.elasticsearch.index.query.QueryBuilders.existsQuery; +import static org.elasticsearch.xpack.esql.EsqlTestUtils.assertEqualsIgnoringIds; import static org.elasticsearch.xpack.esql.core.querydsl.query.Query.unscore; import static org.hamcrest.Matchers.is; @@ -47,7 +48,7 @@ public void testSamePhysicalPlans() { """; PhysicalPlan expectedPlan = plannerOptimizerTimeSeries.plan(controlQuery); - assertEquals(NodeUtils.diffString(expectedPlan, actualPlan), expectedPlan, actualPlan); + assertEqualsIgnoringIds(NodeUtils.diffString(expectedPlan, actualPlan), expectedPlan, actualPlan); } public void testPushdownOfSimpleCounterQuery() { diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java index 6f1f060b466d2..7500b85cdaffb 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java @@ -159,10 +159,12 @@ import static org.elasticsearch.xpack.esql.EsqlTestUtils.TWO; import static org.elasticsearch.xpack.esql.EsqlTestUtils.as; import static org.elasticsearch.xpack.esql.EsqlTestUtils.asLimit; +import static org.elasticsearch.xpack.esql.EsqlTestUtils.containsIgnoringIds; import static org.elasticsearch.xpack.esql.EsqlTestUtils.emptyInferenceResolution; import static org.elasticsearch.xpack.esql.EsqlTestUtils.emptySource; import static org.elasticsearch.xpack.esql.EsqlTestUtils.fieldAttribute; import static org.elasticsearch.xpack.esql.EsqlTestUtils.getFieldAttribute; +import static org.elasticsearch.xpack.esql.EsqlTestUtils.ignoreIds; import static org.elasticsearch.xpack.esql.EsqlTestUtils.localSource; import static org.elasticsearch.xpack.esql.EsqlTestUtils.randomLiteral; import static org.elasticsearch.xpack.esql.EsqlTestUtils.referenceAttribute; @@ -1236,7 +1238,7 @@ public void testPushDownEvalPastProject() { var eval = as(keep.child(), Eval.class); assertThat( eval.fields(), - contains( + containsIgnoringIds( new Alias( EMPTY, "y", @@ -1256,7 +1258,7 @@ public void testPushDownDissectPastProject() { var keep = as(plan, Project.class); var dissect = as(keep.child(), Dissect.class); - assertThat(dissect.extractedFields(), contains(referenceAttribute("y", DataType.KEYWORD))); + assertThat(dissect.extractedFields(), containsIgnoringIds(referenceAttribute("y", DataType.KEYWORD))); } public void testPushDownGrokPastProject() { @@ -1269,7 +1271,7 @@ public void testPushDownGrokPastProject() { var keep = as(plan, Project.class); var grok = as(keep.child(), Grok.class); - assertThat(grok.extractedFields(), contains(referenceAttribute("y", DataType.KEYWORD))); + assertThat(grok.extractedFields(), containsIgnoringIds(referenceAttribute("y", DataType.KEYWORD))); } public void testPushDownFilterPastProjectUsingEval() { @@ -2703,7 +2705,7 @@ public void testDontPruneSameFieldDifferentDirectionSortClauses() { var topN = as(keep.child(), TopN.class); assertThat( topN.order(), - contains( + containsIgnoringIds( new Order( EMPTY, new ReferenceAttribute(EMPTY, null, "e", INTEGER, Nullability.TRUE, null, false), @@ -2746,7 +2748,7 @@ public void testPruneRedundantSortClauses() { var topN = as(project.child(), TopN.class); assertThat( topN.order(), - contains( + containsIgnoringIds( new Order( EMPTY, new ReferenceAttribute(EMPTY, null, "e", INTEGER, Nullability.TRUE, null, false), @@ -2788,7 +2790,7 @@ public void testDontPruneSameFieldDifferentDirectionSortClauses_UsingAlias() { var topN = as(keep.child(), TopN.class); assertThat( topN.order(), - contains( + containsIgnoringIds( new Order( EMPTY, new FieldAttribute(EMPTY, "emp_no", mapping.get("emp_no")), @@ -2811,7 +2813,7 @@ public void testPruneRedundantSortClausesUsingAlias() { var topN = as(project.child(), TopN.class); assertThat( topN.order(), - contains( + containsIgnoringIds( new Order( EMPTY, new FieldAttribute(EMPTY, "emp_no", mapping.get("emp_no")), @@ -6352,7 +6354,7 @@ public void testInlineStatsWithRow() { var localRelation = as(limit.child(), LocalRelation.class); assertThat( localRelation.output(), - contains( + containsIgnoringIds( new ReferenceAttribute(EMPTY, "salary", INTEGER), new ReferenceAttribute(EMPTY, "emp_no", INTEGER), new ReferenceAttribute(EMPTY, "gender", KEYWORD) @@ -6645,7 +6647,8 @@ private void doTestSimplifyComparisonArithmetics( private void assertSemanticMatching(String expected, String provided) { BinaryComparison bc = extractPlannedBinaryComparison(provided); LogicalPlan exp = analyzerTypes.analyze(parser.createStatement("FROM types | WHERE " + expected, EsqlTestUtils.TEST_CFG)); - assertSemanticMatching(bc, extractPlannedBinaryComparison(exp)); + // Exp is created separately, so the IDs will be different - ignore them for the comparison. + assertSemanticMatching((BinaryComparison) ignoreIds(bc), (EsqlBinaryComparison) ignoreIds(extractPlannedBinaryComparison(exp))); } private static void assertSemanticMatching(Expression fieldAttributeExp, Expression unresolvedAttributeExp) { diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/ExpressionTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/ExpressionTests.java index 0696f2c99e03e..0b15f7f57161c 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/ExpressionTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/ExpressionTests.java @@ -45,6 +45,8 @@ import java.util.stream.IntStream; import static org.elasticsearch.xpack.esql.EsqlTestUtils.as; +import static org.elasticsearch.xpack.esql.EsqlTestUtils.assertEqualsIgnoringIds; +import static org.elasticsearch.xpack.esql.EsqlTestUtils.equalToIgnoringIds; import static org.elasticsearch.xpack.esql.core.tree.Source.EMPTY; import static org.elasticsearch.xpack.esql.core.type.DataType.DATE_PERIOD; import static org.elasticsearch.xpack.esql.core.type.DataType.DOUBLE; @@ -327,32 +329,32 @@ public void testOperatorsPrecedenceWithNegation() { } public void testOperatorsPrecedenceExpressionsEquality() { - assertThat(whereExpression("a-1>2 or b>=5 and c-1>=5"), equalTo(whereExpression("((a-1)>2 or (b>=5 and (c-1)>=5))"))); + assertThat(whereExpression("a-1>2 or b>=5 and c-1>=5"), equalToIgnoringIds(whereExpression("((a-1)>2 or (b>=5 and (c-1)>=5))"))); assertThat( whereExpression("a*5==25 and b>5 and c%4>=1 or true or false"), - equalTo(whereExpression("(((((a*5)==25) and (b>5) and ((c%4)>=1)) or true) or false)")) + equalToIgnoringIds(whereExpression("(((((a*5)==25) and (b>5) and ((c%4)>=1)) or true) or false)")) ); assertThat( whereExpression("a*4-b*5<100 and b/2+c*6>=50 or c%5+x>=5"), - equalTo(whereExpression("((((a*4)-(b*5))<100) and (((b/2)+(c*6))>=50)) or (((c%5)+x)>=5)")) + equalToIgnoringIds(whereExpression("((((a*4)-(b*5))<100) and (((b/2)+(c*6))>=50)) or (((c%5)+x)>=5)")) ); assertThat( whereExpression("true and false or true and c/12+x*5-y%2>=50"), - equalTo(whereExpression("((true and false) or (true and (((c/12)+(x*5)-(y%2))>=50)))")) + equalToIgnoringIds(whereExpression("((true and false) or (true and (((c/12)+(x*5)-(y%2))>=50)))")) ); assertThat( whereExpression("10 days > 5 hours and 1/5 minutes > 8 seconds * 3 and -1 minutes > foo"), - equalTo(whereExpression("((10 days) > (5 hours)) and ((1/(5 minutes) > ((8 seconds) * 3))) and (-1 minute > foo)")) + equalToIgnoringIds(whereExpression("((10 days) > (5 hours)) and ((1/(5 minutes) > ((8 seconds) * 3))) and (-1 minute > foo)")) ); assertThat( whereExpression("10 DAYS > 5 HOURS and 1/5 MINUTES > 8 SECONDS * 3 and -1 MINUTES > foo"), - equalTo(whereExpression("((10 days) > (5 hours)) and ((1/(5 minutes) > ((8 seconds) * 3))) and (-1 minute > foo)")) + equalToIgnoringIds(whereExpression("((10 days) > (5 hours)) and ((1/(5 minutes) > ((8 seconds) * 3))) and (-1 minute > foo)")) ); } public void testFunctionExpressions() { assertEquals(new UnresolvedFunction(EMPTY, "fn", DEFAULT, new ArrayList<>()), whereExpression("fn()")); - assertEquals( + assertEqualsIgnoringIds( new UnresolvedFunction( EMPTY, "invoke", @@ -366,13 +368,13 @@ public void testFunctionExpressions() { ), whereExpression("invoke(a, b + c)") ); - assertEquals(whereExpression("(invoke((a + b)))"), whereExpression("invoke(a+b)")); - assertEquals(whereExpression("((fn()) + fn(fn()))"), whereExpression("fn() + fn(fn())")); + assertEqualsIgnoringIds(whereExpression("(invoke((a + b)))"), whereExpression("invoke(a+b)")); + assertEqualsIgnoringIds(whereExpression("((fn()) + fn(fn()))"), whereExpression("fn() + fn(fn())")); } public void testUnquotedIdentifiers() { for (String identifier : List.of("a", "_a", "a_b", "a9", "abc123", "a_____9", "__a_b", "@a", "_1", "@2")) { - assertEquals(new UnresolvedAttribute(EMPTY, identifier), whereExpression(identifier)); + assertEqualsIgnoringIds(new UnresolvedAttribute(EMPTY, identifier), whereExpression(identifier)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/QualifierTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/QualifierTests.java index dfc13c7b3f24c..855a798b9fa80 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/QualifierTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/QualifierTests.java @@ -23,6 +23,7 @@ import java.util.function.Function; import static org.elasticsearch.xpack.esql.EsqlTestUtils.as; +import static org.elasticsearch.xpack.esql.EsqlTestUtils.assertEqualsIgnoringIds; public class QualifierTests extends AbstractStatementParserTests { public void testQualifiersAreDisabledInReleaseBuilds() { @@ -57,7 +58,7 @@ public void testSimpleQualifierInExpression() { UnresolvedRelation relation = as(join.right(), UnresolvedRelation.class); UnresolvedAttribute filterExpr = as(filter.condition(), UnresolvedAttribute.class); - assertEquals(new UnresolvedAttribute(Source.EMPTY, "qualified", "field", null), filterExpr); + assertEqualsIgnoringIds(new UnresolvedAttribute(Source.EMPTY, "qualified", "field", null), filterExpr); assertEquals("Unknown column [[qualified].[field]]", filterExpr.unresolvedMessage()); String referenceQuery = "ROW x = 1 | LOOKUP JOIN lu_idx AS qualified ON x | WHERE qualified.field"; @@ -894,7 +895,7 @@ private void assertQualifiedAttributeInExpressions( LogicalPlan referencePlan = statement(referenceQuery).transformExpressionsDown(Expression.class, normalizeExpressions); - assertEquals(referencePlan, planWithStrippedQualifiers); + assertEqualsIgnoringIds(referencePlan, planWithStrippedQualifiers); } private static int countAttribute(Expression expr, String qualifier, String name) { @@ -912,6 +913,6 @@ private static int countAttribute(Expression expr, String qualifier, String name private void assertStatementsEqual(String query1, String query2) { LogicalPlan plan1 = statement(query1); LogicalPlan plan2 = statement(query2); - assertEquals(plan1, plan2); + assertEqualsIgnoringIds(plan1, plan2); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plan/physical/ExchangeSinkExecSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plan/physical/ExchangeSinkExecSerializationTests.java index f4effe507ab64..95c8cdaf186ea 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plan/physical/ExchangeSinkExecSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plan/physical/ExchangeSinkExecSerializationTests.java @@ -10,6 +10,7 @@ import org.elasticsearch.common.io.stream.BytesStreamOutput; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.index.IndexMode; +import org.elasticsearch.xpack.esql.SerializationTestUtils; import org.elasticsearch.xpack.esql.analysis.Analyzer; import org.elasticsearch.xpack.esql.core.expression.Attribute; import org.elasticsearch.xpack.esql.core.expression.Literal; @@ -212,7 +213,14 @@ private void testSerializePlanWithIndex(EsIndex index, ByteSizeValue expected, b try (BytesStreamOutput out = new BytesStreamOutput(); PlanStreamOutput pso = new PlanStreamOutput(out, configuration())) { pso.writeNamedWriteable(exchangeSinkExec); assertThat(ByteSizeValue.ofBytes(out.bytes().length()), byteSizeEquals(expected)); - try (PlanStreamInput psi = new PlanStreamInput(out.bytes().streamInput(), getNamedWriteableRegistry(), configuration())) { + try ( + PlanStreamInput psi = new PlanStreamInput( + out.bytes().streamInput(), + getNamedWriteableRegistry(), + configuration(), + new SerializationTestUtils.TestNameIdMapper() + ) + ) { assertThat(psi.readNamedWriteable(PhysicalPlan.class), equalTo(exchangeSinkExec)); } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plugin/ClusterRequestTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plugin/ClusterRequestTests.java index be40f535dad16..e9fbba7d558ce 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plugin/ClusterRequestTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plugin/ClusterRequestTests.java @@ -17,6 +17,7 @@ import org.elasticsearch.test.AbstractWireSerializingTestCase; import org.elasticsearch.xpack.esql.ConfigurationTestUtils; import org.elasticsearch.xpack.esql.EsqlTestUtils; +import org.elasticsearch.xpack.esql.SerializationTestUtils; import org.elasticsearch.xpack.esql.analysis.Analyzer; import org.elasticsearch.xpack.esql.analysis.AnalyzerContext; import org.elasticsearch.xpack.esql.core.type.EsField; @@ -46,7 +47,7 @@ public class ClusterRequestTests extends AbstractWireSerializingTestCase instanceReader() { - return ClusterComputeRequest::new; + return (in) -> new ClusterComputeRequest(in, new SerializationTestUtils.TestNameIdMapper()); } @Override From 44f580d22cb8b63a48f92368d7c380a2e7f54a28 Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Mon, 6 Oct 2025 12:22:47 +0200 Subject: [PATCH 32/38] Fix AttributeMapTests --- .../core/expression/AttributeMapTests.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/x-pack/plugin/esql-core/src/test/java/org/elasticsearch/xpack/esql/core/expression/AttributeMapTests.java b/x-pack/plugin/esql-core/src/test/java/org/elasticsearch/xpack/esql/core/expression/AttributeMapTests.java index b22121cd8246d..35f71929db54b 100644 --- a/x-pack/plugin/esql-core/src/test/java/org/elasticsearch/xpack/esql/core/expression/AttributeMapTests.java +++ b/x-pack/plugin/esql-core/src/test/java/org/elasticsearch/xpack/esql/core/expression/AttributeMapTests.java @@ -34,11 +34,15 @@ static Attribute a(String name) { return new UnresolvedAttribute(Source.EMPTY, name); } + private static Attribute ONE = a("one"); + private static Attribute TWO = a("two"); + private static Attribute THREE = a("three"); + private static AttributeMap threeMap() { AttributeMap.Builder builder = AttributeMap.builder(); - builder.put(a("one"), "one"); - builder.put(a("two"), "two"); - builder.put(a("three"), "three"); + builder.put(ONE, "one"); + builder.put(TWO, "two"); + builder.put(THREE, "three"); return builder.build(); } @@ -46,12 +50,12 @@ private static AttributeMap threeMap() { public void testAttributeMapWithSameAliasesCanResolveAttributes() { Alias param1 = createIntParameterAlias(1, 100); Alias param2 = createIntParameterAlias(2, 100); - assertTrue(param1.equals(param2)); - assertTrue(param1.semanticEquals(param2)); + assertFalse(param1.equals(param2)); + assertFalse(param1.semanticEquals(param2)); // equality on literals assertTrue(param1.child().equals(param2.child())); assertTrue(param1.child().semanticEquals(param2.child())); - assertTrue(param1.toAttribute().equals(param2.toAttribute())); + assertFalse(param1.toAttribute().equals(param2.toAttribute())); assertFalse(param1.toAttribute().semanticEquals(param2.toAttribute())); AttributeMap.Builder mapBuilder = AttributeMap.builder(); @@ -205,18 +209,14 @@ public void testSubsetOf() { } public void testKeySet() { - Attribute one = a("one"); - Attribute two = a("two"); - Attribute three = a("three"); - Set keySet = threeMap().keySet(); - assertThat(keySet, contains(one, two, three)); + assertThat(keySet, contains(ONE, TWO, THREE)); // toObject Object[] array = keySet.toArray(); assertThat(array, arrayWithSize(3)); - assertThat(array, arrayContaining(one, two, three)); + assertThat(array, arrayContaining(ONE, TWO, THREE)); } public void testValues() { From 4443fcd0dd03b913786ddbbed1a0e6f8f6e62bb9 Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Mon, 20 Oct 2025 13:04:59 +0200 Subject: [PATCH 33/38] Simplify NamedExpression#equals and #hashCode Just give them an ignoreIds parameter and use an overrideable default for it. --- .../xpack/esql/core/expression/Alias.java | 24 +----- .../xpack/esql/core/expression/Attribute.java | 73 ++++--------------- .../esql/core/expression/EmptyAttribute.java | 4 +- .../esql/core/expression/FieldAttribute.java | 8 +- .../core/expression/MetadataAttribute.java | 8 +- .../esql/core/expression/NamedExpression.java | 59 ++++++++++----- .../esql/core/expression/TypedAttribute.java | 8 +- .../core/expression/UnresolvedAttribute.java | 19 +++-- .../esql/core/expression/UnresolvedStar.java | 12 ++- .../xpack/esql/analysis/Analyzer.java | 6 +- .../xpack/esql/common/Failure.java | 8 +- .../expression/UnresolvedNamePattern.java | 14 ++-- .../function/UnsupportedAttribute.java | 8 +- .../DataNodeRequestSerializationTests.java | 1 - 14 files changed, 111 insertions(+), 141 deletions(-) diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Alias.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Alias.java index dada0557febf2..32259c50cb440 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Alias.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Alias.java @@ -17,17 +17,17 @@ import java.io.IOException; import java.util.List; -import java.util.Objects; import static java.util.Collections.singletonList; /** * An {@code Alias} is a {@code NamedExpression} that gets renamed to something else through the Alias. - * + *

* For example, in the statement {@code 5 + 2 AS x}, {@code x} is an alias which is points to {@code ADD(5, 2)}. - * * And in {@code SELECT col AS x} "col" is a named expression that gets renamed to "x" through an alias. - * + *

+ * Note on equality: The id is respected in {@link #equals(Object)} for Alias because the {@link ReferenceAttribute} + * created by {@link #toAttribute()} uses it. */ public final class Alias extends NamedExpression { public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(NamedExpression.class, "Alias", Alias::new); @@ -152,20 +152,4 @@ public String nodeString() { public static Expression unwrap(Expression e) { return e instanceof Alias as ? as.child() : e; } - - @Override - @SuppressWarnings("checkstyle:EqualsHashCode")// equals is implemented in parent. See innerEquals instead - public int hashCode() { - return Objects.hash(super.hashCode(), id()); - } - - /** - * The id is part of equality for Alias because the {@link ReferenceAttribute} created - * by {@link #toAttribute()} uses it. - */ - @Override - protected boolean innerEquals(Object o) { - var other = (Alias) o; - return Objects.equals(id(), other.id()) && super.innerEquals(other); - } } diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java index 474de5690aa5a..9f3ed3cb44ffd 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java @@ -22,34 +22,24 @@ /** * {@link Expression}s that can be materialized and describe properties of the derived table. * In other words, an attribute represent a column in the results of a query. - * + *

* In the statement {@code SELECT ABS(foo), A, B+C FROM ...} the three named * expressions {@code ABS(foo), A, B+C} get converted to attributes and the user can * only see Attributes. - * + *

* In the statement {@code SELECT foo FROM TABLE WHERE foo > 10 + 1} only {@code foo} inside the SELECT * is a named expression (an {@code Alias} will be created automatically for it). * The rest are not as they are not part of the projection and thus are not part of the derived table. + *

+ * Note on equality: Because the name alone is not sufficient to identify an attribute + * (two different relations can have the same attribute name), we respect the {@link #id()} in equality checks and hashing. */ public abstract class Attribute extends NamedExpression { /** * A wrapper class where equality of the contained attribute ignores the {@link Attribute#id()}. Useful when we want to create new * attributes and want to avoid duplicates - we can create a set of {@link NonSemanticAttribute}s. */ - public class NonSemanticAttribute { - private Attribute attribute; - - public NonSemanticAttribute(Attribute attribute) { - if (attribute == null) { - throw new IllegalStateException("Attribute inside NonSemanticAttribute cannot be null"); - } - this.attribute = attribute; - } - - public Attribute get() { - return attribute; - } - + public record NonSemanticAttribute(Attribute inner) { @Override public boolean equals(Object o) { if (this == o) { @@ -59,21 +49,13 @@ public boolean equals(Object o) { return false; } - Attribute otherAttribute = ((NonSemanticAttribute) o).attribute; - - if (attribute == otherAttribute) { - return true; - } - if (otherAttribute == null || attribute.getClass() != otherAttribute.getClass()) { - return false; - } - - return attribute.nonSemanticEquals(otherAttribute); + Attribute otherAttribute = ((NonSemanticAttribute) o).inner(); + return inner().equals(otherAttribute, true); } @Override public int hashCode() { - return attribute.nonSemanticHashCode(); + return inner().hashCode(true); } } @@ -209,42 +191,17 @@ protected Expression canonicalize() { return clone(Source.EMPTY, qualifier(), name(), dataType(), nullability, id(), synthetic()); } - /** - * Compares all fields except the id. Useful when looking for attributes that are the same except for their origin, or when we create - * new attributes based on existing ones and want to avoid duplicates. - *

- * Does not perform the usual instance and class equality checks, those are already done in {@link NamedExpression#equals(Object)} - */ - public boolean nonSemanticEquals(Attribute other) { - return super.innerEquals(other) && Objects.equals(qualifier, other.qualifier) && Objects.equals(nullability, other.nullability); - } - - /** - * Hashcode that's consistent with {@link #nonSemanticEquals(Attribute)}. Hashes everything but the id. - */ - public int nonSemanticHashCode() { - return Objects.hash(super.hashCode(), qualifier, nullability); - } - - /** - * Inheritors should generally only override {@link #nonSemanticHashCode()}. - */ @Override - @SuppressWarnings("checkstyle:EqualsHashCode")// equals is implemented in parent. See innerEquals instead - public int hashCode() { - return Objects.hash(id(), nonSemanticHashCode()); + protected int innerHashCode(boolean ignoreIds) { + return Objects.hash(super.innerHashCode(ignoreIds), qualifier, nullability); } - /** - * Because the name alone is not sufficient to identify an attribute (two different relations can have the same attribute name), - * we also have an id that is used in equality checks and hashing. - *

- * Inheritors should generally only override {@link #nonSemanticEquals(Attribute)}. - */ @Override - protected boolean innerEquals(Object o) { + protected boolean innerEquals(Object o, boolean ignoreIds) { var other = (Attribute) o; - return semanticEquals(other) && nonSemanticEquals(other); + return super.innerEquals(other, ignoreIds) + && Objects.equals(qualifier, other.qualifier) + && Objects.equals(nullability, other.nullability); } @Override diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/EmptyAttribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/EmptyAttribute.java index 55b6eb649da2c..30c27d78cb88d 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/EmptyAttribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/EmptyAttribute.java @@ -79,12 +79,12 @@ protected NodeInfo info() { } @Override - public int nonSemanticHashCode() { + protected int innerHashCode(boolean ignoreIds) { return EmptyAttribute.class.hashCode(); } @Override - public boolean nonSemanticEquals(Attribute o) { + protected boolean innerEquals(Object o, boolean ignoreIds) { return true; } diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/FieldAttribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/FieldAttribute.java index 0e6cd60a15189..1a292056119f4 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/FieldAttribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/FieldAttribute.java @@ -231,14 +231,14 @@ public Attribute withDataType(DataType type) { } @Override - public int nonSemanticHashCode() { - return Objects.hash(super.nonSemanticHashCode(), parentName, field); + protected int innerHashCode(boolean ignoreIds) { + return Objects.hash(super.innerHashCode(ignoreIds), parentName, field); } @Override - public boolean nonSemanticEquals(Attribute o) { + protected boolean innerEquals(Object o, boolean ignoreIds) { var other = (FieldAttribute) o; - return super.nonSemanticEquals(other) && Objects.equals(parentName, other.parentName) && Objects.equals(field, other.field); + return super.innerEquals(other, ignoreIds) && Objects.equals(parentName, other.parentName) && Objects.equals(field, other.field); } @Override diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/MetadataAttribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/MetadataAttribute.java index 80e90bfd76f58..2e0438797be60 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/MetadataAttribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/MetadataAttribute.java @@ -170,13 +170,13 @@ public static boolean isScoreAttribute(Expression a) { } @Override - public int nonSemanticHashCode() { - return Objects.hash(super.nonSemanticHashCode(), searchable); + protected int innerHashCode(boolean ignoreIds) { + return Objects.hash(super.innerHashCode(ignoreIds), searchable); } @Override - public boolean nonSemanticEquals(Attribute o) { + protected boolean innerEquals(Object o, boolean ignoreIds) { var other = (MetadataAttribute) o; - return super.nonSemanticEquals(other) && searchable == other.searchable; + return super.innerEquals(other, ignoreIds) && searchable == other.searchable; } } diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/NamedExpression.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/NamedExpression.java index 22e40981ddd59..55fc934997fd9 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/NamedExpression.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/NamedExpression.java @@ -60,36 +60,61 @@ public boolean synthetic() { public abstract Attribute toAttribute(); @Override - public int hashCode() { - return Objects.hash(super.hashCode(), name, synthetic); + public final int hashCode() { + return hashCode(ignoreIdsInEqualsPerDefault()); + } + + public final int hashCode(boolean ignoreIds) { + return innerHashCode(ignoreIds); + } + + protected int innerHashCode(boolean ignoreIds) { + return ignoreIds ? Objects.hash(super.hashCode(), name, synthetic) : Objects.hash(super.hashCode(), id, name, synthetic); } - /** - * Polymorphic equality is a pain and are likely slower than a regular ones. - * This equals shortcuts `this == o` and type checks (important when we expect only a few non-equal objects). - * Here equals is final to ensure we are not duplicating those checks. - * For actual equality check override `innerEquals` instead. - */ @Override public final boolean equals(Object o) { + return equals(o, ignoreIdsInEqualsPerDefault()); + } + + /** + * Polymorphic equality is a pain and can be slow. + * This shortcuts {@code this == o} and class checks (important when we expect only a few non-equal objects). + *

+ * For the actual equality check override {@link #innerEquals(Object, boolean)} instead. + *

+ * We also provide the option to ignore NameIds in the equality check, which helps e.g. when creating named expressions + * while avoiding duplicates, or when attaching failures to unresolved attributes (see Failure.equals). + * Some classes will always ignore ids, irrespective of the parameter passed here. Such classes should also override + * {@link #ignoreIdsInEqualsPerDefault()} to return {@code true}. + */ + public final boolean equals(Object o, boolean ignoreIds) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } - return innerEquals(o); + return innerEquals(o, ignoreIds); + } + + /** + * Whether this class should ignore {@link NameId}s in its {@link #equals(Object)} method. + */ + protected boolean ignoreIdsInEqualsPerDefault() { + return false; } - protected boolean innerEquals(Object o) { + /** + * The actual equality check, after shortcutting {@code this == o} and class checks. + */ + protected boolean innerEquals(Object o, boolean ignoreIds) { var other = (NamedExpression) o; - return synthetic == other.synthetic - /* - * It is important that the line below be `name` - * and not `name()` because subclasses might override - * `name()` in ways that are not compatible with - * equality. Specifically the `Unresolved` subclasses. - */ + return (ignoreIds || Objects.equals(id, other.id)) && synthetic == other.synthetic + // It is important that the line below be `name` + // and not `name()` because subclasses might override + // `name()` in ways that are not compatible with + // equality. Specifically the `Unresolved` subclasses. && Objects.equals(name, other.name) && Objects.equals(children(), other.children()); } diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypedAttribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypedAttribute.java index 224605c3308ec..2705b8ccda2a8 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypedAttribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypedAttribute.java @@ -50,13 +50,13 @@ public DataType dataType() { } @Override - public int nonSemanticHashCode() { - return Objects.hash(super.nonSemanticHashCode(), dataType); + protected int innerHashCode(boolean ignoreIds) { + return Objects.hash(super.innerHashCode(ignoreIds), dataType); } @Override - public boolean nonSemanticEquals(Attribute o) { + protected boolean innerEquals(Object o, boolean ignoreIds) { var other = (TypedAttribute) o; - return super.nonSemanticEquals(other) && dataType == other.dataType; + return super.innerEquals(other, ignoreIds) && dataType == other.dataType; } } diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedAttribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedAttribute.java index 73d0068a53806..ff19c06cbec9d 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedAttribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedAttribute.java @@ -23,6 +23,11 @@ * An unresolved attribute. We build these while walking the syntax tree and then resolve them into other {@link Attribute} subclasses * during analysis. {@link Alias}es whose types are not yet resolved also return {@link UnresolvedAttribute}s when calling * {@link Alias#toAttribute()}. + *

+ * Note that the {@link #id()} is respected in {@link #equals(Object)}. Two unresolved attributes with the same name but different + * {@link NameId} can occur e.g. when resolving {@code EVAL x = 2*x, y = 3*x}. In the first expression, {@code x} is referring to an + * upstream attribute, while in the second expression it is referring to the alias defined in the first expression. This allows us to + * distinguish the attributes generated by the {@code EVAL} from attributes referenced by it. */ public class UnresolvedAttribute extends Attribute implements Unresolvable { private final boolean customMessage; @@ -175,20 +180,14 @@ public static String errorMessage(String name, List potentialMatches) { } @Override - public int nonSemanticHashCode() { - return Objects.hash(super.nonSemanticHashCode(), resolutionMetadata, unresolvedMsg); + protected int innerHashCode(boolean ignoreIds) { + return Objects.hash(super.innerHashCode(ignoreIds), resolutionMetadata, unresolvedMsg); } - /** - * Note that the {@link #id()} is respected here. Two unresolved attributes with the same name but different - * {@link NameId} can occur e.g. when resolving {@code EVAL x = 2*x, y = 3*x}. In the first expression, {@code x} is referring to an - * upstream attribute, while in the second expression it is referring to the alias defined in the first expression. This allows us to - * distinguish the attributes generated by the {@code EVAL} from attributes referenced by it. - */ @Override - public boolean nonSemanticEquals(Attribute o) { + protected boolean innerEquals(Object o, boolean ignoreIds) { var other = (UnresolvedAttribute) o; - return super.nonSemanticEquals(other) + return super.innerEquals(o, ignoreIds) && Objects.equals(resolutionMetadata, other.resolutionMetadata) && Objects.equals(unresolvedMsg, other.unresolvedMsg); } diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedStar.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedStar.java index eedb2231ca33c..ec85f744f84e4 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedStar.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedStar.java @@ -57,15 +57,19 @@ public UnresolvedAttribute qualifier() { } @Override - @SuppressWarnings("checkstyle:EqualsHashCode")// equals is implemented in parent. See innerEquals instead - public int hashCode() { + protected boolean ignoreIdsInEqualsPerDefault() { + return true; + } + + @Override + protected int innerHashCode(boolean ignoreIds) { return Objects.hash(qualifier); } @Override - protected boolean innerEquals(Object o) { + protected boolean innerEquals(Object o, boolean ignoreIds) { var other = (UnresolvedStar) o; - return super.innerEquals(other) && Objects.equals(qualifier, other.qualifier); + return super.innerEquals(other, true) && Objects.equals(qualifier, other.qualifier); } private String message() { diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Analyzer.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Analyzer.java index 5c500b510c9cd..c38ef185307bb 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Analyzer.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Analyzer.java @@ -1877,7 +1877,7 @@ private LogicalPlan doRule(LogicalPlan plan, List (FieldAttribute) attr.get()).toList()); + return addGeneratedFieldsToEsRelations(plan, unionFieldAttributes.stream().map(attr -> (FieldAttribute) attr.inner()).toList()); } /** @@ -1997,10 +1997,10 @@ private Expression createIfDoesNotAlreadyExist( int existingIndex = unionFieldAttributes.indexOf(nonSemanticUnionFieldAttribute); if (existingIndex >= 0) { // Do not generate multiple name/type combinations with different IDs - return unionFieldAttributes.get(existingIndex).get(); + return unionFieldAttributes.get(existingIndex).inner(); } else { unionFieldAttributes.add(nonSemanticUnionFieldAttribute); - return nonSemanticUnionFieldAttribute.get(); + return nonSemanticUnionFieldAttribute.inner(); } } diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/common/Failure.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/common/Failure.java index b805870966aff..1cc56343fa54f 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/common/Failure.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/common/Failure.java @@ -39,7 +39,7 @@ public String message() { @Override public int hashCode() { if (node instanceof UnresolvedAttribute ua) { - return ua.nonSemanticHashCode(); + return ua.hashCode(true); } return Objects.hash(node); } @@ -63,10 +63,8 @@ public boolean equals(Object obj) { // Otherwise, two failures will be emitted to the user for e.g. // `FROM test | STATS max(unknown) by unknown` because the two `unknown` attributes will have differentNameIds - even though they // clearly refer to the same problem. - if (node instanceof UnresolvedAttribute ua - && other.node instanceof UnresolvedAttribute otherUa - && ua.getClass() == otherUa.getClass()) { - return ua.nonSemanticEquals(otherUa); + if (node instanceof UnresolvedAttribute ua) { + return ua.equals(other.node, true); } return Objects.equals(node, other.node); } diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/UnresolvedNamePattern.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/UnresolvedNamePattern.java index 097d42e947417..564558956114d 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/UnresolvedNamePattern.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/UnresolvedNamePattern.java @@ -98,15 +98,19 @@ public Nullability nullable() { } @Override - @SuppressWarnings("checkstyle:EqualsHashCode")// equals is implemented in parent. See innerEquals instead - public int hashCode() { - return Objects.hash(super.hashCode(), pattern); + protected boolean ignoreIdsInEqualsPerDefault() { + return true; } @Override - protected boolean innerEquals(Object o) { + protected int innerHashCode(boolean ignoreIds) { + return Objects.hash(super.innerHashCode(true), pattern); + } + + @Override + protected boolean innerEquals(Object o, boolean ignoreIds) { var other = (UnresolvedNamePattern) o; - return super.innerEquals(other) && Objects.equals(pattern, other.pattern); + return super.innerEquals(other, true) && Objects.equals(pattern, other.pattern); } @Override diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttribute.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttribute.java index 6ae373b49a260..c003b5c7dec6d 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttribute.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttribute.java @@ -178,14 +178,14 @@ public boolean hasCustomMessage() { } @Override - public int nonSemanticHashCode() { - return Objects.hash(super.nonSemanticHashCode(), hasCustomMessage, message); + protected int innerHashCode(boolean ignoreIds) { + return Objects.hash(super.innerHashCode(ignoreIds), hasCustomMessage, message); } @Override - public boolean nonSemanticEquals(Attribute o) { + protected boolean innerEquals(Object o, boolean ignoreIds) { var other = (UnsupportedAttribute) o; - return super.nonSemanticEquals(other) && hasCustomMessage == other.hasCustomMessage && Objects.equals(message, other.message); + return super.innerEquals(other, ignoreIds) && hasCustomMessage == other.hasCustomMessage && Objects.equals(message, other.message); } /** diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plugin/DataNodeRequestSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plugin/DataNodeRequestSerializationTests.java index f20b6653c37c5..dd4a0538988c6 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plugin/DataNodeRequestSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plugin/DataNodeRequestSerializationTests.java @@ -19,7 +19,6 @@ import org.elasticsearch.search.SearchModule; import org.elasticsearch.search.internal.AliasFilter; import org.elasticsearch.test.AbstractWireSerializingTestCase; -import org.elasticsearch.xpack.esql.EsqlTestUtils; import org.elasticsearch.xpack.esql.SerializationTestUtils; import org.elasticsearch.xpack.esql.analysis.Analyzer; import org.elasticsearch.xpack.esql.core.expression.FoldContext; From 349c3fe2304d7d1ad5717cd3d2ac1fa5da71ef61 Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Mon, 20 Oct 2025 13:32:53 +0200 Subject: [PATCH 34/38] NonSemanticAttribute -> IdIgnoringWrapper --- .../xpack/esql/core/expression/Attribute.java | 17 +++++++++++------ .../xpack/esql/core/expression/NameId.java | 1 + .../xpack/esql/analysis/Analyzer.java | 8 ++++---- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java index 9f3ed3cb44ffd..7c236b4a317c6 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java @@ -32,14 +32,19 @@ * The rest are not as they are not part of the projection and thus are not part of the derived table. *

* Note on equality: Because the name alone is not sufficient to identify an attribute - * (two different relations can have the same attribute name), we respect the {@link #id()} in equality checks and hashing. + * (two different relations can have the same attribute name), attributes get a unique {@link #id()} + * assigned at creation which is respected in equality checks and hashing. */ public abstract class Attribute extends NamedExpression { /** * A wrapper class where equality of the contained attribute ignores the {@link Attribute#id()}. Useful when we want to create new - * attributes and want to avoid duplicates - we can create a set of {@link NonSemanticAttribute}s. + * attributes and want to avoid duplicates. Because we assign unique ids on creation, a normal equality check would always fail when + * we create the "same" attribute again. + *

+ * C.f. {@link AttributeMap} (and its contained wrapper class) which does the exact opposite: ignores everything but the id by + * using {@link Attribute#semanticEquals(Expression)}. */ - public record NonSemanticAttribute(Attribute inner) { + public record IdIgnoringWrapper(Attribute inner) { @Override public boolean equals(Object o) { if (this == o) { @@ -49,7 +54,7 @@ public boolean equals(Object o) { return false; } - Attribute otherAttribute = ((NonSemanticAttribute) o).inner(); + Attribute otherAttribute = ((IdIgnoringWrapper) o).inner(); return inner().equals(otherAttribute, true); } @@ -59,8 +64,8 @@ public int hashCode() { } } - public NonSemanticAttribute ignoreId() { - return new NonSemanticAttribute(this); + public IdIgnoringWrapper ignoreId() { + return new IdIgnoringWrapper(this); } /** diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/NameId.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/NameId.java index 19294a60ddd0a..f32775f94a298 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/NameId.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/NameId.java @@ -35,6 +35,7 @@ public NameId() { * Absolutely only intended for tests, esp. to deal with serialization. Never use in production as it breaks the * uniqueness guarantee. */ + @Deprecated public NameId(long id) { this.id = id; } diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Analyzer.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Analyzer.java index c38ef185307bb..beb9015097415 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Analyzer.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Analyzer.java @@ -1847,11 +1847,11 @@ record TypeResolutionKey(String fieldName, DataType fieldType) {} @Override public LogicalPlan apply(LogicalPlan plan) { - List unionFieldAttributes = new ArrayList<>(); + List unionFieldAttributes = new ArrayList<>(); return plan.transformUp(LogicalPlan.class, p -> p.childrenResolved() == false ? p : doRule(p, unionFieldAttributes)); } - private LogicalPlan doRule(LogicalPlan plan, List unionFieldAttributes) { + private LogicalPlan doRule(LogicalPlan plan, List unionFieldAttributes) { Holder alreadyAddedUnionFieldAttributes = new Holder<>(unionFieldAttributes.size()); // Collect field attributes from previous runs if (plan instanceof EsRelation rel) { @@ -1907,7 +1907,7 @@ private static LogicalPlan addGeneratedFieldsToEsRelations(LogicalPlan plan, Lis }); } - private Expression resolveConvertFunction(ConvertFunction convert, List unionFieldAttributes) { + private Expression resolveConvertFunction(ConvertFunction convert, List unionFieldAttributes) { Expression convertExpression = (Expression) convert; if (convert.field() instanceof FieldAttribute fa && fa.field() instanceof InvalidMappedField imf) { HashMap typeResolutions = new HashMap<>(); @@ -1978,7 +1978,7 @@ private Expression resolveConvertFunction(ConvertFunction convert, List unionFieldAttributes + List unionFieldAttributes ) { // Generate new ID for the field and suffix it with the data type to maintain unique attribute names. // NOTE: The name has to start with $$ to not break bwc with 8.15 - in that version, this is how we had to mark this as From b00b63993acc3a7abf8035ed6722d66b56e71925 Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Mon, 20 Oct 2025 13:55:58 +0200 Subject: [PATCH 35/38] Improve javadoc for Attribute --- .../elasticsearch/xpack/esql/core/expression/Attribute.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java index 7c236b4a317c6..0ecac43c92359 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java @@ -34,6 +34,9 @@ * Note on equality: Because the name alone is not sufficient to identify an attribute * (two different relations can have the same attribute name), attributes get a unique {@link #id()} * assigned at creation which is respected in equality checks and hashing. + *

+ * Caution! {@link #semanticEquals(Expression)} and {@link #semanticHash()} rely solely on the id. + * But this doesn't extend to expressions containing attributes as children. */ public abstract class Attribute extends NamedExpression { /** From af30e47f375df1c5a4a01ab27740988674800061 Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Mon, 20 Oct 2025 15:29:04 +0200 Subject: [PATCH 36/38] Add tests + simplify some more --- .../esql/core/expression/NamedExpression.java | 14 +-- .../esql/core/expression/UnresolvedStar.java | 7 +- .../expression/UnresolvedAttributeTests.java | 110 ------------------ .../expression/UnresolvedNamePattern.java | 5 - ...ractNamedExpressionSerializationTests.java | 33 ++++++ .../xpack/esql/expression/AliasTests.java | 7 +- .../expression/UnresolvedAttributeTests.java | 106 +++++++++++++++++ .../UnresolvedNamePatternTests.java | 45 +++++++ .../esql/expression/UnresolvedStarTests.java | 42 +++++++ .../function/FieldAttributeTests.java | 9 +- .../function/MetadataAttributeTests.java | 9 +- .../function/ReferenceAttributeTests.java | 9 +- .../function/UnresolvedFunctionTests.java | 2 +- .../function/UnsupportedAttributeTests.java | 9 +- .../esql/tree/EsqlNodeSubclassTests.java | 2 +- 15 files changed, 266 insertions(+), 143 deletions(-) delete mode 100644 x-pack/plugin/esql-core/src/test/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedAttributeTests.java create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractNamedExpressionSerializationTests.java create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/UnresolvedAttributeTests.java create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/UnresolvedNamePatternTests.java create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/UnresolvedStarTests.java diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/NamedExpression.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/NamedExpression.java index 55fc934997fd9..80c7e0c6b8035 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/NamedExpression.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/NamedExpression.java @@ -61,7 +61,7 @@ public boolean synthetic() { @Override public final int hashCode() { - return hashCode(ignoreIdsInEqualsPerDefault()); + return hashCode(false); } public final int hashCode(boolean ignoreIds) { @@ -74,7 +74,7 @@ protected int innerHashCode(boolean ignoreIds) { @Override public final boolean equals(Object o) { - return equals(o, ignoreIdsInEqualsPerDefault()); + return equals(o, false); } /** @@ -85,8 +85,7 @@ public final boolean equals(Object o) { *

* We also provide the option to ignore NameIds in the equality check, which helps e.g. when creating named expressions * while avoiding duplicates, or when attaching failures to unresolved attributes (see Failure.equals). - * Some classes will always ignore ids, irrespective of the parameter passed here. Such classes should also override - * {@link #ignoreIdsInEqualsPerDefault()} to return {@code true}. + * Some classes will always ignore ids, irrespective of the parameter passed here. */ public final boolean equals(Object o, boolean ignoreIds) { if (this == o) { @@ -98,13 +97,6 @@ public final boolean equals(Object o, boolean ignoreIds) { return innerEquals(o, ignoreIds); } - /** - * Whether this class should ignore {@link NameId}s in its {@link #equals(Object)} method. - */ - protected boolean ignoreIdsInEqualsPerDefault() { - return false; - } - /** * The actual equality check, after shortcutting {@code this == o} and class checks. */ diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedStar.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedStar.java index ec85f744f84e4..273f68fc32e85 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedStar.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedStar.java @@ -19,7 +19,7 @@ public class UnresolvedStar extends UnresolvedNamedExpression { - // TODO: Currently unused, but likely will be again when we support qualified star resolution + // TODO: Currently unused, can be removed. (Qualifiers will likely remain just strings.) private final UnresolvedAttribute qualifier; public UnresolvedStar(Source source, UnresolvedAttribute qualifier) { @@ -56,11 +56,6 @@ public UnresolvedAttribute qualifier() { return qualifier; } - @Override - protected boolean ignoreIdsInEqualsPerDefault() { - return true; - } - @Override protected int innerHashCode(boolean ignoreIds) { return Objects.hash(qualifier); diff --git a/x-pack/plugin/esql-core/src/test/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedAttributeTests.java b/x-pack/plugin/esql-core/src/test/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedAttributeTests.java deleted file mode 100644 index 6ac8377a2d8b9..0000000000000 --- a/x-pack/plugin/esql-core/src/test/java/org/elasticsearch/xpack/esql/core/expression/UnresolvedAttributeTests.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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.core.expression; - -import org.elasticsearch.xpack.esql.core.tree.AbstractNodeTestCase; -import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.core.tree.SourceTests; - -import java.util.Arrays; -import java.util.Objects; -import java.util.function.Supplier; - -public class UnresolvedAttributeTests extends AbstractNodeTestCase { - public static UnresolvedAttribute randomUnresolvedAttribute() { - Source source = SourceTests.randomSource(); - String name = randomAlphaOfLength(5); - NameId id = randomBoolean() ? null : new NameId(); - String unresolvedMessage = randomUnresolvedMessage(); - Object resolutionMetadata = new Object(); - return new UnresolvedAttribute(source, name, id, unresolvedMessage, resolutionMetadata); - } - - /** - * A random qualifier. It is important that this be distinct - * from the name and the unresolvedMessage for testing transform. - */ - private static String randomQualifier() { - return randomBoolean() ? null : randomAlphaOfLength(6); - } - - /** - * A random qualifier. It is important that this be distinct - * from the name and the qualifier for testing transform. - */ - private static String randomUnresolvedMessage() { - return randomAlphaOfLength(7); - } - - @Override - protected UnresolvedAttribute randomInstance() { - return randomUnresolvedAttribute(); - } - - @Override - protected UnresolvedAttribute mutate(UnresolvedAttribute a) { - Supplier option = randomFrom( - Arrays.asList( - () -> new UnresolvedAttribute( - a.source(), - randomValueOtherThan(a.name(), () -> randomAlphaOfLength(5)), - a.id(), - a.unresolvedMessage(), - a.resolutionMetadata() - ), - () -> new UnresolvedAttribute( - a.source(), - a.name(), - a.id(), - randomValueOtherThan(a.unresolvedMessage(), () -> randomUnresolvedMessage()), - a.resolutionMetadata() - ), - () -> new UnresolvedAttribute(a.source(), a.name(), a.id(), a.unresolvedMessage(), new Object()) - ) - ); - return option.get(); - } - - @Override - protected UnresolvedAttribute copy(UnresolvedAttribute a) { - return new UnresolvedAttribute(a.source(), a.name(), a.id(), a.unresolvedMessage(), a.resolutionMetadata()); - } - - @Override - public void testTransform() { - UnresolvedAttribute a = randomUnresolvedAttribute(); - - String newName = randomValueOtherThan(a.name(), () -> randomAlphaOfLength(5)); - assertEquals( - new UnresolvedAttribute(a.source(), newName, a.id(), a.unresolvedMessage(), a.resolutionMetadata()), - a.transformPropertiesOnly(Object.class, v -> Objects.equals(v, a.name()) ? newName : v) - ); - - NameId newId = new NameId(); - assertEquals( - new UnresolvedAttribute(a.source(), a.name(), newId, a.unresolvedMessage(), a.resolutionMetadata()), - a.transformPropertiesOnly(Object.class, v -> Objects.equals(v, a.id()) ? newId : v) - ); - - String newMessage = randomValueOtherThan(a.unresolvedMessage(), UnresolvedAttributeTests::randomUnresolvedMessage); - assertEquals( - new UnresolvedAttribute(a.source(), a.name(), a.id(), newMessage, a.resolutionMetadata()), - a.transformPropertiesOnly(Object.class, v -> Objects.equals(v, a.unresolvedMessage()) ? newMessage : v) - ); - - Object newMeta = new Object(); - assertEquals( - new UnresolvedAttribute(a.source(), a.name(), a.id(), a.unresolvedMessage(), newMeta), - a.transformPropertiesOnly(Object.class, v -> Objects.equals(v, a.resolutionMetadata()) ? newMeta : v) - ); - } - - @Override - public void testReplaceChildren() { - // UnresolvedAttribute doesn't have any children - } -} diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/UnresolvedNamePattern.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/UnresolvedNamePattern.java index 564558956114d..986e715cce681 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/UnresolvedNamePattern.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/UnresolvedNamePattern.java @@ -97,11 +97,6 @@ public Nullability nullable() { throw new UnresolvedException("nullable", this); } - @Override - protected boolean ignoreIdsInEqualsPerDefault() { - return true; - } - @Override protected int innerHashCode(boolean ignoreIds) { return Objects.hash(super.innerHashCode(true), pattern); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractNamedExpressionSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractNamedExpressionSerializationTests.java new file mode 100644 index 0000000000000..ec829c5c25a31 --- /dev/null +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractNamedExpressionSerializationTests.java @@ -0,0 +1,33 @@ +/* + * 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; + +import org.elasticsearch.xpack.esql.core.expression.NamedExpression; + +public abstract class AbstractNamedExpressionSerializationTests extends AbstractExpressionSerializationTests { + public void testEqualsAndHashCodeIgnoringId() throws Exception { + T instance = createTestInstance(); + T withNewId = mutateNameId(instance); + + assertTrue(instance.equals(withNewId, true)); + assertEquals(instance.hashCode(true), withNewId.hashCode(true)); + + assertEquals(instance.equals(withNewId), instance.equals(withNewId, false)); + } + + public void testEqualsAndHashCodeWithId() throws Exception { + T instance = createTestInstance(); + T withNewId = mutateNameId(instance); + + if (instance.equals(withNewId)) { + assertEquals(instance.hashCode(), withNewId.hashCode()); + } + } + + protected abstract T mutateNameId(T instance); +} diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AliasTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AliasTests.java index 83b215aa8332b..08e145af803eb 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AliasTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AliasTests.java @@ -16,7 +16,7 @@ import java.io.IOException; -public class AliasTests extends AbstractExpressionSerializationTests { +public class AliasTests extends AbstractNamedExpressionSerializationTests { public static Alias randomAlias() { Source source = SourceTests.randomSource(); String name = randomAlphaOfLength(5); @@ -49,4 +49,9 @@ protected Alias mutateInstance(Alias instance) throws IOException { protected boolean alwaysEmptySource() { return true; } + + @Override + protected Alias mutateNameId(Alias instance) { + return instance.withId(new NameId()); + } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/UnresolvedAttributeTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/UnresolvedAttributeTests.java new file mode 100644 index 0000000000000..1f03b0b9a4c54 --- /dev/null +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/UnresolvedAttributeTests.java @@ -0,0 +1,106 @@ +/* + * 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; + +import org.elasticsearch.TransportVersion; +import org.elasticsearch.xpack.esql.core.expression.NameId; +import org.elasticsearch.xpack.esql.core.expression.UnresolvedAttribute; +import org.elasticsearch.xpack.esql.core.tree.Source; +import org.elasticsearch.xpack.esql.core.tree.SourceTests; + +import java.io.IOException; +import java.util.Objects; + +public class UnresolvedAttributeTests extends AbstractNamedExpressionSerializationTests { + public static UnresolvedAttribute randomUnresolvedAttribute() { + Source source = SourceTests.randomSource(); + String qualifier = randomBoolean() ? null : randomAlphaOfLength(5); + String name = randomAlphaOfLength(5); + NameId id = randomBoolean() ? null : new NameId(); + String unresolvedMessage = randomUnresolvedMessage(); + Object resolutionMetadata = new Object(); + return new UnresolvedAttribute(source, qualifier, name, id, unresolvedMessage, resolutionMetadata); + } + + /** + * A random qualifier. It is important that this be distinct + * from the name and the qualifier for testing transform. + */ + private static String randomUnresolvedMessage() { + return randomAlphaOfLength(7); + } + + @Override + protected UnresolvedAttribute createTestInstance() { + return randomUnresolvedAttribute(); + } + + @Override + protected UnresolvedAttribute mutateInstance(UnresolvedAttribute instance) { + Source source = instance.source(); + String name = instance.name(); + String qualifier = instance.qualifier(); + NameId id = instance.id(); + String unresolvedMessage = instance.unresolvedMessage(); + Object resolutionMetadata = instance.resolutionMetadata(); + + switch (between(0, 4)) { + case 0 -> name = randomValueOtherThan(name, () -> randomBoolean() ? null : randomAlphaOfLength(5)); + case 1 -> qualifier = randomAlphaOfLength(qualifier == null ? 3 : qualifier.length() + 1); + case 2 -> id = new NameId(); + case 3 -> unresolvedMessage = randomValueOtherThan(unresolvedMessage, UnresolvedAttributeTests::randomUnresolvedMessage); + case 4 -> resolutionMetadata = new Object(); + } + return new UnresolvedAttribute(source, qualifier, name, id, unresolvedMessage, resolutionMetadata); + } + + @Override + protected UnresolvedAttribute copyInstance(UnresolvedAttribute instance, TransportVersion version) throws IOException { + // Doesn't escape the node + return new UnresolvedAttribute( + instance.source(), + instance.qualifier(), + instance.name(), + instance.id(), + instance.unresolvedMessage(), + instance.resolutionMetadata() + ); + } + + @Override + protected UnresolvedAttribute mutateNameId(UnresolvedAttribute instance) { + return instance.withId(new NameId()); + } + + public void testTransform() { + UnresolvedAttribute a = randomUnresolvedAttribute(); + + String newName = randomValueOtherThan(a.name(), () -> randomAlphaOfLength(5)); + assertEquals( + new UnresolvedAttribute(a.source(), a.qualifier(), newName, a.id(), a.unresolvedMessage(), a.resolutionMetadata()), + a.transformPropertiesOnly(Object.class, v -> Objects.equals(v, a.name()) ? newName : v) + ); + + NameId newId = new NameId(); + assertEquals( + new UnresolvedAttribute(a.source(), a.qualifier(), a.name(), newId, a.unresolvedMessage(), a.resolutionMetadata()), + a.transformPropertiesOnly(Object.class, v -> Objects.equals(v, a.id()) ? newId : v) + ); + + String newMessage = randomValueOtherThan(a.unresolvedMessage(), UnresolvedAttributeTests::randomUnresolvedMessage); + assertEquals( + new UnresolvedAttribute(a.source(), a.qualifier(), a.name(), a.id(), newMessage, a.resolutionMetadata()), + a.transformPropertiesOnly(Object.class, v -> Objects.equals(v, a.unresolvedMessage()) ? newMessage : v) + ); + + Object newMeta = new Object(); + assertEquals( + new UnresolvedAttribute(a.source(), a.qualifier(), a.name(), a.id(), a.unresolvedMessage(), newMeta), + a.transformPropertiesOnly(Object.class, v -> Objects.equals(v, a.resolutionMetadata()) ? newMeta : v) + ); + } +} diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/UnresolvedNamePatternTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/UnresolvedNamePatternTests.java new file mode 100644 index 0000000000000..5591ac9c001c3 --- /dev/null +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/UnresolvedNamePatternTests.java @@ -0,0 +1,45 @@ +/* + * 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; + +import org.elasticsearch.TransportVersion; +import org.elasticsearch.xpack.esql.core.tree.Source; + +import java.io.IOException; + +public class UnresolvedNamePatternTests extends AbstractNamedExpressionSerializationTests { + @Override + protected UnresolvedNamePattern createTestInstance() { + // No automaton, this is normally injected during parsing and is derived from the pattern. + return new UnresolvedNamePattern(Source.EMPTY, null, randomAlphaOfLength(3), randomAlphaOfLength(3)); + } + + @Override + protected UnresolvedNamePattern mutateInstance(UnresolvedNamePattern instance) { + Source source = instance.source(); + String name = instance.name(); + String pattern = instance.pattern(); + switch (between(0, 1)) { + case 0 -> name = randomValueOtherThan(name, () -> randomAlphaOfLength(4)); + case 1 -> pattern = randomValueOtherThan(pattern, () -> randomAlphaOfLength(4)); + } + return new UnresolvedNamePattern(source, null, name, pattern); + } + + @Override + protected UnresolvedNamePattern mutateNameId(UnresolvedNamePattern instance) { + // Creating a new instance is enough as the NameId is generated automatically. + return new UnresolvedNamePattern(instance.source(), null, instance.pattern(), instance.name()); + } + + @Override + protected UnresolvedNamePattern copyInstance(UnresolvedNamePattern instance, TransportVersion version) throws IOException { + // Doesn't escape the node + return new UnresolvedNamePattern(instance.source(), null, instance.pattern(), instance.name()); + } +} diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/UnresolvedStarTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/UnresolvedStarTests.java new file mode 100644 index 0000000000000..be6b5518f9d64 --- /dev/null +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/UnresolvedStarTests.java @@ -0,0 +1,42 @@ +/* + * 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; + +import org.elasticsearch.TransportVersion; +import org.elasticsearch.xpack.esql.core.expression.UnresolvedAttribute; +import org.elasticsearch.xpack.esql.core.expression.UnresolvedStar; +import org.elasticsearch.xpack.esql.core.tree.Source; + +import java.io.IOException; + +public class UnresolvedStarTests extends AbstractNamedExpressionSerializationTests { + @Override + protected UnresolvedStar createTestInstance() { + return new UnresolvedStar(Source.EMPTY, randomBoolean() ? null : new UnresolvedAttribute(Source.EMPTY, randomAlphaOfLength(3))); + } + + @Override + protected UnresolvedStar mutateInstance(UnresolvedStar instance) { + Source source = instance.source(); + String qualifier = instance.qualifier() == null ? "" : instance.qualifier().name(); + qualifier = randomValueOtherThan(qualifier, randomAlphaOfLength(4)::toString); + return new UnresolvedStar(source, new UnresolvedAttribute(Source.EMPTY, qualifier)); + } + + @Override + protected UnresolvedStar mutateNameId(UnresolvedStar instance) { + // Creating a new instance is enough as the NameId is generated automatically. + return new UnresolvedStar(instance.source(), instance.qualifier()); + } + + @Override + protected UnresolvedStar copyInstance(UnresolvedStar instance, TransportVersion version) throws IOException { + // Doesn't escape the node + return new UnresolvedStar(instance.source(), instance.qualifier()); + } +} diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/FieldAttributeTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/FieldAttributeTests.java index fff14da7e74a1..5137937e3f101 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/FieldAttributeTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/FieldAttributeTests.java @@ -13,10 +13,10 @@ import org.elasticsearch.xpack.esql.core.tree.Source; import org.elasticsearch.xpack.esql.core.type.DataType; import org.elasticsearch.xpack.esql.core.type.EsField; -import org.elasticsearch.xpack.esql.expression.AbstractExpressionSerializationTests; +import org.elasticsearch.xpack.esql.expression.AbstractNamedExpressionSerializationTests; import org.elasticsearch.xpack.esql.type.AbstractEsFieldTypeTests; -public class FieldAttributeTests extends AbstractExpressionSerializationTests { +public class FieldAttributeTests extends AbstractNamedExpressionSerializationTests { public static FieldAttribute createFieldAttribute(int maxDepth, boolean onlyRepresentable) { Source source = Source.EMPTY; String parentName = maxDepth == 0 || randomBoolean() ? null : randomAlphaOfLength(3); @@ -61,4 +61,9 @@ protected FieldAttribute mutateInstance(FieldAttribute instance) { } return new FieldAttribute(source, parentName, qualifier, name, field, nullability, id, synthetic); } + + @Override + protected FieldAttribute mutateNameId(FieldAttribute instance) { + return (FieldAttribute) instance.withId(new NameId()); + } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/MetadataAttributeTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/MetadataAttributeTests.java index b002c1af78ed1..0d09ee1fc76ff 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/MetadataAttributeTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/MetadataAttributeTests.java @@ -12,9 +12,9 @@ import org.elasticsearch.xpack.esql.core.expression.Nullability; import org.elasticsearch.xpack.esql.core.tree.Source; import org.elasticsearch.xpack.esql.core.type.DataType; -import org.elasticsearch.xpack.esql.expression.AbstractExpressionSerializationTests; +import org.elasticsearch.xpack.esql.expression.AbstractNamedExpressionSerializationTests; -public class MetadataAttributeTests extends AbstractExpressionSerializationTests { +public class MetadataAttributeTests extends AbstractNamedExpressionSerializationTests { @Override protected MetadataAttribute createTestInstance() { return randomMetadataAttribute(); @@ -49,4 +49,9 @@ protected MetadataAttribute mutateInstance(MetadataAttribute instance) { } return new MetadataAttribute(source, name, type, nullability, id, synthetic, searchable); } + + @Override + protected MetadataAttribute mutateNameId(MetadataAttribute instance) { + return (MetadataAttribute) instance.withId(new NameId()); + } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/ReferenceAttributeTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/ReferenceAttributeTests.java index 9220ac1993485..5206146758a96 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/ReferenceAttributeTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/ReferenceAttributeTests.java @@ -12,9 +12,9 @@ import org.elasticsearch.xpack.esql.core.expression.ReferenceAttribute; import org.elasticsearch.xpack.esql.core.tree.Source; import org.elasticsearch.xpack.esql.core.type.DataType; -import org.elasticsearch.xpack.esql.expression.AbstractExpressionSerializationTests; +import org.elasticsearch.xpack.esql.expression.AbstractNamedExpressionSerializationTests; -public class ReferenceAttributeTests extends AbstractExpressionSerializationTests { +public class ReferenceAttributeTests extends AbstractNamedExpressionSerializationTests { public static ReferenceAttribute randomReferenceAttribute(boolean onlyRepresentable) { Source source = Source.EMPTY; String qualifier = randomBoolean() ? null : randomAlphaOfLength(3); @@ -51,4 +51,9 @@ protected ReferenceAttribute mutateInstance(ReferenceAttribute instance) { } return new ReferenceAttribute(source, qualifier, name, type, nullability, id, synthetic); } + + @Override + protected ReferenceAttribute mutateNameId(ReferenceAttribute instance) { + return (ReferenceAttribute) instance.withId(new NameId()); + } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/UnresolvedFunctionTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/UnresolvedFunctionTests.java index 7cb547876e532..efd22d9ed6eb3 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/UnresolvedFunctionTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/UnresolvedFunctionTests.java @@ -17,8 +17,8 @@ import static java.util.Arrays.asList; import static java.util.Collections.singletonList; -import static org.elasticsearch.xpack.esql.core.expression.UnresolvedAttributeTests.randomUnresolvedAttribute; import static org.elasticsearch.xpack.esql.core.tree.SourceTests.randomSource; +import static org.elasticsearch.xpack.esql.expression.UnresolvedAttributeTests.randomUnresolvedAttribute; public class UnresolvedFunctionTests extends AbstractNodeTestCase { diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttributeTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttributeTests.java index acb5108116eb5..722e752035050 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttributeTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttributeTests.java @@ -10,10 +10,10 @@ import org.elasticsearch.xpack.esql.core.expression.NameId; import org.elasticsearch.xpack.esql.core.tree.Source; import org.elasticsearch.xpack.esql.core.type.UnsupportedEsField; -import org.elasticsearch.xpack.esql.expression.AbstractExpressionSerializationTests; +import org.elasticsearch.xpack.esql.expression.AbstractNamedExpressionSerializationTests; import org.elasticsearch.xpack.esql.type.UnsupportedEsFieldTests; -public class UnsupportedAttributeTests extends AbstractExpressionSerializationTests { +public class UnsupportedAttributeTests extends AbstractNamedExpressionSerializationTests { @Override protected UnsupportedAttribute createTestInstance() { return randomUnsupportedAttribute(); @@ -45,4 +45,9 @@ protected UnsupportedAttribute mutateInstance(UnsupportedAttribute instance) { } return new UnsupportedAttribute(source, qualifier, name, field, customMessage, id); } + + @Override + protected UnsupportedAttribute mutateNameId(UnsupportedAttribute instance) { + return (UnsupportedAttribute) instance.withId(new NameId()); + } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/tree/EsqlNodeSubclassTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/tree/EsqlNodeSubclassTests.java index 2f848d07f657f..d3ce61ef372bd 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/tree/EsqlNodeSubclassTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/tree/EsqlNodeSubclassTests.java @@ -26,7 +26,6 @@ import org.elasticsearch.xpack.esql.core.expression.FieldAttribute; import org.elasticsearch.xpack.esql.core.expression.Literal; import org.elasticsearch.xpack.esql.core.expression.UnresolvedAttribute; -import org.elasticsearch.xpack.esql.core.expression.UnresolvedAttributeTests; import org.elasticsearch.xpack.esql.core.expression.UnresolvedNamedExpression; import org.elasticsearch.xpack.esql.core.expression.function.Function; import org.elasticsearch.xpack.esql.core.tree.AbstractNodeTestCase; @@ -39,6 +38,7 @@ import org.elasticsearch.xpack.esql.core.type.DataType; import org.elasticsearch.xpack.esql.core.type.EsField; import org.elasticsearch.xpack.esql.expression.Order; +import org.elasticsearch.xpack.esql.expression.UnresolvedAttributeTests; import org.elasticsearch.xpack.esql.expression.function.UnresolvedFunction; import org.elasticsearch.xpack.esql.expression.function.scalar.ip.CIDRMatch; import org.elasticsearch.xpack.esql.expression.function.scalar.math.Pow; From 6253ef095cade299e2203447b7b6ac9a6b39879c Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Mon, 20 Oct 2025 15:30:57 +0200 Subject: [PATCH 37/38] Update docs/changelog/132455.yaml --- docs/changelog/132455.yaml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 docs/changelog/132455.yaml diff --git a/docs/changelog/132455.yaml b/docs/changelog/132455.yaml new file mode 100644 index 0000000000000..e6860499ce858 --- /dev/null +++ b/docs/changelog/132455.yaml @@ -0,0 +1,7 @@ +pr: 132455 +summary: "Make equals include ids for Alias, `TypedAttribute`" +area: ES|QL +type: bug +issues: + - 131509 + - 132634 From f3acb8f12b451f7a15413a1db2cba9ef9faff0f3 Mon Sep 17 00:00:00 2001 From: Alexander Spies Date: Mon, 20 Oct 2025 15:42:59 +0200 Subject: [PATCH 38/38] Expand test of equality for id mutation --- .../AbstractNamedExpressionSerializationTests.java | 7 ++++++- .../elasticsearch/xpack/esql/expression/AliasTests.java | 5 +++++ .../xpack/esql/expression/UnresolvedAttributeTests.java | 5 +++++ .../xpack/esql/expression/UnresolvedNamePatternTests.java | 5 +++++ .../xpack/esql/expression/UnresolvedStarTests.java | 5 +++++ .../esql/expression/function/FieldAttributeTests.java | 5 +++++ .../esql/expression/function/MetadataAttributeTests.java | 5 +++++ .../esql/expression/function/ReferenceAttributeTests.java | 5 +++++ .../expression/function/UnsupportedAttributeTests.java | 5 +++++ 9 files changed, 46 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractNamedExpressionSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractNamedExpressionSerializationTests.java index ec829c5c25a31..8e74046895790 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractNamedExpressionSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AbstractNamedExpressionSerializationTests.java @@ -24,10 +24,15 @@ public void testEqualsAndHashCodeWithId() throws Exception { T instance = createTestInstance(); T withNewId = mutateNameId(instance); - if (instance.equals(withNewId)) { + if (equalityIgnoresId()) { + assertEquals(instance, withNewId); assertEquals(instance.hashCode(), withNewId.hashCode()); + } else { + assertNotEquals(instance, withNewId); } } protected abstract T mutateNameId(T instance); + + protected abstract boolean equalityIgnoresId(); } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AliasTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AliasTests.java index 08e145af803eb..485a8e394d4cb 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AliasTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/AliasTests.java @@ -54,4 +54,9 @@ protected boolean alwaysEmptySource() { protected Alias mutateNameId(Alias instance) { return instance.withId(new NameId()); } + + @Override + protected boolean equalityIgnoresId() { + return false; + } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/UnresolvedAttributeTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/UnresolvedAttributeTests.java index 1f03b0b9a4c54..a899f067966d2 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/UnresolvedAttributeTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/UnresolvedAttributeTests.java @@ -76,6 +76,11 @@ protected UnresolvedAttribute mutateNameId(UnresolvedAttribute instance) { return instance.withId(new NameId()); } + @Override + protected boolean equalityIgnoresId() { + return false; + } + public void testTransform() { UnresolvedAttribute a = randomUnresolvedAttribute(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/UnresolvedNamePatternTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/UnresolvedNamePatternTests.java index 5591ac9c001c3..b47baad5bf72c 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/UnresolvedNamePatternTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/UnresolvedNamePatternTests.java @@ -37,6 +37,11 @@ protected UnresolvedNamePattern mutateNameId(UnresolvedNamePattern instance) { return new UnresolvedNamePattern(instance.source(), null, instance.pattern(), instance.name()); } + @Override + protected boolean equalityIgnoresId() { + return true; + } + @Override protected UnresolvedNamePattern copyInstance(UnresolvedNamePattern instance, TransportVersion version) throws IOException { // Doesn't escape the node diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/UnresolvedStarTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/UnresolvedStarTests.java index be6b5518f9d64..203dcc6e0be85 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/UnresolvedStarTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/UnresolvedStarTests.java @@ -34,6 +34,11 @@ protected UnresolvedStar mutateNameId(UnresolvedStar instance) { return new UnresolvedStar(instance.source(), instance.qualifier()); } + @Override + protected boolean equalityIgnoresId() { + return true; + } + @Override protected UnresolvedStar copyInstance(UnresolvedStar instance, TransportVersion version) throws IOException { // Doesn't escape the node diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/FieldAttributeTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/FieldAttributeTests.java index 5137937e3f101..56d9667f204df 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/FieldAttributeTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/FieldAttributeTests.java @@ -66,4 +66,9 @@ protected FieldAttribute mutateInstance(FieldAttribute instance) { protected FieldAttribute mutateNameId(FieldAttribute instance) { return (FieldAttribute) instance.withId(new NameId()); } + + @Override + protected boolean equalityIgnoresId() { + return false; + } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/MetadataAttributeTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/MetadataAttributeTests.java index 0d09ee1fc76ff..b983856eb50af 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/MetadataAttributeTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/MetadataAttributeTests.java @@ -54,4 +54,9 @@ protected MetadataAttribute mutateInstance(MetadataAttribute instance) { protected MetadataAttribute mutateNameId(MetadataAttribute instance) { return (MetadataAttribute) instance.withId(new NameId()); } + + @Override + protected boolean equalityIgnoresId() { + return false; + } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/ReferenceAttributeTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/ReferenceAttributeTests.java index 5206146758a96..04d0ca5427117 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/ReferenceAttributeTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/ReferenceAttributeTests.java @@ -56,4 +56,9 @@ protected ReferenceAttribute mutateInstance(ReferenceAttribute instance) { protected ReferenceAttribute mutateNameId(ReferenceAttribute instance) { return (ReferenceAttribute) instance.withId(new NameId()); } + + @Override + protected boolean equalityIgnoresId() { + return false; + } } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttributeTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttributeTests.java index 722e752035050..370f794edcc3c 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttributeTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttributeTests.java @@ -50,4 +50,9 @@ protected UnsupportedAttribute mutateInstance(UnsupportedAttribute instance) { protected UnsupportedAttribute mutateNameId(UnsupportedAttribute instance) { return (UnsupportedAttribute) instance.withId(new NameId()); } + + @Override + protected boolean equalityIgnoresId() { + return false; + } }