Skip to content

Commit 48cf5de

Browse files
committed
Renamed isPresentable to be more specific with counter types
1 parent b9ff56f commit 48cf5de

File tree

10 files changed

+21
-21
lines changed

10 files changed

+21
-21
lines changed

x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypeResolutions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ public static TypeResolution isDate(Expression e, String operationName, ParamOrd
7575
/**
7676
* @see DataType#isRepresentable(DataType)
7777
*/
78-
public static TypeResolution isRepresentable(Expression e, String operationName, ParamOrdinal paramOrd) {
78+
public static TypeResolution isRepresentableExceptCounters(Expression e, String operationName, ParamOrdinal paramOrd) {
7979
return isType(e, DataType::isRepresentable, operationName, paramOrd, "any type except counter types");
8080
}
8181

82-
public static TypeResolution isRepresentableNotSpatial(Expression e, String operationName, ParamOrdinal paramOrd) {
82+
public static TypeResolution isRepresentableExceptCountersAndSpatial(Expression e, String operationName, ParamOrdinal paramOrd) {
8383
return isType(e, (t) -> isSpatial(t) == false && DataType.isRepresentable(t), operationName, paramOrd, "any type except counter and spatial types");
8484
}
8585

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAppend.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.FIRST;
4141
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.SECOND;
42-
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isRepresentable;
42+
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isRepresentableExceptCounters;
4343
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isType;
4444

4545
/**
@@ -138,14 +138,14 @@ protected TypeResolution resolveType() {
138138
return new TypeResolution("Unresolved children");
139139
}
140140

141-
TypeResolution resolution = isRepresentable(field1, sourceText(), FIRST);
141+
TypeResolution resolution = isRepresentableExceptCounters(field1, sourceText(), FIRST);
142142
if (resolution.unresolved()) {
143143
return resolution;
144144
}
145145
dataType = field1.dataType().noText();
146146
if (dataType == DataType.NULL) {
147147
dataType = field2.dataType().noText();
148-
return isRepresentable(field2, sourceText(), SECOND);
148+
return isRepresentableExceptCounters(field2, sourceText(), SECOND);
149149
}
150150
return isType(field2, t -> t.noText() == dataType, sourceText(), SECOND, dataType.typeName());
151151
}

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvCount.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import java.util.List;
2626

2727
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.DEFAULT;
28-
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isRepresentable;
28+
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isRepresentableExceptCounters;
2929

3030
/**
3131
* Reduce a multivalued field to a single valued field containing the count of values.
@@ -75,7 +75,7 @@ public String getWriteableName() {
7575

7676
@Override
7777
protected TypeResolution resolveFieldType() {
78-
return isRepresentable(field(), sourceText(), DEFAULT);
78+
return isRepresentableExceptCounters(field(), sourceText(), DEFAULT);
7979
}
8080

8181
@Override

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvDedupe.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import java.util.List;
2424

2525
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.DEFAULT;
26-
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isRepresentable;
26+
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isRepresentableExceptCounters;
2727

2828
/**
2929
* Removes duplicate values from a multivalued field.
@@ -89,7 +89,7 @@ public String getWriteableName() {
8989

9090
@Override
9191
protected TypeResolution resolveFieldType() {
92-
return isRepresentable(field(), sourceText(), DEFAULT);
92+
return isRepresentableExceptCounters(field(), sourceText(), DEFAULT);
9393
}
9494

9595
@Override

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvFirst.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import java.util.List;
3232

3333
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.DEFAULT;
34-
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isRepresentable;
34+
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isRepresentableExceptCounters;
3535

3636
/**
3737
* Reduce a multivalued field to a single valued field containing the minimum value.
@@ -104,7 +104,7 @@ public String getWriteableName() {
104104

105105
@Override
106106
protected TypeResolution resolveFieldType() {
107-
return isRepresentable(field(), sourceText(), DEFAULT);
107+
return isRepresentableExceptCounters(field(), sourceText(), DEFAULT);
108108
}
109109

110110
@Override

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvLast.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import java.util.List;
3232

3333
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.DEFAULT;
34-
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isRepresentable;
34+
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isRepresentableExceptCounters;
3535

3636
/**
3737
* Reduce a multivalued field to a single valued field containing the minimum value.
@@ -104,7 +104,7 @@ public String getWriteableName() {
104104

105105
@Override
106106
protected TypeResolution resolveFieldType() {
107-
return isRepresentable(field(), sourceText(), DEFAULT);
107+
return isRepresentableExceptCounters(field(), sourceText(), DEFAULT);
108108
}
109109

110110
@Override

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMax.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import java.util.List;
2727

2828
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.DEFAULT;
29-
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isRepresentableNotSpatial;
29+
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isRepresentableExceptCountersAndSpatial;
3030

3131
/**
3232
* Reduce a multivalued field to a single valued field containing the maximum value.
@@ -68,7 +68,7 @@ public String getWriteableName() {
6868

6969
@Override
7070
protected TypeResolution resolveFieldType() {
71-
return isRepresentableNotSpatial(field(), sourceText(), DEFAULT);
71+
return isRepresentableExceptCountersAndSpatial(field(), sourceText(), DEFAULT);
7272
}
7373

7474
@Override

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvMin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import java.util.List;
2727

2828
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.DEFAULT;
29-
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isRepresentableNotSpatial;
29+
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isRepresentableExceptCountersAndSpatial;
3030

3131
/**
3232
* Reduce a multivalued field to a single valued field containing the minimum value.
@@ -68,7 +68,7 @@ public String getWriteableName() {
6868

6969
@Override
7070
protected TypeResolution resolveFieldType() {
71-
return isRepresentableNotSpatial(field(), sourceText(), DEFAULT);
71+
return isRepresentableExceptCountersAndSpatial(field(), sourceText(), DEFAULT);
7272
}
7373

7474
@Override

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSlice.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.FIRST;
4242
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.SECOND;
4343
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.THIRD;
44-
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isRepresentable;
44+
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isRepresentableExceptCounters;
4545
import static org.elasticsearch.xpack.esql.core.type.DataType.INTEGER;
4646
import static org.elasticsearch.xpack.esql.type.EsqlDataTypeConverter.stringToInt;
4747

@@ -161,7 +161,7 @@ protected TypeResolution resolveType() {
161161
return new TypeResolution("Unresolved children");
162162
}
163163

164-
TypeResolution resolution = isRepresentable(field, sourceText(), FIRST);
164+
TypeResolution resolution = isRepresentableExceptCounters(field, sourceText(), FIRST);
165165
if (resolution.unresolved()) {
166166
return resolution;
167167
}

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSort.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.FIRST;
5555
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.SECOND;
56-
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isRepresentable;
56+
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isRepresentableExceptCounters;
5757
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isString;
5858
import static org.elasticsearch.xpack.esql.expression.Validations.isFoldable;
5959

@@ -128,7 +128,7 @@ protected TypeResolution resolveType() {
128128
return new TypeResolution("Unresolved children");
129129
}
130130

131-
TypeResolution resolution = isRepresentable(field, sourceText(), FIRST);
131+
TypeResolution resolution = isRepresentableExceptCounters(field, sourceText(), FIRST);
132132

133133
if (resolution.unresolved()) {
134134
return resolution;

0 commit comments

Comments
 (0)