[
https://issues.apache.org/jira/browse/HIVE-25738?focusedWorklogId=687369&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-687369
]
ASF GitHub Bot logged work on HIVE-25738:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 29/Nov/21 15:25
Start Date: 29/Nov/21 15:25
Worklog Time Spent: 10m
Work Description: kgyrtkirk commented on a change in pull request #2816:
URL: https://github.com/apache/hive/pull/2816#discussion_r758469294
##########
File path:
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFNullif.java
##########
@@ -86,17 +87,13 @@ public ObjectInspector initialize(ObjectInspector[]
arguments) throws UDFArgumen
public Object evaluate(DeferredObject[] arguments) throws HiveException {
Object arg0 = arguments[0].get();
Object arg1 = arguments[1].get();
- Object value0 = null;
- if (arg0 != null) {
- value0 = returnOIResolver.convertIfNecessary(arg0, argumentOIs[0],
false);
- }
+ Object value0 = returnOIResolver.convertIfNecessary(arg0, argumentOIs[0],
false);
if (arg0 == null || arg1 == null) {
return value0;
}
- PrimitiveObjectInspector compareOI = (PrimitiveObjectInspector)
returnOIResolver.get();
- if (PrimitiveObjectInspectorUtils.comparePrimitiveObjects(
- value0, compareOI,
- returnOIResolver.convertIfNecessary(arg1, argumentOIs[1], false),
compareOI)) {
+ Object value1 = returnOIResolver.convertIfNecessary(arg1, argumentOIs[1],
false);
+ ObjectInspector compareOI = returnOIResolver.get();
+ if (ObjectInspectorUtils.compare(value0, compareOI, value1, compareOI) ==
0) {
Review comment:
it does work - but there are some interesting findings:
both of the following cases change the "non-used" part of the union (note:
`create_union(idx,o0,o1)` creates a union which uses the `idx`-th object)
```
SELECT (NULLIF(create_union(0,1,2),create_union(0,1,3)) is not null);
false
SELECT (NULLIF(create_union(0,1,2),create_union(1,2,1)) is not null);
true
```
it seems like the comparision ignores the unused/dormant parts which could
be ok; but it seems like it also compares the `idx` field - I think it should
either also ignore the `idx` field or also consider the dormant objects
opened HIVE-25748 to look into this
--
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]
Issue Time Tracking
-------------------
Worklog Id: (was: 687369)
Time Spent: 50m (was: 40m)
> NullIf doesn't support complex types
> ------------------------------------
>
> Key: HIVE-25738
> URL: https://issues.apache.org/jira/browse/HIVE-25738
> Project: Hive
> Issue Type: Improvement
> Reporter: Zoltan Haindrich
> Priority: Major
> Labels: pull-request-available
> Time Spent: 50m
> Remaining Estimate: 0h
>
> {code}
> SELECT NULLIF(array(1,2,3),array(1,2,3))
> {code}
> results in:
> {code}
> java.lang.ClassCastException:
> org.apache.hadoop.hive.serde2.objectinspector.StandardListObjectInspector
> cannot be cast to
> org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector
> at
> org.apache.hadoop.hive.ql.udf.generic.GenericUDFNullif.evaluate(GenericUDFNullif.java:96)
> at
> org.apache.hadoop.hive.ql.udf.generic.GenericUDF.initializeAndFoldConstants(GenericUDF.java:177)
> at
> org.apache.hadoop.hive.ql.parse.type.HiveFunctionHelper.getReturnType(HiveFunctionHelper.java:135)
> at
> org.apache.hadoop.hive.ql.parse.type.RexNodeExprFactory.createFuncCallExpr(RexNodeExprFactory.java:647)
> [...]
> {code}
--
This message was sent by Atlassian Jira
(v8.20.1#820001)