From 10efba15361d33a5441b160d1dacb5a64a704f33 Mon Sep 17 00:00:00 2001 From: Vitalii Dmyterko <92328789+vitaliidm@users.noreply.github.com> Date: Tue, 8 Apr 2025 18:21:39 +0100 Subject: [PATCH 01/13] Add ES|QL copy_sign function --- .../scalar/math/CopySignEvaluator.java | 158 ++++++++++++++++++ .../function/EsqlFunctionRegistry.java | 2 + .../function/scalar/math/CopySIgn.java | 133 +++++++++++++++ 3 files changed, 293 insertions(+) create mode 100644 x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignEvaluator.java create mode 100644 x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySIgn.java diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignEvaluator.java new file mode 100644 index 0000000000000..25b9d5c319b69 --- /dev/null +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignEvaluator.java @@ -0,0 +1,158 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License +// 2.0; you may not use this file except in compliance with the Elastic License +// 2.0. +package org.elasticsearch.xpack.esql.expression.function.scalar.math; + +import java.lang.ArithmeticException; +import java.lang.IllegalArgumentException; +import java.lang.Override; +import java.lang.String; +import org.elasticsearch.compute.data.Block; +import org.elasticsearch.compute.data.DoubleBlock; +import org.elasticsearch.compute.data.DoubleVector; +import org.elasticsearch.compute.data.Page; +import org.elasticsearch.compute.operator.DriverContext; +import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; +import org.elasticsearch.core.Releasables; +import org.elasticsearch.xpack.esql.core.tree.Source; + +/** + * {@link EvalOperator.ExpressionEvaluator} implementation for {@link CopySign}. + * This class is generated. Edit {@code EvaluatorImplementer} instead. + */ +public final class CopySignEvaluator implements EvalOperator.ExpressionEvaluator { + private final Source source; + + private final EvalOperator.ExpressionEvaluator magnitude; + + private final EvalOperator.ExpressionEvaluator sign; + + private final DriverContext driverContext; + + private Warnings warnings; + + public CopySignEvaluator(Source source, EvalOperator.ExpressionEvaluator magnitude, + EvalOperator.ExpressionEvaluator sign, DriverContext driverContext) { + this.source = source; + this.magnitude = magnitude; + this.sign = sign; + this.driverContext = driverContext; + } + + @Override + public Block eval(Page page) { + try (DoubleBlock magnitudeBlock = (DoubleBlock) magnitude.eval(page)) { + try (DoubleBlock signBlock = (DoubleBlock) sign.eval(page)) { + DoubleVector magnitudeVector = magnitudeBlock.asVector(); + if (magnitudeVector == null) { + return eval(page.getPositionCount(), magnitudeBlock, signBlock); + } + DoubleVector signVector = signBlock.asVector(); + if (signVector == null) { + return eval(page.getPositionCount(), magnitudeBlock, signBlock); + } + return eval(page.getPositionCount(), magnitudeVector, signVector); + } + } + } + + public DoubleBlock eval(int positionCount, DoubleBlock magnitudeBlock, DoubleBlock signBlock) { + try(DoubleBlock.Builder result = driverContext.blockFactory().newDoubleBlockBuilder(positionCount)) { + position: for (int p = 0; p < positionCount; p++) { + if (magnitudeBlock.isNull(p)) { + result.appendNull(); + continue position; + } + if (magnitudeBlock.getValueCount(p) != 1) { + if (magnitudeBlock.getValueCount(p) > 1) { + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); + } + result.appendNull(); + continue position; + } + if (signBlock.isNull(p)) { + result.appendNull(); + continue position; + } + if (signBlock.getValueCount(p) != 1) { + if (signBlock.getValueCount(p) > 1) { + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); + } + result.appendNull(); + continue position; + } + try { + result.appendDouble(CopySign.process(magnitudeBlock.getDouble(magnitudeBlock.getFirstValueIndex(p)), signBlock.getDouble(signBlock.getFirstValueIndex(p)))); + } catch (ArithmeticException e) { + warnings().registerException(e); + result.appendNull(); + } + } + return result.build(); + } + } + + public DoubleBlock eval(int positionCount, DoubleVector magnitudeVector, + DoubleVector signVector) { + try(DoubleBlock.Builder result = driverContext.blockFactory().newDoubleBlockBuilder(positionCount)) { + position: for (int p = 0; p < positionCount; p++) { + try { + result.appendDouble(CopySign.process(magnitudeVector.getDouble(p), signVector.getDouble(p))); + } catch (ArithmeticException e) { + warnings().registerException(e); + result.appendNull(); + } + } + return result.build(); + } + } + + @Override + public String toString() { + return "CopySignEvaluator[" + "magnitude=" + magnitude + ", sign=" + sign + "]"; + } + + @Override + public void close() { + Releasables.closeExpectNoException(magnitude, sign); + } + + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { + private final Source source; + + private final EvalOperator.ExpressionEvaluator.Factory magnitude; + + private final EvalOperator.ExpressionEvaluator.Factory sign; + + public Factory(Source source, EvalOperator.ExpressionEvaluator.Factory magnitude, + EvalOperator.ExpressionEvaluator.Factory sign) { + this.source = source; + this.magnitude = magnitude; + this.sign = sign; + } + + @Override + public CopySignEvaluator get(DriverContext context) { + return new CopySignEvaluator(source, magnitude.get(context), sign.get(context), context); + } + + @Override + public String toString() { + return "CopySignEvaluator[" + "magnitude=" + magnitude + ", sign=" + sign + "]"; + } + } +} diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/EsqlFunctionRegistry.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/EsqlFunctionRegistry.java index 41c2b64004b8f..335729e757e1c 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/EsqlFunctionRegistry.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/EsqlFunctionRegistry.java @@ -77,6 +77,7 @@ import org.elasticsearch.xpack.esql.expression.function.scalar.math.Atan2; import org.elasticsearch.xpack.esql.expression.function.scalar.math.Cbrt; import org.elasticsearch.xpack.esql.expression.function.scalar.math.Ceil; +import org.elasticsearch.xpack.esql.expression.function.scalar.math.CopySign; import org.elasticsearch.xpack.esql.expression.function.scalar.math.Cos; import org.elasticsearch.xpack.esql.expression.function.scalar.math.Cosh; import org.elasticsearch.xpack.esql.expression.function.scalar.math.E; @@ -298,6 +299,7 @@ private static FunctionDefinition[][] functions() { def(Atan2.class, Atan2::new, "atan2"), def(Cbrt.class, Cbrt::new, "cbrt"), def(Ceil.class, Ceil::new, "ceil"), + def(CopySign.class, CopySign::new, "copy_sign"), def(Cos.class, Cos::new, "cos"), def(Cosh.class, Cosh::new, "cosh"), def(E.class, E::new, "e"), diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySIgn.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySIgn.java new file mode 100644 index 0000000000000..8220063fe1bd7 --- /dev/null +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySIgn.java @@ -0,0 +1,133 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +package org.elasticsearch.xpack.esql.expression.function.scalar.math; + +import org.elasticsearch.common.io.stream.NamedWriteableRegistry; +import org.elasticsearch.common.io.stream.StreamInput; +import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.compute.ann.Evaluator; +import org.elasticsearch.compute.operator.EvalOperator.ExpressionEvaluator; +import org.elasticsearch.xpack.esql.core.expression.Expression; +import org.elasticsearch.xpack.esql.core.tree.NodeInfo; +import org.elasticsearch.xpack.esql.core.tree.Source; +import org.elasticsearch.xpack.esql.core.type.DataType; +import org.elasticsearch.xpack.esql.core.util.NumericUtils; +import org.elasticsearch.xpack.esql.expression.function.Example; +import org.elasticsearch.xpack.esql.expression.function.FunctionInfo; +import org.elasticsearch.xpack.esql.expression.function.Param; +import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction; +import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; + +import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.FIRST; +import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.SECOND; +import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isNumeric; + +public class CopySign extends EsqlScalarFunction { + public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(Expression.class, "CopySign", CopySign::new); + + private final Expression magnitude; + private final Expression sign; + + @FunctionInfo( + returnType = { "double" }, + description = "Returns the first argument with the sign of the second argument.", + examples = @Example(file = "math", tag = "CopySign") + ) + public CopySign( + Source source, + @Param( + name = "magnitude", + type = { "double", "integer", "long", "unsigned_long" }, + description = "Numeric expression. If `null`, the function returns `null`." + ) Expression magnitude, + @Param( + name = "sign", + type = { "double", "integer", "long", "unsigned_long" }, + description = "Numeric expression. If `null`, the function returns `null`." + ) Expression sign + ) { + super(source, Arrays.asList(magnitude, sign)); + this.magnitude = magnitude; + this.sign = sign; + } + + private CopySign(StreamInput in) throws IOException { + this(Source.readFrom((PlanStreamInput) in), in.readNamedWriteable(Expression.class), in.readNamedWriteable(Expression.class)); + } + + @Override + public void writeTo(StreamOutput out) throws IOException { + source().writeTo(out); + out.writeNamedWriteable(magnitude); + out.writeNamedWriteable(sign); + } + + @Override + public String getWriteableName() { + return ENTRY.name; + } + + @Override + protected TypeResolution resolveType() { + if (childrenResolved() == false) { + return new TypeResolution("Unresolved children"); + } + + TypeResolution resolution = isNumeric(magnitude, sourceText(), FIRST); + if (resolution.unresolved()) { + return resolution; + } + + return isNumeric(sign, sourceText(), SECOND); + } + + @Override + public boolean foldable() { + return magnitude.foldable() && sign.foldable(); + } + + @Evaluator(warnExceptions = { ArithmeticException.class }) + static double process(double magnitude, double sign) { + return NumericUtils.asFiniteNumber(Math.copySign(magnitude, sign)); + } + + @Override + public Expression replaceChildren(List newChildren) { + return new CopySign(source(), newChildren.get(0), newChildren.get(1)); + } + + @Override + protected NodeInfo info() { + return NodeInfo.create(this, CopySign::new, magnitude(), sign()); + } + + public Expression magnitude() { + return magnitude; + } + + public Expression sign() { + return sign; + } + + @Override + public DataType dataType() { + return DataType.DOUBLE; + } + + + @Override + public ExpressionEvaluator.Factory toEvaluator(ToEvaluator toEvaluator) { + var magnitudeEval = Cast.cast(source(), magnitude.dataType(), DataType.DOUBLE, toEvaluator.apply(magnitude)); + var signEval = Cast.cast(source(), sign.dataType(), DataType.DOUBLE, toEvaluator.apply(sign)); + return new CopySignEvaluator.Factory(source(), magnitudeEval, signEval); + } +} From d0ab9567393da15ae590a336a6cabcacc1ccbbab Mon Sep 17 00:00:00 2001 From: elasticsearchmachine Date: Tue, 8 Apr 2025 17:30:00 +0000 Subject: [PATCH 02/13] [CI] Auto commit changes from spotless --- .../xpack/esql/expression/function/scalar/math/CopySIgn.java | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySIgn.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySIgn.java index 8220063fe1bd7..02a0659e4d744 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySIgn.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySIgn.java @@ -123,7 +123,6 @@ public DataType dataType() { return DataType.DOUBLE; } - @Override public ExpressionEvaluator.Factory toEvaluator(ToEvaluator toEvaluator) { var magnitudeEval = Cast.cast(source(), magnitude.dataType(), DataType.DOUBLE, toEvaluator.apply(magnitude)); From a79ce28f71f29e9215937e85c422586e802a7bae Mon Sep 17 00:00:00 2001 From: Vitalii Dmyterko <92328789+vitaliidm@users.noreply.github.com> Date: Tue, 8 Apr 2025 18:32:18 +0100 Subject: [PATCH 03/13] test delete --- .../function/scalar/math/CopySIgn.java | 132 ------------------ 1 file changed, 132 deletions(-) delete mode 100644 x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySIgn.java diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySIgn.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySIgn.java deleted file mode 100644 index 02a0659e4d744..0000000000000 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySIgn.java +++ /dev/null @@ -1,132 +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.scalar.math; - -import org.elasticsearch.common.io.stream.NamedWriteableRegistry; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.compute.ann.Evaluator; -import org.elasticsearch.compute.operator.EvalOperator.ExpressionEvaluator; -import org.elasticsearch.xpack.esql.core.expression.Expression; -import org.elasticsearch.xpack.esql.core.tree.NodeInfo; -import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.core.type.DataType; -import org.elasticsearch.xpack.esql.core.util.NumericUtils; -import org.elasticsearch.xpack.esql.expression.function.Example; -import org.elasticsearch.xpack.esql.expression.function.FunctionInfo; -import org.elasticsearch.xpack.esql.expression.function.Param; -import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction; -import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput; - -import java.io.IOException; -import java.util.Arrays; -import java.util.List; - -import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.FIRST; -import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.SECOND; -import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isNumeric; - -public class CopySign extends EsqlScalarFunction { - public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(Expression.class, "CopySign", CopySign::new); - - private final Expression magnitude; - private final Expression sign; - - @FunctionInfo( - returnType = { "double" }, - description = "Returns the first argument with the sign of the second argument.", - examples = @Example(file = "math", tag = "CopySign") - ) - public CopySign( - Source source, - @Param( - name = "magnitude", - type = { "double", "integer", "long", "unsigned_long" }, - description = "Numeric expression. If `null`, the function returns `null`." - ) Expression magnitude, - @Param( - name = "sign", - type = { "double", "integer", "long", "unsigned_long" }, - description = "Numeric expression. If `null`, the function returns `null`." - ) Expression sign - ) { - super(source, Arrays.asList(magnitude, sign)); - this.magnitude = magnitude; - this.sign = sign; - } - - private CopySign(StreamInput in) throws IOException { - this(Source.readFrom((PlanStreamInput) in), in.readNamedWriteable(Expression.class), in.readNamedWriteable(Expression.class)); - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - source().writeTo(out); - out.writeNamedWriteable(magnitude); - out.writeNamedWriteable(sign); - } - - @Override - public String getWriteableName() { - return ENTRY.name; - } - - @Override - protected TypeResolution resolveType() { - if (childrenResolved() == false) { - return new TypeResolution("Unresolved children"); - } - - TypeResolution resolution = isNumeric(magnitude, sourceText(), FIRST); - if (resolution.unresolved()) { - return resolution; - } - - return isNumeric(sign, sourceText(), SECOND); - } - - @Override - public boolean foldable() { - return magnitude.foldable() && sign.foldable(); - } - - @Evaluator(warnExceptions = { ArithmeticException.class }) - static double process(double magnitude, double sign) { - return NumericUtils.asFiniteNumber(Math.copySign(magnitude, sign)); - } - - @Override - public Expression replaceChildren(List newChildren) { - return new CopySign(source(), newChildren.get(0), newChildren.get(1)); - } - - @Override - protected NodeInfo info() { - return NodeInfo.create(this, CopySign::new, magnitude(), sign()); - } - - public Expression magnitude() { - return magnitude; - } - - public Expression sign() { - return sign; - } - - @Override - public DataType dataType() { - return DataType.DOUBLE; - } - - @Override - public ExpressionEvaluator.Factory toEvaluator(ToEvaluator toEvaluator) { - var magnitudeEval = Cast.cast(source(), magnitude.dataType(), DataType.DOUBLE, toEvaluator.apply(magnitude)); - var signEval = Cast.cast(source(), sign.dataType(), DataType.DOUBLE, toEvaluator.apply(sign)); - return new CopySignEvaluator.Factory(source(), magnitudeEval, signEval); - } -} From 546a0337941b153654ae2026492e567f0255c3c2 Mon Sep 17 00:00:00 2001 From: Vitalii Dmyterko <92328789+vitaliidm@users.noreply.github.com> Date: Tue, 8 Apr 2025 18:33:00 +0100 Subject: [PATCH 04/13] rename file --- .../function/scalar/math/CopySign.java | 132 ++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySign.java diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySign.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySign.java new file mode 100644 index 0000000000000..02a0659e4d744 --- /dev/null +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySign.java @@ -0,0 +1,132 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +package org.elasticsearch.xpack.esql.expression.function.scalar.math; + +import org.elasticsearch.common.io.stream.NamedWriteableRegistry; +import org.elasticsearch.common.io.stream.StreamInput; +import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.compute.ann.Evaluator; +import org.elasticsearch.compute.operator.EvalOperator.ExpressionEvaluator; +import org.elasticsearch.xpack.esql.core.expression.Expression; +import org.elasticsearch.xpack.esql.core.tree.NodeInfo; +import org.elasticsearch.xpack.esql.core.tree.Source; +import org.elasticsearch.xpack.esql.core.type.DataType; +import org.elasticsearch.xpack.esql.core.util.NumericUtils; +import org.elasticsearch.xpack.esql.expression.function.Example; +import org.elasticsearch.xpack.esql.expression.function.FunctionInfo; +import org.elasticsearch.xpack.esql.expression.function.Param; +import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction; +import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; + +import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.FIRST; +import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.SECOND; +import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isNumeric; + +public class CopySign extends EsqlScalarFunction { + public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(Expression.class, "CopySign", CopySign::new); + + private final Expression magnitude; + private final Expression sign; + + @FunctionInfo( + returnType = { "double" }, + description = "Returns the first argument with the sign of the second argument.", + examples = @Example(file = "math", tag = "CopySign") + ) + public CopySign( + Source source, + @Param( + name = "magnitude", + type = { "double", "integer", "long", "unsigned_long" }, + description = "Numeric expression. If `null`, the function returns `null`." + ) Expression magnitude, + @Param( + name = "sign", + type = { "double", "integer", "long", "unsigned_long" }, + description = "Numeric expression. If `null`, the function returns `null`." + ) Expression sign + ) { + super(source, Arrays.asList(magnitude, sign)); + this.magnitude = magnitude; + this.sign = sign; + } + + private CopySign(StreamInput in) throws IOException { + this(Source.readFrom((PlanStreamInput) in), in.readNamedWriteable(Expression.class), in.readNamedWriteable(Expression.class)); + } + + @Override + public void writeTo(StreamOutput out) throws IOException { + source().writeTo(out); + out.writeNamedWriteable(magnitude); + out.writeNamedWriteable(sign); + } + + @Override + public String getWriteableName() { + return ENTRY.name; + } + + @Override + protected TypeResolution resolveType() { + if (childrenResolved() == false) { + return new TypeResolution("Unresolved children"); + } + + TypeResolution resolution = isNumeric(magnitude, sourceText(), FIRST); + if (resolution.unresolved()) { + return resolution; + } + + return isNumeric(sign, sourceText(), SECOND); + } + + @Override + public boolean foldable() { + return magnitude.foldable() && sign.foldable(); + } + + @Evaluator(warnExceptions = { ArithmeticException.class }) + static double process(double magnitude, double sign) { + return NumericUtils.asFiniteNumber(Math.copySign(magnitude, sign)); + } + + @Override + public Expression replaceChildren(List newChildren) { + return new CopySign(source(), newChildren.get(0), newChildren.get(1)); + } + + @Override + protected NodeInfo info() { + return NodeInfo.create(this, CopySign::new, magnitude(), sign()); + } + + public Expression magnitude() { + return magnitude; + } + + public Expression sign() { + return sign; + } + + @Override + public DataType dataType() { + return DataType.DOUBLE; + } + + @Override + public ExpressionEvaluator.Factory toEvaluator(ToEvaluator toEvaluator) { + var magnitudeEval = Cast.cast(source(), magnitude.dataType(), DataType.DOUBLE, toEvaluator.apply(magnitude)); + var signEval = Cast.cast(source(), sign.dataType(), DataType.DOUBLE, toEvaluator.apply(sign)); + return new CopySignEvaluator.Factory(source(), magnitudeEval, signEval); + } +} From be1c1e1f652cce847fdeabb2eeb95c677a4125cf Mon Sep 17 00:00:00 2001 From: Vitalii Dmyterko <92328789+vitaliidm@users.noreply.github.com> Date: Wed, 9 Apr 2025 11:05:49 +0100 Subject: [PATCH 05/13] fix some tests --- .../yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml index 3b657f03b149f..ac60ffeb4efdb 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml @@ -101,7 +101,7 @@ setup: - match: {esql.functions.coalesce: $functions_coalesce} - gt: {esql.functions.categorize: $functions_categorize} # Testing for the entire function set isn't feasbile, so we just check that we return the correct count as an approximation. - - length: {esql.functions: 134} # check the "sister" test below for a likely update to the same esql.functions length check + - length: {esql.functions: 135} # check the "sister" test below for a likely update to the same esql.functions length check --- "Basic ESQL usage output (telemetry) non-snapshot version": From de75f6057a083d7d42bedc95c708ae8d4a8f7ebe Mon Sep 17 00:00:00 2001 From: Vitalii Dmyterko <92328789+vitaliidm@users.noreply.github.com> Date: Wed, 9 Apr 2025 18:56:09 +0100 Subject: [PATCH 06/13] tests --- .../src/main/resources/math.csv-spec | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/math.csv-spec b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/math.csv-spec index c80827c372eec..d8ee78b6832d4 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/math.csv-spec +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/math.csv-spec @@ -1702,3 +1702,84 @@ emp_no:integer | l1:double | l2:double 10002 | -7.23 | null 10003 | 4.0 | null ; + +copySignOfPositiveToPositive +ROW magnitude = 50.0, sign = 3.3 +| EVAL result = COPY_SIGN(magnitude, sign) +; + +magnitude:double | sign:double | result:double +50.0 | 3.3 | 50.0 +; + +copySignOfPositiveToNegative +ROW magnitude = 5.2, sign = -9.0 +| EVAL result = COPY_SIGN(magnitude, sign) +; + +magnitude:double | sign:double | result:double +5.2 | -9.0 | -5.2 +; + +copySignOfNegativeToPositive +ROW magnitude = -5.12, sign = 3.0 +| EVAL result = COPY_SIGN(magnitude, sign) +; + +magnitude:double | sign:double | result:double +-5.12 | 3.0 | 5.12 +; + +copySignOfNegativeToNegative +ROW magnitude = -12.0, sign = -800.0 +| EVAL result = COPY_SIGN(magnitude, sign) +; + +magnitude:double | sign:double | result:double +-12.0 | -800.0 | -12.0 +; + +copySignOfZeroToPositive +ROW magnitude = 0.0, sign = 3.0 +| EVAL result = COPY_SIGN(magnitude, sign) +; + +magnitude:double | sign:double | result:double +0.0 | 3.0 | 0 +; + +copySignOfZeroToNegative +ROW magnitude = 0.0, sign = -1.0 +| EVAL result = COPY_SIGN(magnitude, sign) +; + +magnitude:double | sign:double | result:double +0.0 | -1.0 | -0.0 +; + +copySignOfIntegerDouble +ROW magnitude = 11, sign = -7.111 +| EVAL result = COPY_SIGN(magnitude, sign) +; + +magnitude:integer | sign:double | result:double +11 | -7.111 | -11.0 +; + +copySignOfDoubleInteger +ROW magnitude = 23.1234, sign = 11 +| EVAL result = COPY_SIGN(magnitude, sign) +; + +magnitude:double | sign:integer | result:double +23.1234 | 11 | 23.1234 +; + +copySignOfULDouble +ROW magnitude = 9223372036854775808, sign = -11.2 +| EVAL result = COPY_SIGN(magnitude, sign) +; + +magnitude:unsigned_long | sign:double | result:double +9223372036854775808 | -11.2 | -9223372036854775808 +; From c0afb9e7ecf06b9516253b1514439e506215e639 Mon Sep 17 00:00:00 2001 From: Vitalii Dmyterko <92328789+vitaliidm@users.noreply.github.com> Date: Thu, 10 Apr 2025 11:17:52 +0100 Subject: [PATCH 07/13] fix another test --- .../yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml index ac60ffeb4efdb..56206a4558c1d 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml @@ -101,7 +101,7 @@ setup: - match: {esql.functions.coalesce: $functions_coalesce} - gt: {esql.functions.categorize: $functions_categorize} # Testing for the entire function set isn't feasbile, so we just check that we return the correct count as an approximation. - - length: {esql.functions: 135} # check the "sister" test below for a likely update to the same esql.functions length check + - length: {esql.functions: 136} # check the "sister" test below for a likely update to the same esql.functions length check --- "Basic ESQL usage output (telemetry) non-snapshot version": From 22469ce0ac0cc3eb6b58a9f890c5e397cd9ce5d2 Mon Sep 17 00:00:00 2001 From: Vitalii Dmyterko <92328789+vitaliidm@users.noreply.github.com> Date: Thu, 10 Apr 2025 11:57:32 +0100 Subject: [PATCH 08/13] test + example update --- .../qa/testFixtures/src/main/resources/math.csv-spec | 12 ++++++++++++ .../expression/function/scalar/math/CopySign.java | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/math.csv-spec b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/math.csv-spec index d8ee78b6832d4..63020f9f7b3b5 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/math.csv-spec +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/math.csv-spec @@ -1713,12 +1713,16 @@ magnitude:double | sign:double | result:double ; copySignOfPositiveToNegative +// tag::copySign-PosToNeg[] ROW magnitude = 5.2, sign = -9.0 | EVAL result = COPY_SIGN(magnitude, sign) +// end::copySign-PosToNeg[] ; +// tag::copySign-PosToNeg-result[] magnitude:double | sign:double | result:double 5.2 | -9.0 | -5.2 +// end::copySign-PosToNeg-result[] ; copySignOfNegativeToPositive @@ -1783,3 +1787,11 @@ ROW magnitude = 9223372036854775808, sign = -11.2 magnitude:unsigned_long | sign:double | result:double 9223372036854775808 | -11.2 | -9223372036854775808 ; + +copySignAsArgument +ROW result = SIGNUM(COPY_SIGN(24, -11)) +; + +result:double +-1 +; diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySign.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySign.java index 02a0659e4d744..4a31532e79437 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySign.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySign.java @@ -40,7 +40,7 @@ public class CopySign extends EsqlScalarFunction { @FunctionInfo( returnType = { "double" }, description = "Returns the first argument with the sign of the second argument.", - examples = @Example(file = "math", tag = "CopySign") + examples = @Example(file = "math", tag = "copySign-PosToNeg") ) public CopySign( Source source, From 51cd6381ce7f3f2c5df2d29e5ffef0889f39dd3d Mon Sep 17 00:00:00 2001 From: Vitalii Dmyterko <92328789+vitaliidm@users.noreply.github.com> Date: Fri, 11 Apr 2025 16:04:41 +0100 Subject: [PATCH 09/13] unit tests && docs --- .../functions/description/copy_sign.md | 6 + .../_snippets/functions/examples/copy_sign.md | 14 + .../_snippets/functions/layout/copy_sign.md | 23 ++ .../functions/parameters/copy_sign.md | 10 + .../_snippets/functions/types/copy_sign.md | 23 ++ .../esql/images/functions/copy_sign.svg | 1 + .../definition/functions/copy_sign.json | 301 ++++++++++++++++++ .../esql/kibana/docs/functions/copy_sign.md | 11 + .../esql/expression/ExpressionWritables.java | 2 + .../scalar/math/CopySignErrorTests.java | 38 +++ .../math/CopySignSerializationTests.java | 38 +++ .../function/scalar/math/CopySignTests.java | 52 +++ 12 files changed, 519 insertions(+) create mode 100644 docs/reference/query-languages/esql/_snippets/functions/description/copy_sign.md create mode 100644 docs/reference/query-languages/esql/_snippets/functions/examples/copy_sign.md create mode 100644 docs/reference/query-languages/esql/_snippets/functions/layout/copy_sign.md create mode 100644 docs/reference/query-languages/esql/_snippets/functions/parameters/copy_sign.md create mode 100644 docs/reference/query-languages/esql/_snippets/functions/types/copy_sign.md create mode 100644 docs/reference/query-languages/esql/images/functions/copy_sign.svg create mode 100644 docs/reference/query-languages/esql/kibana/definition/functions/copy_sign.json create mode 100644 docs/reference/query-languages/esql/kibana/docs/functions/copy_sign.md create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignErrorTests.java create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignSerializationTests.java create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignTests.java diff --git a/docs/reference/query-languages/esql/_snippets/functions/description/copy_sign.md b/docs/reference/query-languages/esql/_snippets/functions/description/copy_sign.md new file mode 100644 index 0000000000000..de5ce6081af2c --- /dev/null +++ b/docs/reference/query-languages/esql/_snippets/functions/description/copy_sign.md @@ -0,0 +1,6 @@ +% This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it. + +**Description** + +Returns the first argument with the sign of the second argument. + diff --git a/docs/reference/query-languages/esql/_snippets/functions/examples/copy_sign.md b/docs/reference/query-languages/esql/_snippets/functions/examples/copy_sign.md new file mode 100644 index 0000000000000..065261fa4c904 --- /dev/null +++ b/docs/reference/query-languages/esql/_snippets/functions/examples/copy_sign.md @@ -0,0 +1,14 @@ +% This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it. + +**Example** + +```esql +ROW magnitude = 5.2, sign = -9.0 +| EVAL result = COPY_SIGN(magnitude, sign) +``` + +| magnitude:double | sign:double | result:double | +| --- | --- | --- | +| 5.2 | -9.0 | -5.2 | + + diff --git a/docs/reference/query-languages/esql/_snippets/functions/layout/copy_sign.md b/docs/reference/query-languages/esql/_snippets/functions/layout/copy_sign.md new file mode 100644 index 0000000000000..d9e0b8cf41070 --- /dev/null +++ b/docs/reference/query-languages/esql/_snippets/functions/layout/copy_sign.md @@ -0,0 +1,23 @@ +% This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it. + +## `COPY_SIGN` [esql-copy_sign] + +**Syntax** + +:::{image} ../../../images/functions/copy_sign.svg +:alt: Embedded +:class: text-center +::: + + +:::{include} ../parameters/copy_sign.md +::: + +:::{include} ../description/copy_sign.md +::: + +:::{include} ../types/copy_sign.md +::: + +:::{include} ../examples/copy_sign.md +::: diff --git a/docs/reference/query-languages/esql/_snippets/functions/parameters/copy_sign.md b/docs/reference/query-languages/esql/_snippets/functions/parameters/copy_sign.md new file mode 100644 index 0000000000000..15c0e5e4f7edf --- /dev/null +++ b/docs/reference/query-languages/esql/_snippets/functions/parameters/copy_sign.md @@ -0,0 +1,10 @@ +% This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it. + +**Parameters** + +`magnitude` +: Numeric expression. If `null`, the function returns `null`. + +`sign` +: Numeric expression. If `null`, the function returns `null`. + diff --git a/docs/reference/query-languages/esql/_snippets/functions/types/copy_sign.md b/docs/reference/query-languages/esql/_snippets/functions/types/copy_sign.md new file mode 100644 index 0000000000000..978f57042efe6 --- /dev/null +++ b/docs/reference/query-languages/esql/_snippets/functions/types/copy_sign.md @@ -0,0 +1,23 @@ +% This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it. + +**Supported types** + +| magnitude | sign | result | +| --- | --- | --- | +| double | double | double | +| double | integer | double | +| double | long | double | +| double | unsigned_long | double | +| integer | double | double | +| integer | integer | double | +| integer | long | double | +| integer | unsigned_long | double | +| long | double | double | +| long | integer | double | +| long | long | double | +| long | unsigned_long | double | +| unsigned_long | double | double | +| unsigned_long | integer | double | +| unsigned_long | long | double | +| unsigned_long | unsigned_long | double | + diff --git a/docs/reference/query-languages/esql/images/functions/copy_sign.svg b/docs/reference/query-languages/esql/images/functions/copy_sign.svg new file mode 100644 index 0000000000000..82455b59b1eda --- /dev/null +++ b/docs/reference/query-languages/esql/images/functions/copy_sign.svg @@ -0,0 +1 @@ +COPY_SIGN(magnitude,sign) \ No newline at end of file diff --git a/docs/reference/query-languages/esql/kibana/definition/functions/copy_sign.json b/docs/reference/query-languages/esql/kibana/definition/functions/copy_sign.json new file mode 100644 index 0000000000000..917ddd287a0a4 --- /dev/null +++ b/docs/reference/query-languages/esql/kibana/definition/functions/copy_sign.json @@ -0,0 +1,301 @@ +{ + "comment" : "This is generated by ESQL’s AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.", + "type" : "scalar", + "name" : "copy_sign", + "description" : "Returns the first argument with the sign of the second argument.", + "signatures" : [ + { + "params" : [ + { + "name" : "magnitude", + "type" : "double", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + }, + { + "name" : "sign", + "type" : "double", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + } + ], + "variadic" : false, + "returnType" : "double" + }, + { + "params" : [ + { + "name" : "magnitude", + "type" : "double", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + }, + { + "name" : "sign", + "type" : "integer", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + } + ], + "variadic" : false, + "returnType" : "double" + }, + { + "params" : [ + { + "name" : "magnitude", + "type" : "double", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + }, + { + "name" : "sign", + "type" : "long", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + } + ], + "variadic" : false, + "returnType" : "double" + }, + { + "params" : [ + { + "name" : "magnitude", + "type" : "double", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + }, + { + "name" : "sign", + "type" : "unsigned_long", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + } + ], + "variadic" : false, + "returnType" : "double" + }, + { + "params" : [ + { + "name" : "magnitude", + "type" : "integer", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + }, + { + "name" : "sign", + "type" : "double", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + } + ], + "variadic" : false, + "returnType" : "double" + }, + { + "params" : [ + { + "name" : "magnitude", + "type" : "integer", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + }, + { + "name" : "sign", + "type" : "integer", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + } + ], + "variadic" : false, + "returnType" : "double" + }, + { + "params" : [ + { + "name" : "magnitude", + "type" : "integer", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + }, + { + "name" : "sign", + "type" : "long", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + } + ], + "variadic" : false, + "returnType" : "double" + }, + { + "params" : [ + { + "name" : "magnitude", + "type" : "integer", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + }, + { + "name" : "sign", + "type" : "unsigned_long", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + } + ], + "variadic" : false, + "returnType" : "double" + }, + { + "params" : [ + { + "name" : "magnitude", + "type" : "long", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + }, + { + "name" : "sign", + "type" : "double", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + } + ], + "variadic" : false, + "returnType" : "double" + }, + { + "params" : [ + { + "name" : "magnitude", + "type" : "long", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + }, + { + "name" : "sign", + "type" : "integer", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + } + ], + "variadic" : false, + "returnType" : "double" + }, + { + "params" : [ + { + "name" : "magnitude", + "type" : "long", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + }, + { + "name" : "sign", + "type" : "long", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + } + ], + "variadic" : false, + "returnType" : "double" + }, + { + "params" : [ + { + "name" : "magnitude", + "type" : "long", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + }, + { + "name" : "sign", + "type" : "unsigned_long", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + } + ], + "variadic" : false, + "returnType" : "double" + }, + { + "params" : [ + { + "name" : "magnitude", + "type" : "unsigned_long", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + }, + { + "name" : "sign", + "type" : "double", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + } + ], + "variadic" : false, + "returnType" : "double" + }, + { + "params" : [ + { + "name" : "magnitude", + "type" : "unsigned_long", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + }, + { + "name" : "sign", + "type" : "integer", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + } + ], + "variadic" : false, + "returnType" : "double" + }, + { + "params" : [ + { + "name" : "magnitude", + "type" : "unsigned_long", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + }, + { + "name" : "sign", + "type" : "long", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + } + ], + "variadic" : false, + "returnType" : "double" + }, + { + "params" : [ + { + "name" : "magnitude", + "type" : "unsigned_long", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + }, + { + "name" : "sign", + "type" : "unsigned_long", + "optional" : false, + "description" : "Numeric expression. If `null`, the function returns `null`." + } + ], + "variadic" : false, + "returnType" : "double" + } + ], + "examples" : [ + "ROW magnitude = 5.2, sign = -9.0\n| EVAL result = COPY_SIGN(magnitude, sign)" + ], + "preview" : false, + "snapshot_only" : false +} diff --git a/docs/reference/query-languages/esql/kibana/docs/functions/copy_sign.md b/docs/reference/query-languages/esql/kibana/docs/functions/copy_sign.md new file mode 100644 index 0000000000000..20c19e6115769 --- /dev/null +++ b/docs/reference/query-languages/esql/kibana/docs/functions/copy_sign.md @@ -0,0 +1,11 @@ + + +### COPY_SIGN +Returns the first argument with the sign of the second argument. + +```esql +ROW magnitude = 5.2, sign = -9.0 +| EVAL result = COPY_SIGN(magnitude, sign) +``` diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/ExpressionWritables.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/ExpressionWritables.java index b93028b3e5897..1f525719be057 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/ExpressionWritables.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/ExpressionWritables.java @@ -37,6 +37,7 @@ import org.elasticsearch.xpack.esql.expression.function.scalar.math.Asin; import org.elasticsearch.xpack.esql.expression.function.scalar.math.Atan; import org.elasticsearch.xpack.esql.expression.function.scalar.math.Cbrt; +import org.elasticsearch.xpack.esql.expression.function.scalar.math.CopySign; import org.elasticsearch.xpack.esql.expression.function.scalar.math.Ceil; import org.elasticsearch.xpack.esql.expression.function.scalar.math.Cos; import org.elasticsearch.xpack.esql.expression.function.scalar.math.Cosh; @@ -153,6 +154,7 @@ public static List unaryScalars() { entries.add(ByteLength.ENTRY); entries.add(Cbrt.ENTRY); entries.add(Ceil.ENTRY); + entries.add(CopySign.ENTRY); entries.add(Cos.ENTRY); entries.add(Cosh.ENTRY); entries.add(Exp.ENTRY); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignErrorTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignErrorTests.java new file mode 100644 index 0000000000000..abadcb0c62d3f --- /dev/null +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignErrorTests.java @@ -0,0 +1,38 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + + package org.elasticsearch.xpack.esql.expression.function.scalar.math; + + import org.elasticsearch.xpack.esql.core.expression.Expression; + import org.elasticsearch.xpack.esql.core.tree.Source; + import org.elasticsearch.xpack.esql.core.type.DataType; + import org.elasticsearch.xpack.esql.expression.function.ErrorsForCasesWithoutExamplesTestCase; + import org.elasticsearch.xpack.esql.expression.function.TestCaseSupplier; + import org.hamcrest.Matcher; + + import java.util.List; + import java.util.Set; + + import static org.hamcrest.Matchers.equalTo; + + public class CopySignErrorTests extends ErrorsForCasesWithoutExamplesTestCase { + @Override + protected List cases() { + return paramsToSuppliers(CopySignTests.parameters()); + } + + @Override + protected Expression build(Source source, List args) { + return new CopySign(source, args.get(0), args.get(1)); + } + + @Override + protected Matcher expectedTypeErrorMatcher(List> validPerPosition, List signature) { + return equalTo(typeErrorMessage(true, validPerPosition, signature, (v, i) -> "numeric")); + } + } + \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignSerializationTests.java new file mode 100644 index 0000000000000..ef5a4c390428c --- /dev/null +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignSerializationTests.java @@ -0,0 +1,38 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + + package org.elasticsearch.xpack.esql.expression.function.scalar.math; + + import org.elasticsearch.xpack.esql.core.expression.Expression; + import org.elasticsearch.xpack.esql.core.tree.Source; + import org.elasticsearch.xpack.esql.expression.AbstractExpressionSerializationTests; + + import java.io.IOException; + + public class CopySignSerializationTests extends AbstractExpressionSerializationTests { + @Override + protected CopySign createTestInstance() { + Source source = randomSource(); + Expression magnitude = randomChild(); + Expression sign = randomChild(); + return new CopySign(source, magnitude, sign); + } + + @Override + protected CopySign mutateInstance(CopySign instance) throws IOException { + Source source = instance.source(); + Expression magnitude = instance.magnitude(); + Expression sign = instance.sign(); + if (randomBoolean()) { + magnitude = randomValueOtherThan(magnitude, AbstractExpressionSerializationTests::randomChild); + } else { + sign = randomValueOtherThan(sign, AbstractExpressionSerializationTests::randomChild); + } + return new CopySign(source, magnitude, sign); + } + } + \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignTests.java new file mode 100644 index 0000000000000..ab85abb9f48e5 --- /dev/null +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignTests.java @@ -0,0 +1,52 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + + package org.elasticsearch.xpack.esql.expression.function.scalar.math; + + import com.carrotsearch.randomizedtesting.annotations.Name; + import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; + + import org.elasticsearch.xpack.esql.core.expression.Expression; + import org.elasticsearch.xpack.esql.core.tree.Source; + import org.elasticsearch.xpack.esql.core.type.DataType; + import org.elasticsearch.xpack.esql.expression.function.AbstractScalarFunctionTestCase; + import org.elasticsearch.xpack.esql.expression.function.TestCaseSupplier; + + import java.util.List; + import java.util.function.Supplier; + + public class CopySignTests extends AbstractScalarFunctionTestCase { + public CopySignTests(@Name("TestCase") Supplier testCaseSupplier) { + this.testCase = testCaseSupplier.get(); + } + + @ParametersFactory + public static Iterable parameters() { + List suppliers = TestCaseSupplier.forBinaryCastingToDouble( + "CopySignEvaluator", + "magnitude", + "sign", + Math::copySign, + Double.NEGATIVE_INFINITY, + Double.POSITIVE_INFINITY, + Double.NEGATIVE_INFINITY, + Double.POSITIVE_INFINITY, + List.of() + ); + + suppliers = anyNullIsNull(true, suppliers); + + return parameterSuppliersFromTypedDataWithDefaultChecksNoErrors(true, suppliers); + } + + @Override + protected Expression build(Source source, List args) { + return new CopySign(source, args.get(0), args.get(1)); + } + + } + \ No newline at end of file From e38518c4af9acb025799ea5e00c45d1d75cd15a2 Mon Sep 17 00:00:00 2001 From: Vitalii Dmyterko <92328789+vitaliidm@users.noreply.github.com> Date: Fri, 11 Apr 2025 16:07:31 +0100 Subject: [PATCH 10/13] linting --- .../scalar/math/CopySignErrorTests.java | 69 ++++++------ .../math/CopySignSerializationTests.java | 65 ++++++----- .../function/scalar/math/CopySignTests.java | 101 +++++++++--------- 3 files changed, 116 insertions(+), 119 deletions(-) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignErrorTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignErrorTests.java index abadcb0c62d3f..8fcd45940c6c2 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignErrorTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignErrorTests.java @@ -1,38 +1,37 @@ /* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ +* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +* or more contributor license agreements. Licensed under the Elastic License +* 2.0; you may not use this file except in compliance with the Elastic License +* 2.0. +*/ - package org.elasticsearch.xpack.esql.expression.function.scalar.math; +package org.elasticsearch.xpack.esql.expression.function.scalar.math; - import org.elasticsearch.xpack.esql.core.expression.Expression; - import org.elasticsearch.xpack.esql.core.tree.Source; - import org.elasticsearch.xpack.esql.core.type.DataType; - import org.elasticsearch.xpack.esql.expression.function.ErrorsForCasesWithoutExamplesTestCase; - import org.elasticsearch.xpack.esql.expression.function.TestCaseSupplier; - import org.hamcrest.Matcher; - - import java.util.List; - import java.util.Set; - - import static org.hamcrest.Matchers.equalTo; - - public class CopySignErrorTests extends ErrorsForCasesWithoutExamplesTestCase { - @Override - protected List cases() { - return paramsToSuppliers(CopySignTests.parameters()); - } - - @Override - protected Expression build(Source source, List args) { - return new CopySign(source, args.get(0), args.get(1)); - } - - @Override - protected Matcher expectedTypeErrorMatcher(List> validPerPosition, List signature) { - return equalTo(typeErrorMessage(true, validPerPosition, signature, (v, i) -> "numeric")); - } - } - \ No newline at end of file +import org.elasticsearch.xpack.esql.core.expression.Expression; +import org.elasticsearch.xpack.esql.core.tree.Source; +import org.elasticsearch.xpack.esql.core.type.DataType; +import org.elasticsearch.xpack.esql.expression.function.ErrorsForCasesWithoutExamplesTestCase; +import org.elasticsearch.xpack.esql.expression.function.TestCaseSupplier; +import org.hamcrest.Matcher; + +import java.util.List; +import java.util.Set; + +import static org.hamcrest.Matchers.equalTo; + +public class CopySignErrorTests extends ErrorsForCasesWithoutExamplesTestCase { + @Override + protected List cases() { + return paramsToSuppliers(CopySignTests.parameters()); + } + + @Override + protected Expression build(Source source, List args) { + return new CopySign(source, args.get(0), args.get(1)); + } + + @Override + protected Matcher expectedTypeErrorMatcher(List> validPerPosition, List signature) { + return equalTo(typeErrorMessage(true, validPerPosition, signature, (v, i) -> "numeric")); + } +} \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignSerializationTests.java index ef5a4c390428c..409f0e8fcadc9 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignSerializationTests.java @@ -1,38 +1,37 @@ /* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ +* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +* or more contributor license agreements. Licensed under the Elastic License +* 2.0; you may not use this file except in compliance with the Elastic License +* 2.0. +*/ - package org.elasticsearch.xpack.esql.expression.function.scalar.math; +package org.elasticsearch.xpack.esql.expression.function.scalar.math; - import org.elasticsearch.xpack.esql.core.expression.Expression; - import org.elasticsearch.xpack.esql.core.tree.Source; - import org.elasticsearch.xpack.esql.expression.AbstractExpressionSerializationTests; - - import java.io.IOException; - - public class CopySignSerializationTests extends AbstractExpressionSerializationTests { - @Override - protected CopySign createTestInstance() { - Source source = randomSource(); - Expression magnitude = randomChild(); - Expression sign = randomChild(); - return new CopySign(source, magnitude, sign); - } - - @Override - protected CopySign mutateInstance(CopySign instance) throws IOException { - Source source = instance.source(); - Expression magnitude = instance.magnitude(); - Expression sign = instance.sign(); - if (randomBoolean()) { +import org.elasticsearch.xpack.esql.core.expression.Expression; +import org.elasticsearch.xpack.esql.core.tree.Source; +import org.elasticsearch.xpack.esql.expression.AbstractExpressionSerializationTests; + +import java.io.IOException; + +public class CopySignSerializationTests extends AbstractExpressionSerializationTests { + @Override + protected CopySign createTestInstance() { + Source source = randomSource(); + Expression magnitude = randomChild(); + Expression sign = randomChild(); + return new CopySign(source, magnitude, sign); + } + + @Override + protected CopySign mutateInstance(CopySign instance) throws IOException { + Source source = instance.source(); + Expression magnitude = instance.magnitude(); + Expression sign = instance.sign(); + if (randomBoolean()) { magnitude = randomValueOtherThan(magnitude, AbstractExpressionSerializationTests::randomChild); - } else { + } else { sign = randomValueOtherThan(sign, AbstractExpressionSerializationTests::randomChild); - } - return new CopySign(source, magnitude, sign); - } - } - \ No newline at end of file + } + return new CopySign(source, magnitude, sign); + } +} \ No newline at end of file diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignTests.java index ab85abb9f48e5..a91305995ec07 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignTests.java @@ -1,52 +1,51 @@ /* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - - package org.elasticsearch.xpack.esql.expression.function.scalar.math; - - import com.carrotsearch.randomizedtesting.annotations.Name; - import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; - - import org.elasticsearch.xpack.esql.core.expression.Expression; - import org.elasticsearch.xpack.esql.core.tree.Source; - import org.elasticsearch.xpack.esql.core.type.DataType; - import org.elasticsearch.xpack.esql.expression.function.AbstractScalarFunctionTestCase; - import org.elasticsearch.xpack.esql.expression.function.TestCaseSupplier; - - import java.util.List; - import java.util.function.Supplier; - - public class CopySignTests extends AbstractScalarFunctionTestCase { - public CopySignTests(@Name("TestCase") Supplier testCaseSupplier) { - this.testCase = testCaseSupplier.get(); - } - - @ParametersFactory - public static Iterable parameters() { - List suppliers = TestCaseSupplier.forBinaryCastingToDouble( - "CopySignEvaluator", - "magnitude", - "sign", - Math::copySign, - Double.NEGATIVE_INFINITY, - Double.POSITIVE_INFINITY, - Double.NEGATIVE_INFINITY, - Double.POSITIVE_INFINITY, - List.of() - ); - - suppliers = anyNullIsNull(true, suppliers); - - return parameterSuppliersFromTypedDataWithDefaultChecksNoErrors(true, suppliers); - } - - @Override - protected Expression build(Source source, List args) { - return new CopySign(source, args.get(0), args.get(1)); - } - - } - \ No newline at end of file +* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +* or more contributor license agreements. Licensed under the Elastic License +* 2.0; you may not use this file except in compliance with the Elastic License +* 2.0. +*/ + +package org.elasticsearch.xpack.esql.expression.function.scalar.math; + +import com.carrotsearch.randomizedtesting.annotations.Name; +import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; + +import org.elasticsearch.xpack.esql.core.expression.Expression; +import org.elasticsearch.xpack.esql.core.tree.Source; +import org.elasticsearch.xpack.esql.core.type.DataType; +import org.elasticsearch.xpack.esql.expression.function.AbstractScalarFunctionTestCase; +import org.elasticsearch.xpack.esql.expression.function.TestCaseSupplier; + +import java.util.List; +import java.util.function.Supplier; + +public class CopySignTests extends AbstractScalarFunctionTestCase { + public CopySignTests(@Name("TestCase") Supplier testCaseSupplier) { + this.testCase = testCaseSupplier.get(); + } + + @ParametersFactory + public static Iterable parameters() { + List suppliers = TestCaseSupplier.forBinaryCastingToDouble( + "CopySignEvaluator", + "magnitude", + "sign", + Math::copySign, + Double.NEGATIVE_INFINITY, + Double.POSITIVE_INFINITY, + Double.NEGATIVE_INFINITY, + Double.POSITIVE_INFINITY, + List.of() + ); + + suppliers = anyNullIsNull(true, suppliers); + + return parameterSuppliersFromTypedDataWithDefaultChecksNoErrors(true, suppliers); + } + + @Override + protected Expression build(Source source, List args) { + return new CopySign(source, args.get(0), args.get(1)); + } + +} \ No newline at end of file From 9cb7c1e7d2bdf736bc5106f6251501006161bd79 Mon Sep 17 00:00:00 2001 From: elasticsearchmachine Date: Fri, 11 Apr 2025 15:17:53 +0000 Subject: [PATCH 11/13] [CI] Auto commit changes from spotless --- .../xpack/esql/expression/ExpressionWritables.java | 2 +- .../expression/function/scalar/math/CopySignErrorTests.java | 2 +- .../function/scalar/math/CopySignSerializationTests.java | 2 +- .../esql/expression/function/scalar/math/CopySignTests.java | 3 +-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/ExpressionWritables.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/ExpressionWritables.java index 1f525719be057..e48a2d5747530 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/ExpressionWritables.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/ExpressionWritables.java @@ -37,8 +37,8 @@ import org.elasticsearch.xpack.esql.expression.function.scalar.math.Asin; import org.elasticsearch.xpack.esql.expression.function.scalar.math.Atan; import org.elasticsearch.xpack.esql.expression.function.scalar.math.Cbrt; -import org.elasticsearch.xpack.esql.expression.function.scalar.math.CopySign; import org.elasticsearch.xpack.esql.expression.function.scalar.math.Ceil; +import org.elasticsearch.xpack.esql.expression.function.scalar.math.CopySign; import org.elasticsearch.xpack.esql.expression.function.scalar.math.Cos; import org.elasticsearch.xpack.esql.expression.function.scalar.math.Cosh; import org.elasticsearch.xpack.esql.expression.function.scalar.math.Exp; diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignErrorTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignErrorTests.java index 8fcd45940c6c2..8a56b4d9e0349 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignErrorTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignErrorTests.java @@ -34,4 +34,4 @@ protected Expression build(Source source, List args) { protected Matcher expectedTypeErrorMatcher(List> validPerPosition, List signature) { return equalTo(typeErrorMessage(true, validPerPosition, signature, (v, i) -> "numeric")); } -} \ No newline at end of file +} diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignSerializationTests.java index 409f0e8fcadc9..e13f424e85b43 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignSerializationTests.java @@ -34,4 +34,4 @@ protected CopySign mutateInstance(CopySign instance) throws IOException { } return new CopySign(source, magnitude, sign); } -} \ No newline at end of file +} diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignTests.java index a91305995ec07..28b65d6ab3ddc 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignTests.java @@ -12,7 +12,6 @@ import org.elasticsearch.xpack.esql.core.expression.Expression; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.core.type.DataType; import org.elasticsearch.xpack.esql.expression.function.AbstractScalarFunctionTestCase; import org.elasticsearch.xpack.esql.expression.function.TestCaseSupplier; @@ -48,4 +47,4 @@ protected Expression build(Source source, List args) { return new CopySign(source, args.get(0), args.get(1)); } -} \ No newline at end of file +} From efaa536118709ae2661ea3144e7123878e77ca92 Mon Sep 17 00:00:00 2001 From: Vitalii Dmyterko <92328789+vitaliidm@users.noreply.github.com> Date: Fri, 11 Apr 2025 16:45:25 +0100 Subject: [PATCH 12/13] 137 --- .../yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml index 25bae65958f2f..838ec22a2d8b1 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml @@ -101,7 +101,7 @@ setup: - match: {esql.functions.coalesce: $functions_coalesce} - gt: {esql.functions.categorize: $functions_categorize} # Testing for the entire function set isn't feasbile, so we just check that we return the correct count as an approximation. - - length: {esql.functions: 136} # check the "sister" test below for a likely update to the same esql.functions length check + - length: {esql.functions: 137} # check the "sister" test below for a likely update to the same esql.functions length check --- "Basic ESQL usage output (telemetry) non-snapshot version": From 6c4e49bf7f671a5fa418fa426350635ef99e61b8 Mon Sep 17 00:00:00 2001 From: Vitalii Dmyterko <92328789+vitaliidm@users.noreply.github.com> Date: Fri, 11 Apr 2025 17:08:05 +0100 Subject: [PATCH 13/13] fix stylings --- .../function/scalar/math/CopySignErrorTests.java | 10 +++++----- .../scalar/math/CopySignSerializationTests.java | 10 +++++----- .../expression/function/scalar/math/CopySignTests.java | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignErrorTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignErrorTests.java index 8a56b4d9e0349..d0792951f98e2 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignErrorTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignErrorTests.java @@ -1,9 +1,9 @@ /* -* 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. -*/ + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ package org.elasticsearch.xpack.esql.expression.function.scalar.math; diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignSerializationTests.java index e13f424e85b43..ef7075092c646 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignSerializationTests.java @@ -1,9 +1,9 @@ /* -* 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. -*/ + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ package org.elasticsearch.xpack.esql.expression.function.scalar.math; diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignTests.java index 28b65d6ab3ddc..e2f68ef652130 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/math/CopySignTests.java @@ -1,9 +1,9 @@ /* -* 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. -*/ + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ package org.elasticsearch.xpack.esql.expression.function.scalar.math;