This is an automated email from the ASF dual-hosted git repository.
michaelsmith pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git
The following commit(s) were added to refs/heads/master by this push:
new 6b571eb7e IMPALA-12184: Java UDF increment on an empty string is
inconsistent
6b571eb7e is described below
commit 6b571eb7e4cd24c34331be43193416678e69b579
Author: Peter Rozsa <[email protected]>
AuthorDate: Mon Jun 12 15:12:11 2023 +0200
IMPALA-12184: Java UDF increment on an empty string is inconsistent
This change removes the Text-typed overload for BufferAlteringUDF to
avoid ambiguous function matchings. It also changes the 2-parameter
function in BufferAlteringUDF to cover Text typed arguments.
Tests:
- test_udfs.py manually executed
Change-Id: I3a17240ce39fef41b0453f162ab5752f1c940f41
Reviewed-on: http://gerrit.cloudera.org:8080/20038
Reviewed-by: Michael Smith <[email protected]>
Tested-by: Impala Public Jenkins <[email protected]>
---
.../java/org/apache/impala/BufferAlteringUdf.java | 19 +++---------------
.../queries/QueryTest/java-udf.test | 23 ++++++++--------------
.../queries/QueryTest/load-java-udfs.test | 6 +-----
3 files changed, 12 insertions(+), 36 deletions(-)
diff --git
a/java/test-hive-udfs/src/main/java/org/apache/impala/BufferAlteringUdf.java
b/java/test-hive-udfs/src/main/java/org/apache/impala/BufferAlteringUdf.java
index 9fbe07a04..0f50fe52b 100644
--- a/java/test-hive-udfs/src/main/java/org/apache/impala/BufferAlteringUdf.java
+++ b/java/test-hive-udfs/src/main/java/org/apache/impala/BufferAlteringUdf.java
@@ -32,18 +32,6 @@ import org.apache.hadoop.io.Text;
* interface.
*/
public class BufferAlteringUdf extends UDF {
- /**
- * Increments the first byte by one in a Text and returns the result as a
Text
- */
- public Text evaluate(Text text) throws ParseException {
- if ((null == text) || ("".equals(text.toString()))) {
- return null;
- }
- byte[] bytes = text.getBytes();
-
- incrementByteArray(bytes);
- return text;
- }
/**
* Increments the first byte by one in a BytesWritable and returns the
result as a
@@ -60,11 +48,10 @@ public class BufferAlteringUdf extends UDF {
}
/**
- * Copies the source BytesWritable to the target BytesWritable, implicitly
resizing it.
- * After the copy, the first byte of the target BytesWritable is incremented
by one.
+ * Copies the source BytesWritable to the target Text, implicitly resizing
it.
+ * After the copy, the first byte of the target Text is incremented by one.
*/
- public BytesWritable evaluate(BytesWritable target, BytesWritable source)
- throws ParseException {
+ public Text evaluate(Text target, BytesWritable source) throws
ParseException {
if (null == source || null == target) {
return null;
}
diff --git
a/testdata/workloads/functional-query/queries/QueryTest/java-udf.test
b/testdata/workloads/functional-query/queries/QueryTest/java-udf.test
index fb2bc4f2a..4b16405c3 100644
--- a/testdata/workloads/functional-query/queries/QueryTest/java-udf.test
+++ b/testdata/workloads/functional-query/queries/QueryTest/java-udf.test
@@ -350,37 +350,30 @@ symbol='org.apache.impala.TestUdf';
CatalogException: Variable arguments not supported in Hive UDFs.
====
---- QUERY
-select increment("a");
+select increment(cast("a" as binary));
---- TYPES
-STRING
+BINARY
---- RESULTS
'b'
====
---- QUERY
-select increment(NULL);
----- TYPES
-STRING
----- RESULTS
-'NULL'
-====
----- QUERY
-select increment("");
+select increment(cast("" as binary));
---- TYPES
-STRING
+BINARY
---- RESULTS
''
====
---- QUERY
-select increment(cast("a" as binary));
+select increment(NULL);
---- TYPES
BINARY
---- RESULTS
-'b'
+'NULL'
====
---- QUERY
-select copy_and_increment(cast("bbb" as binary), cast("aaaa" as binary));
+select copy_and_increment("bbb", cast("aaaa" as binary));
---- TYPES
-BINARY
+STRING
---- RESULTS
'baaa'
====
diff --git
a/testdata/workloads/functional-query/queries/QueryTest/load-java-udfs.test
b/testdata/workloads/functional-query/queries/QueryTest/load-java-udfs.test
index 81c8d579a..1588671e1 100644
--- a/testdata/workloads/functional-query/queries/QueryTest/load-java-udfs.test
+++ b/testdata/workloads/functional-query/queries/QueryTest/load-java-udfs.test
@@ -93,11 +93,7 @@ create function increment(binary) returns binary
location '$FILESYSTEM_PREFIX/test-warehouse/impala-hive-udfs.jar'
symbol='org.apache.impala.BufferAlteringUdf';
-create function increment(string) returns string
-location '$FILESYSTEM_PREFIX/test-warehouse/impala-hive-udfs.jar'
-symbol='org.apache.impala.BufferAlteringUdf';
-
-create function copy_and_increment(binary, binary) returns binary
+create function copy_and_increment(string, binary) returns string
location '$FILESYSTEM_PREFIX/test-warehouse/impala-hive-udfs.jar'
symbol='org.apache.impala.BufferAlteringUdf';
====