[hive] branch master updated: HIVE-26235: OR Condition on binary column is returning empty result (#3305) (Peter Vary, reviewed by Laszlo Bodor)

2022-05-25 Thread pvary
This is an automated email from the ASF dual-hosted git repository.

pvary pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
 new a22ba9dafad HIVE-26235: OR Condition on binary column is returning 
empty result (#3305) (Peter Vary, reviewed by Laszlo Bodor)
a22ba9dafad is described below

commit a22ba9dafad4bfda0c5c0d2c63eaf83293d6fd64
Author: pvary 
AuthorDate: Thu May 26 06:42:34 2022 +0200

HIVE-26235: OR Condition on binary column is returning empty result (#3305) 
(Peter Vary, reviewed by Laszlo Bodor)
---
 .../hadoop/hive/ql/udf/generic/GenericUDFIn.java   | 22 --
 ql/src/test/queries/clientpositive/udf_in_binary.q |  8 +++
 .../clientpositive/llap/udf_in_binary.q.out| 79 ++
 3 files changed, 103 insertions(+), 6 deletions(-)

diff --git 
a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFIn.java 
b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFIn.java
index 0a2ae14502f..24852e1b728 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFIn.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFIn.java
@@ -18,6 +18,7 @@
 
 package org.apache.hadoop.hive.ql.udf.generic;
 
+import java.nio.ByteBuffer;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -26,6 +27,7 @@ import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
 import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException;
 import org.apache.hadoop.hive.ql.metadata.HiveException;
 import 
org.apache.hadoop.hive.ql.udf.generic.GenericUDFUtils.ReturnObjectInspectorResolver;
+import org.apache.hadoop.hive.serde.serdeConstants;
 import org.apache.hadoop.hive.serde2.objectinspector.ConstantObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector;
@@ -123,9 +125,14 @@ public class GenericUDFIn extends GenericUDF {
 constantInSet = new HashSet();
 if (compareOI.getCategory().equals(ObjectInspector.Category.PRIMITIVE)) {
   for (int i = 1; i < arguments.length; ++i) {
-constantInSet.add(((PrimitiveObjectInspector) compareOI)
+Object constant = ((PrimitiveObjectInspector) compareOI)
 .getPrimitiveJavaObject(conversionHelper
-.convertIfNecessary(arguments[i].get(), argumentOIs[i])));
+.convertIfNecessary(arguments[i].get(), argumentOIs[i]));
+if (compareOI.getTypeName().equals(serdeConstants.BINARY_TYPE_NAME)) {
+  constantInSet.add(ByteBuffer.wrap((byte[]) constant));
+} else {
+  constantInSet.add(constant);
+}
   }
 } else {
   for (int i = 1; i < arguments.length; ++i) {
@@ -148,9 +155,13 @@ public class GenericUDFIn extends GenericUDF {
   }
   switch (compareOI.getCategory()) {
   case PRIMITIVE: {
-if (constantInSet.contains(((PrimitiveObjectInspector) compareOI)
-
.getPrimitiveJavaObject(conversionHelper.convertIfNecessary(arguments[0].get(),
-argumentOIs[0] {
+Object arg = ((PrimitiveObjectInspector) compareOI)
+
.getPrimitiveJavaObject(conversionHelper.convertIfNecessary(arguments[0].get(),
+argumentOIs[0]));
+if (compareOI.getTypeName().equals(serdeConstants.BINARY_TYPE_NAME)) {
+  arg = ByteBuffer.wrap((byte[]) arg);
+}
+if (constantInSet.contains(arg)) {
   bw.set(true);
   return bw;
 }
@@ -226,5 +237,4 @@ public class GenericUDFIn extends GenericUDF {
 sb.append(")");
 return sb.toString();
   }
-
 }
diff --git a/ql/src/test/queries/clientpositive/udf_in_binary.q 
b/ql/src/test/queries/clientpositive/udf_in_binary.q
new file mode 100644
index 000..a27dcb586cb
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/udf_in_binary.q
@@ -0,0 +1,8 @@
+create table test_binary(data_col timestamp, binary_col binary) partitioned by 
(ts string);
+insert into test_binary partition(ts='20220420') values ('2022-04-20 
00:00:00.0', 'a'),
+('2022-04-20 00:00:00.0', 'b'),('2022-04-20 00:00:00.0', 'c'),('2022-04-20 
00:00:00.0', NULL);
+select * from test_binary where ts='20220420' and binary_col = unhex('61');
+select * from test_binary where ts='20220420' and binary_col between 
unhex('61') and unhex('62');
+select * from test_binary where binary_col = unhex('61') or binary_col = 
unhex('62');
+select * from test_binary where ts='20220420' and (binary_col = 
unhex('61') or binary_col = unhex('62'));
+select * from test_binary where binary_col in (unhex('61'), unhex('62'));
diff --git a/ql/src/test/results/clientpositive/llap/udf_in_binary.q.out 
b/ql/src/test/results/clientpositive/llap/udf_in_binary.q.out
new file mode 100644
index 000..0cd8876219e
--- /dev/null
+++ 

[hive] branch master updated: disable flaky mysql metastore test

2022-05-25 Thread kgyrtkirk
This is an automated email from the ASF dual-hosted git repository.

kgyrtkirk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
 new 34b24d55ade disable flaky mysql metastore test
34b24d55ade is described below

commit 34b24d55ade393673424f077b69add43bad9f731
Author: Zoltan Haindrich 
AuthorDate: Wed May 25 11:41:41 2022 +

disable flaky mysql metastore test
---
 Jenkinsfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index ade004a6c3e..79052c64e42 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -257,7 +257,7 @@ fi
   }
 
   def branches = [:]
-  for (def d in ['derby','postgres','mysql','oracle']) {
+  for (def d in ['derby','postgres',/*'mysql',*/'oracle']) {
 def dbType=d
 def splitName = "init@$dbType"
 branches[splitName] = {