Return-Path: X-Original-To: apmail-hive-user-archive@www.apache.org Delivered-To: apmail-hive-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B9AB19FC0 for ; Tue, 29 May 2012 13:58:20 +0000 (UTC) Received: (qmail 19728 invoked by uid 500); 29 May 2012 13:58:19 -0000 Delivered-To: apmail-hive-user-archive@hive.apache.org Received: (qmail 19681 invoked by uid 500); 29 May 2012 13:58:19 -0000 Mailing-List: contact user-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hive.apache.org Delivered-To: mailing list user@hive.apache.org Received: (qmail 19673 invoked by uid 99); 29 May 2012 13:58:19 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 May 2012 13:58:19 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of edlinuxguru@gmail.com designates 209.85.161.176 as permitted sender) Received: from [209.85.161.176] (HELO mail-gg0-f176.google.com) (209.85.161.176) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 May 2012 13:58:15 +0000 Received: by ggnk4 with SMTP id k4so3257966ggn.35 for ; Tue, 29 May 2012 06:57:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=iv0N6IFaDj/p7HVe3JFpO8ti/pAp4DoeanbDXl+uxuw=; b=wpGEGKBMEE+rQyFP3SZxtWwaPwy4aiVYkzbTDIl6s0lERUgy05JfWxvHyiUKrNDpsz 9VEsze9NVFRsAmK0R0r6z+GZyY97EzS0S0F4YOUlbG5UZvPmRFEnOl6QSYKFn6Sd+r8y Z88ozyjdBvsNfJtlhU018SzOo2xw2MuBjTD45hXqAxy1M0mHJhx+BT1Gc8+M6pWWkRm4 +wRlocQWHlY7hkXskJLjvX/apYi48f6diGRr5ArSNVE5ErScnwA1DrcbftLvkRDIhWLI 3RrVgP2GPdKTWCdgqDUWNrtGzAJNViOIsAPE8U/h5VhYec7NTSG4VaOfVctmrE3/RA50 dhwQ== MIME-Version: 1.0 Received: by 10.50.191.200 with SMTP id ha8mr7524177igc.45.1338299874089; Tue, 29 May 2012 06:57:54 -0700 (PDT) Received: by 10.64.18.176 with HTTP; Tue, 29 May 2012 06:57:54 -0700 (PDT) In-Reply-To: References: Date: Tue, 29 May 2012 09:57:54 -0400 Message-ID: Subject: Re: GenericUdf and Jdbc issues From: Edward Capriolo To: user@hive.apache.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org So..... this.getResourceAsStream(filename) is a very tricky method to get right especially in hive which you have the hive-classpath, the hadoop-classpath, the hive-jdbc classpath. Especially when you consider that launched map/reduce tasks get there own environment and classpath. I had the same issues when I was writing my geo-ip-udf. See the comments. https://github.com/edwardcapriolo/hive-geoip/blob/master/src/main/java/com/= jointhegrid/udf/geoip/GenericUDFGeoIP.java I came to the conclusion that if you add a file to the distributed cache using 'ADD FILE' You can reliably assume it will be in the current working directory and this works. File f =3D new File(database); I hope this helps. Edward On Tue, May 29, 2012 at 8:35 AM, Maoz Gelbart wr= ote: > Hi all, > > > > I am using Hive 0.7.1 over Cloudera=92s Hadoop distribution 0.20.2 and Ma= pR > hdfs distribution 1.1.1. > > I wrote a GenericUDF packaged as a Jar that attempts to open a local > resource during its initialization at initialize(ObjectInspector[] > arguments) command. > > > > When I run with the CLI, everything is fine. > > When I run using Cloudera=92s Hive-JDBC driver, The UDF fails with null > pointer returned from the command this.getResourceAsStream(filename). > > Removing the line fixed the problem and the UDF ran on both CLI and Jdbc,= so > I believe that =93ADD JAR=94 and =93CREATE TEMPORARY FUNCTION=94 were ent= ered > correctly. > > > > Did anyone observe such a behavior? I have a demo Jar to reproduce the > problem if needed. > > > > Thanks, > > Maoz