From 573e5a2e07e515cdd4dd49308254fe094abdf7c4 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Mon, 28 Aug 2023 11:36:53 -0400 Subject: [PATCH] Format and test --- docs/reference/esql/functions/left.asciidoc | 4 ++-- .../esql/qa/testFixtures/src/main/resources/show.csv-spec | 2 +- .../xpack/esql/expression/function/scalar/string/Left.java | 7 +++---- .../esql/expression/function/scalar/string/LeftTests.java | 1 - 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/docs/reference/esql/functions/left.asciidoc b/docs/reference/esql/functions/left.asciidoc index 3fb277bd12cbf..42537d9560ebf 100644 --- a/docs/reference/esql/functions/left.asciidoc +++ b/docs/reference/esql/functions/left.asciidoc @@ -6,9 +6,9 @@ from string starting from 0. [source.merge.styled,esql] ---- -include::{esql-specs}/docs.csv-spec[tag=left] +include::{esql-specs}/string.csv-spec[tag=left] ---- [%header.monospaced.styled,format=dsv,separator=|] |=== -include::{esql-specs}/docs.csv-spec[tag=left-result] +include::{esql-specs}/string.csv-spec[tag=left-result] |=== diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/show.csv-spec b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/show.csv-spec index 10476f8523b14..96eee58be4855 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/show.csv-spec +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/show.csv-spec @@ -36,7 +36,7 @@ is_finite |is_finite(arg1) is_infinite |is_infinite(arg1) is_nan |is_nan(arg1) least |least(arg1, arg2...) -left |left(arg1) +left |left(arg1, arg2) length |length(arg1) log10 |log10(arg1) ltrim |ltrim(arg1) diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Left.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Left.java index 6b15d9d310605..9c1133769f846 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Left.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Left.java @@ -56,11 +56,10 @@ static BytesRef process(@Fixed BytesRef out, BytesRef str, int length) { out.length = str.length; int curLenStart = 0; UnicodeUtil.UTF8CodePoint cp = new UnicodeUtil.UTF8CodePoint(); - for (int i = 0; i < length && curLenStart < out.length; - i++, curLenStart += cp.numBytes) { - UnicodeUtil.codePointAt(out.bytes, out.offset + curLenStart, cp); + for (int i = 0; i < length && curLenStart < out.length; i++, curLenStart += cp.numBytes) { + UnicodeUtil.codePointAt(out.bytes, out.offset + curLenStart, cp); } - out.length = Math.min(curLenStart, out.length); + out.length = Math.min(curLenStart, out.length); return out; } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/LeftTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/LeftTests.java index ab641415cc115..1119fcc80aa39 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/LeftTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/LeftTests.java @@ -26,7 +26,6 @@ import static org.elasticsearch.compute.data.BlockUtils.toJavaObject; import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.nullValue; public class LeftTests extends AbstractScalarFunctionTestCase { public LeftTests(@Name("TestCase") Supplier testCaseSupplier) {