Skip to content

Commit 6448db9

Browse files
committed
Do not allow null values for first argument in type resolution
1 parent c3b257c commit 6448db9

File tree

2 files changed

+6
-4
lines changed
  • x-pack/plugin/esql/src
    • main/java/org/elasticsearch/xpack/esql/expression/function/fulltext
    • test/java/org/elasticsearch/xpack/esql/expression/function/fulltext

2 files changed

+6
-4
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import java.util.List;
4444

4545
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.*;
46+
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isNotNull;
4647
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isNumeric;
4748
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isType;
4849
import static org.elasticsearch.xpack.esql.core.type.DataType.*;
@@ -165,13 +166,14 @@ protected TypeResolution resolveType() {
165166
return new TypeResolution("Unresolved children");
166167
}
167168

168-
TypeResolution valueResolution = isType(
169+
TypeResolution valueResolution = isNotNull(value, sourceText(), FIRST)
170+
.and(isType(
169171
value,
170172
dt -> dt.isNumeric() || dt.isDate() || isSpatialPoint(dt),
171173
sourceText(),
172174
FIRST,
173175
NUMERIC_DATE_OR_SPATIAL_POINT
174-
);
176+
));
175177
if (valueResolution.unresolved()) {
176178
return valueResolution;
177179
}
@@ -392,7 +394,6 @@ static double process(double value, double origin, double scale, double offset,
392394
};
393395
}
394396

395-
// TODO: should offset be a long?
396397
@Evaluator(extraName = "Long")
397398
static double process(long value, long origin, long scale, double offset, double decay, BytesRef functionType) {
398399
return switch (functionType.utf8ToString()) {

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/fulltext/DecayTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import static org.hamcrest.Matchers.equalTo;
3232
import static org.hamcrest.Matchers.startsWith;
3333

34+
// TODO: check null args in VerifierTests
3435
public class DecayTests extends AbstractScalarFunctionTestCase {
3536

3637
public DecayTests(@Name("TestCase") Supplier<TestCaseSupplier.TestCase> testCaseSupplier) {
@@ -149,7 +150,7 @@ public static Iterable<Object[]> parameters() {
149150
)
150151
);
151152

152-
return parameterSuppliersFromTypedDataWithDefaultChecksNoErrors(true, testCaseSuppliers);
153+
return parameterSuppliersFromTypedData(testCaseSuppliers);
153154
}
154155

155156
@Override

0 commit comments

Comments
 (0)