diff --git a/docs/reference/esql/functions/kibana/definition/hash.json b/docs/reference/esql/functions/kibana/definition/hash.json
index 21f56bad80df1..17a60cf45acfe 100644
--- a/docs/reference/esql/functions/kibana/definition/hash.json
+++ b/docs/reference/esql/functions/kibana/definition/hash.json
@@ -7,7 +7,7 @@
{
"params" : [
{
- "name" : "alg",
+ "name" : "algorithm",
"type" : "keyword",
"optional" : false,
"description" : "Hash algorithm to use."
@@ -25,7 +25,7 @@
{
"params" : [
{
- "name" : "alg",
+ "name" : "algorithm",
"type" : "keyword",
"optional" : false,
"description" : "Hash algorithm to use."
@@ -43,7 +43,7 @@
{
"params" : [
{
- "name" : "alg",
+ "name" : "algorithm",
"type" : "text",
"optional" : false,
"description" : "Hash algorithm to use."
@@ -61,7 +61,7 @@
{
"params" : [
{
- "name" : "alg",
+ "name" : "algorithm",
"type" : "text",
"optional" : false,
"description" : "Hash algorithm to use."
diff --git a/docs/reference/esql/functions/parameters/hash.asciidoc b/docs/reference/esql/functions/parameters/hash.asciidoc
index cabffe51f7feb..d47a82d4ab214 100644
--- a/docs/reference/esql/functions/parameters/hash.asciidoc
+++ b/docs/reference/esql/functions/parameters/hash.asciidoc
@@ -2,7 +2,7 @@
*Parameters*
-`alg`::
+`algorithm`::
Hash algorithm to use.
`input`::
diff --git a/docs/reference/esql/functions/signature/hash.svg b/docs/reference/esql/functions/signature/hash.svg
index 2b6b1088ed561..f819e14c9d1a4 100644
--- a/docs/reference/esql/functions/signature/hash.svg
+++ b/docs/reference/esql/functions/signature/hash.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/docs/reference/esql/functions/types/hash.asciidoc b/docs/reference/esql/functions/types/hash.asciidoc
index 9d8a181084676..786ba03b2aa60 100644
--- a/docs/reference/esql/functions/types/hash.asciidoc
+++ b/docs/reference/esql/functions/types/hash.asciidoc
@@ -4,7 +4,7 @@
[%header.monospaced.styled,format=dsv,separator=|]
|===
-alg | input | result
+algorithm | input | result
keyword | keyword | keyword
keyword | text | keyword
text | keyword | keyword
diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/HashConstantEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/HashConstantEvaluator.java
index f82501da7c97e..d5bfbfca04d85 100644
--- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/HashConstantEvaluator.java
+++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/HashConstantEvaluator.java
@@ -30,7 +30,7 @@ public final class HashConstantEvaluator implements EvalOperator.ExpressionEvalu
private final BreakingBytesRefBuilder scratch;
- private final MessageDigest alg;
+ private final MessageDigest algorithm;
private final EvalOperator.ExpressionEvaluator input;
@@ -38,11 +38,12 @@ public final class HashConstantEvaluator implements EvalOperator.ExpressionEvalu
private Warnings warnings;
- public HashConstantEvaluator(Source source, BreakingBytesRefBuilder scratch, MessageDigest alg,
- EvalOperator.ExpressionEvaluator input, DriverContext driverContext) {
+ public HashConstantEvaluator(Source source, BreakingBytesRefBuilder scratch,
+ MessageDigest algorithm, EvalOperator.ExpressionEvaluator input,
+ DriverContext driverContext) {
this.source = source;
this.scratch = scratch;
- this.alg = alg;
+ this.algorithm = algorithm;
this.input = input;
this.driverContext = driverContext;
}
@@ -73,7 +74,7 @@ public BytesRefBlock eval(int positionCount, BytesRefBlock inputBlock) {
result.appendNull();
continue position;
}
- result.appendBytesRef(Hash.processConstant(this.scratch, this.alg, inputBlock.getBytesRef(inputBlock.getFirstValueIndex(p), inputScratch)));
+ result.appendBytesRef(Hash.processConstant(this.scratch, this.algorithm, inputBlock.getBytesRef(inputBlock.getFirstValueIndex(p), inputScratch)));
}
return result.build();
}
@@ -83,7 +84,7 @@ public BytesRefVector eval(int positionCount, BytesRefVector inputVector) {
try(BytesRefVector.Builder result = driverContext.blockFactory().newBytesRefVectorBuilder(positionCount)) {
BytesRef inputScratch = new BytesRef();
position: for (int p = 0; p < positionCount; p++) {
- result.appendBytesRef(Hash.processConstant(this.scratch, this.alg, inputVector.getBytesRef(p, inputScratch)));
+ result.appendBytesRef(Hash.processConstant(this.scratch, this.algorithm, inputVector.getBytesRef(p, inputScratch)));
}
return result.build();
}
@@ -91,7 +92,7 @@ public BytesRefVector eval(int positionCount, BytesRefVector inputVector) {
@Override
public String toString() {
- return "HashConstantEvaluator[" + "alg=" + alg + ", input=" + input + "]";
+ return "HashConstantEvaluator[" + "algorithm=" + algorithm + ", input=" + input + "]";
}
@Override
@@ -116,27 +117,27 @@ static class Factory implements EvalOperator.ExpressionEvaluator.Factory {
private final Function scratch;
- private final Function alg;
+ private final Function algorithm;
private final EvalOperator.ExpressionEvaluator.Factory input;
public Factory(Source source, Function scratch,
- Function alg,
+ Function algorithm,
EvalOperator.ExpressionEvaluator.Factory input) {
this.source = source;
this.scratch = scratch;
- this.alg = alg;
+ this.algorithm = algorithm;
this.input = input;
}
@Override
public HashConstantEvaluator get(DriverContext context) {
- return new HashConstantEvaluator(source, scratch.apply(context), alg.apply(context), input.get(context), context);
+ return new HashConstantEvaluator(source, scratch.apply(context), algorithm.apply(context), input.get(context), context);
}
@Override
public String toString() {
- return "HashConstantEvaluator[" + "alg=" + alg + ", input=" + input + "]";
+ return "HashConstantEvaluator[" + "algorithm=" + algorithm + ", input=" + input + "]";
}
}
}
diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/HashEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/HashEvaluator.java
index 3c782dafafe02..8b01cc0330142 100644
--- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/HashEvaluator.java
+++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/HashEvaluator.java
@@ -30,7 +30,7 @@ public final class HashEvaluator implements EvalOperator.ExpressionEvaluator {
private final BreakingBytesRefBuilder scratch;
- private final EvalOperator.ExpressionEvaluator alg;
+ private final EvalOperator.ExpressionEvaluator algorithm;
private final EvalOperator.ExpressionEvaluator input;
@@ -39,43 +39,44 @@ public final class HashEvaluator implements EvalOperator.ExpressionEvaluator {
private Warnings warnings;
public HashEvaluator(Source source, BreakingBytesRefBuilder scratch,
- EvalOperator.ExpressionEvaluator alg, EvalOperator.ExpressionEvaluator input,
+ EvalOperator.ExpressionEvaluator algorithm, EvalOperator.ExpressionEvaluator input,
DriverContext driverContext) {
this.source = source;
this.scratch = scratch;
- this.alg = alg;
+ this.algorithm = algorithm;
this.input = input;
this.driverContext = driverContext;
}
@Override
public Block eval(Page page) {
- try (BytesRefBlock algBlock = (BytesRefBlock) alg.eval(page)) {
+ try (BytesRefBlock algorithmBlock = (BytesRefBlock) algorithm.eval(page)) {
try (BytesRefBlock inputBlock = (BytesRefBlock) input.eval(page)) {
- BytesRefVector algVector = algBlock.asVector();
- if (algVector == null) {
- return eval(page.getPositionCount(), algBlock, inputBlock);
+ BytesRefVector algorithmVector = algorithmBlock.asVector();
+ if (algorithmVector == null) {
+ return eval(page.getPositionCount(), algorithmBlock, inputBlock);
}
BytesRefVector inputVector = inputBlock.asVector();
if (inputVector == null) {
- return eval(page.getPositionCount(), algBlock, inputBlock);
+ return eval(page.getPositionCount(), algorithmBlock, inputBlock);
}
- return eval(page.getPositionCount(), algVector, inputVector);
+ return eval(page.getPositionCount(), algorithmVector, inputVector);
}
}
}
- public BytesRefBlock eval(int positionCount, BytesRefBlock algBlock, BytesRefBlock inputBlock) {
+ public BytesRefBlock eval(int positionCount, BytesRefBlock algorithmBlock,
+ BytesRefBlock inputBlock) {
try(BytesRefBlock.Builder result = driverContext.blockFactory().newBytesRefBlockBuilder(positionCount)) {
- BytesRef algScratch = new BytesRef();
+ BytesRef algorithmScratch = new BytesRef();
BytesRef inputScratch = new BytesRef();
position: for (int p = 0; p < positionCount; p++) {
- if (algBlock.isNull(p)) {
+ if (algorithmBlock.isNull(p)) {
result.appendNull();
continue position;
}
- if (algBlock.getValueCount(p) != 1) {
- if (algBlock.getValueCount(p) > 1) {
+ if (algorithmBlock.getValueCount(p) != 1) {
+ if (algorithmBlock.getValueCount(p) > 1) {
warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value"));
}
result.appendNull();
@@ -93,7 +94,7 @@ public BytesRefBlock eval(int positionCount, BytesRefBlock algBlock, BytesRefBlo
continue position;
}
try {
- result.appendBytesRef(Hash.process(this.scratch, algBlock.getBytesRef(algBlock.getFirstValueIndex(p), algScratch), inputBlock.getBytesRef(inputBlock.getFirstValueIndex(p), inputScratch)));
+ result.appendBytesRef(Hash.process(this.scratch, algorithmBlock.getBytesRef(algorithmBlock.getFirstValueIndex(p), algorithmScratch), inputBlock.getBytesRef(inputBlock.getFirstValueIndex(p), inputScratch)));
} catch (NoSuchAlgorithmException e) {
warnings().registerException(e);
result.appendNull();
@@ -103,14 +104,14 @@ public BytesRefBlock eval(int positionCount, BytesRefBlock algBlock, BytesRefBlo
}
}
- public BytesRefBlock eval(int positionCount, BytesRefVector algVector,
+ public BytesRefBlock eval(int positionCount, BytesRefVector algorithmVector,
BytesRefVector inputVector) {
try(BytesRefBlock.Builder result = driverContext.blockFactory().newBytesRefBlockBuilder(positionCount)) {
- BytesRef algScratch = new BytesRef();
+ BytesRef algorithmScratch = new BytesRef();
BytesRef inputScratch = new BytesRef();
position: for (int p = 0; p < positionCount; p++) {
try {
- result.appendBytesRef(Hash.process(this.scratch, algVector.getBytesRef(p, algScratch), inputVector.getBytesRef(p, inputScratch)));
+ result.appendBytesRef(Hash.process(this.scratch, algorithmVector.getBytesRef(p, algorithmScratch), inputVector.getBytesRef(p, inputScratch)));
} catch (NoSuchAlgorithmException e) {
warnings().registerException(e);
result.appendNull();
@@ -122,12 +123,12 @@ public BytesRefBlock eval(int positionCount, BytesRefVector algVector,
@Override
public String toString() {
- return "HashEvaluator[" + "alg=" + alg + ", input=" + input + "]";
+ return "HashEvaluator[" + "algorithm=" + algorithm + ", input=" + input + "]";
}
@Override
public void close() {
- Releasables.closeExpectNoException(scratch, alg, input);
+ Releasables.closeExpectNoException(scratch, algorithm, input);
}
private Warnings warnings() {
@@ -147,27 +148,27 @@ static class Factory implements EvalOperator.ExpressionEvaluator.Factory {
private final Function scratch;
- private final EvalOperator.ExpressionEvaluator.Factory alg;
+ private final EvalOperator.ExpressionEvaluator.Factory algorithm;
private final EvalOperator.ExpressionEvaluator.Factory input;
public Factory(Source source, Function scratch,
- EvalOperator.ExpressionEvaluator.Factory alg,
+ EvalOperator.ExpressionEvaluator.Factory algorithm,
EvalOperator.ExpressionEvaluator.Factory input) {
this.source = source;
this.scratch = scratch;
- this.alg = alg;
+ this.algorithm = algorithm;
this.input = input;
}
@Override
public HashEvaluator get(DriverContext context) {
- return new HashEvaluator(source, scratch.apply(context), alg.get(context), input.get(context), context);
+ return new HashEvaluator(source, scratch.apply(context), algorithm.get(context), input.get(context), context);
}
@Override
public String toString() {
- return "HashEvaluator[" + "alg=" + alg + ", input=" + input + "]";
+ return "HashEvaluator[" + "algorithm=" + algorithm + ", input=" + input + "]";
}
}
}
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Hash.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Hash.java
index 38d085e93d5a9..b5364935464b3 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Hash.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Hash.java
@@ -38,7 +38,7 @@ public class Hash extends EsqlScalarFunction {
public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(Expression.class, "Hash", Hash::new);
- private final Expression alg;
+ private final Expression algorithm;
private final Expression input;
@FunctionInfo(
@@ -47,11 +47,11 @@ public class Hash extends EsqlScalarFunction {
)
public Hash(
Source source,
- @Param(name = "alg", type = { "keyword", "text" }, description = "Hash algorithm to use.") Expression alg,
+ @Param(name = "algorithm", type = { "keyword", "text" }, description = "Hash algorithm to use.") Expression algorithm,
@Param(name = "input", type = { "keyword", "text" }, description = "Input to hash.") Expression input
) {
- super(source, List.of(alg, input));
- this.alg = alg;
+ super(source, List.of(algorithm, input));
+ this.algorithm = algorithm;
this.input = input;
}
@@ -62,7 +62,7 @@ private Hash(StreamInput in) throws IOException {
@Override
public void writeTo(StreamOutput out) throws IOException {
source().writeTo(out);
- out.writeNamedWriteable(alg);
+ out.writeNamedWriteable(algorithm);
out.writeNamedWriteable(input);
}
@@ -82,7 +82,7 @@ protected TypeResolution resolveType() {
return new TypeResolution("Unresolved children");
}
- TypeResolution resolution = isString(alg, sourceText(), FIRST);
+ TypeResolution resolution = isString(algorithm, sourceText(), FIRST);
if (resolution.unresolved()) {
return resolution;
}
@@ -92,28 +92,31 @@ protected TypeResolution resolveType() {
@Override
public boolean foldable() {
- return alg.foldable() && input.foldable();
+ return algorithm.foldable() && input.foldable();
}
@Evaluator(warnExceptions = NoSuchAlgorithmException.class)
- static BytesRef process(@Fixed(includeInToString = false, build = true) BreakingBytesRefBuilder scratch, BytesRef alg, BytesRef input)
- throws NoSuchAlgorithmException {
- return hash(scratch, MessageDigest.getInstance(alg.utf8ToString()), input);
+ static BytesRef process(
+ @Fixed(includeInToString = false, build = true) BreakingBytesRefBuilder scratch,
+ BytesRef algorithm,
+ BytesRef input
+ ) throws NoSuchAlgorithmException {
+ return hash(scratch, MessageDigest.getInstance(algorithm.utf8ToString()), input);
}
@Evaluator(extraName = "Constant")
static BytesRef processConstant(
@Fixed(includeInToString = false, build = true) BreakingBytesRefBuilder scratch,
- @Fixed(build = true) MessageDigest alg,
+ @Fixed(build = true) MessageDigest algorithm,
BytesRef input
) {
- return hash(scratch, alg, input);
+ return hash(scratch, algorithm, input);
}
- private static BytesRef hash(BreakingBytesRefBuilder scratch, MessageDigest alg, BytesRef input) {
- alg.reset();
- alg.update(input.bytes, input.offset, input.length);
- var digest = alg.digest();
+ private static BytesRef hash(BreakingBytesRefBuilder scratch, MessageDigest algorithm, BytesRef input) {
+ algorithm.reset();
+ algorithm.update(input.bytes, input.offset, input.length);
+ var digest = algorithm.digest();
scratch.clear();
scratch.grow(digest.length * 2);
appendUtf8HexDigest(scratch, digest);
@@ -135,9 +138,9 @@ private static void appendUtf8HexDigest(BreakingBytesRefBuilder scratch, byte[]
@Override
public EvalOperator.ExpressionEvaluator.Factory toEvaluator(ToEvaluator toEvaluator) {
- if (alg.foldable()) {
+ if (algorithm.foldable()) {
try {
- var md = MessageDigest.getInstance(((BytesRef) alg.fold()).utf8ToString());
+ var md = MessageDigest.getInstance(((BytesRef) algorithm.fold()).utf8ToString());
return new HashConstantEvaluator.Factory(
source(),
context -> new BreakingBytesRefBuilder(context.breaker(), "hash"),
@@ -145,13 +148,13 @@ public EvalOperator.ExpressionEvaluator.Factory toEvaluator(ToEvaluator toEvalua
toEvaluator.apply(input)
);
} catch (NoSuchAlgorithmException e) {
- throw new InvalidArgumentException(e, "invalid alg for [{}]: {}", sourceText(), e.getMessage());
+ throw new InvalidArgumentException(e, "invalid algorithm for [{}]: {}", sourceText(), e.getMessage());
}
} else {
return new HashEvaluator.Factory(
source(),
context -> new BreakingBytesRefBuilder(context.breaker(), "hash"),
- toEvaluator.apply(alg),
+ toEvaluator.apply(algorithm),
toEvaluator.apply(input)
);
}
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/HashTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/HashTests.java
index 887cec50ed6b4..ba6b44922ded2 100644
--- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/HashTests.java
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/HashTests.java
@@ -42,46 +42,46 @@ public HashTests(@Name("TestCase") Supplier testCaseS
@ParametersFactory
public static Iterable