Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 25DDF200B83 for ; Fri, 2 Sep 2016 10:39:22 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 22D60160ACB; Fri, 2 Sep 2016 08:39:22 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 72123160AAB for ; Fri, 2 Sep 2016 10:39:21 +0200 (CEST) Received: (qmail 76581 invoked by uid 500); 2 Sep 2016 08:39:20 -0000 Mailing-List: contact issues-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hive.apache.org Delivered-To: mailing list issues@hive.apache.org Received: (qmail 76548 invoked by uid 99); 2 Sep 2016 08:39:20 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Sep 2016 08:39:20 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 834072C1B7D for ; Fri, 2 Sep 2016 08:39:20 +0000 (UTC) Date: Fri, 2 Sep 2016 08:39:20 +0000 (UTC) From: "Niklaus Xiao (JIRA)" To: issues@hive.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (HIVE-14694) UDF rand throws NPE when input data is NULL MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Fri, 02 Sep 2016 08:39:22 -0000 [ https://issues.apache.org/jira/browse/HIVE-14694?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15457950#comment-15457950 ] Niklaus Xiao commented on HIVE-14694: ------------------------------------- I tried in MySQL, when input data is null, MySQL will use 0 as the seed {code} mysql> select rand(0); +---------------------+ | rand(0) | +---------------------+ | 0.15522042769493574 | +---------------------+ 1 row in set (0.00 sec) mysql> select rand(NULL); +---------------------+ | rand(NULL) | +---------------------+ | 0.15522042769493574 | +---------------------+ 1 row in set (0.00 sec) {code} So I use 0 as seed when input data is null in the patch, cc [~ashutoshc] > UDF rand throws NPE when input data is NULL > ------------------------------------------- > > Key: HIVE-14694 > URL: https://issues.apache.org/jira/browse/HIVE-14694 > Project: Hive > Issue Type: Bug > Components: UDF > Affects Versions: 2.2.0 > Reporter: Niklaus Xiao > Assignee: Niklaus Xiao > Priority: Minor > Attachments: HIVE-14694.1.patch > > > When use {{rand}} function with null, HiveServer throws NPE: > {code} > 0: jdbc:hive2://10.64.35.144:21066/> desc foo1; > +-----------+------------+----------+--+ > | col_name | data_type | comment | > +-----------+------------+----------+--+ > | c1 | bigint | | > +-----------+------------+----------+--+ > 1 row selected (0.075 seconds) > 0: jdbc:hive2://10.64.35.144:21066/> select * from foo1; > +----------+--+ > | foo1.c1 | > +----------+--+ > | NULL | > | 1 | > | 2 | > +----------+--+ > 3 rows selected (0.124 seconds) > 0: jdbc:hive2://10.64.35.144:21066/> select rand(c1) from foo1; > Error: java.io.IOException: org.apache.hadoop.hive.ql.metadata.HiveException: Unable to execute method public org.apache.hadoop.hive.serde2.io.DoubleWritable org.apache.hadoop.hive.ql.udf.UDFRand.evaluate(org.apache.hadoop.io.LongWritable) on object org.apache.hadoop.hive.ql.udf.UDFRand@37a2b47b of class org.apache.hadoop.hive.ql.udf.UDFRand with arguments {null} of size 1 (state=,code=0) > {code} > Stack trace: > {code} > Caused by: java.lang.reflect.InvocationTargetException > at sun.reflect.GeneratedMethodAccessor79.invoke(Unknown Source) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:498) > at org.apache.hadoop.hive.ql.exec.FunctionRegistry.invoke(FunctionRegistry.java:1010) > ... 36 more > Caused by: java.lang.NullPointerException > at org.apache.hadoop.hive.ql.udf.UDFRand.evaluate(UDFRand.java:57) > ... 40 more > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)