zabetak commented on a change in pull request #2816:
URL: https://github.com/apache/hive/pull/2816#discussion_r759247657
##########
File path:
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFNullif.java
##########
@@ -49,6 +50,17 @@ public ObjectInspector initialize(ObjectInspector[]
arguments) throws UDFArgumen
returnOIResolver = new GenericUDFUtils.ReturnObjectInspectorResolver(true);
returnOIResolver.update(arguments[0]);
+ switch (arguments[0].getCategory()) {
+ case LIST:
+ case MAP:
+ case STRUCT:
+ case PRIMITIVE:
+ break;
+ case UNION:
+ default:
+ throw new UDFArgumentTypeException(0, "Unsupported Argument type
category: " + arguments[0].getCategory());
+ }
+
boolean isPrimitive = (arguments[0] instanceof PrimitiveObjectInspector);
if (isPrimitive)
{
Review comment:
When the first argument is a primitive we are making the checks below to
ensure various things as the fact they are of exactly the same type. It appears
that we are not doing the same for non-primitives, should we?
##########
File path: ql/src/test/queries/clientpositive/udf_nullif.q
##########
@@ -27,3 +27,12 @@ select nullif(a,b),
nullif(b,c),
nullif(c,d),
nullif(d,a) from t0;
+
+SELECT assert_true(NULLIF(array(1,2,3),array(1,2,3)) is null);
+SELECT assert_true(NULLIF(array(1,2,3),array(3,2,1)) is not null);
+
+SELECT assert_true(NULLIF(named_struct("c", 1),named_struct("c", 1)) is null);
+SELECT assert_true(NULLIF(named_struct("c", 1),named_struct("c", 2)) is not
null);
+
+SELECT assert_true(NULLIF(map('a',1,'b',2),map('a',1,'b',2)) is null);
+SELECT assert_true(NULLIF(map('a',1,'b',2),map('a',1,'b',3)) is not null);
Review comment:
I haven't used `assert_true` before so I don't know what is the
additional benefit it brings here. Can't we simply compare with the `.q.out`
that the result of NULLIF is the expected one? I guess this would make also the
use of `is null/is not null` redundant since we could see directly the result
in the `.q.out` file.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]