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 42F8D117A0 for ; Wed, 23 Jul 2014 05:35:07 +0000 (UTC) Received: (qmail 55306 invoked by uid 500); 23 Jul 2014 05:35:05 -0000 Delivered-To: apmail-hive-user-archive@hive.apache.org Received: (qmail 55230 invoked by uid 500); 23 Jul 2014 05:35:05 -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 55220 invoked by uid 99); 23 Jul 2014 05:35:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Jul 2014 05:35:05 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of dingguitao@baixing.com designates 209.85.192.44 as permitted sender) Received: from [209.85.192.44] (HELO mail-qg0-f44.google.com) (209.85.192.44) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Jul 2014 05:35:00 +0000 Received: by mail-qg0-f44.google.com with SMTP id e89so847328qgf.17 for ; Tue, 22 Jul 2014 22:34:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to :content-type; bh=7pH9RfGgPZ93J34AnSET6WnE2H/5/CQtNRlZipVmgz0=; b=VXujhTLg2sOUp/fM8bKgsPjP5tD4lQQ19KyDNSF16lcLmrNEgANUaMymCYjtvWQwiI 0TLEgi0NJqNtzdYylYAFYymRjcFHNBBUG79TKIIEerx4FNrrGElc3pTRYxL6xI5JCt+w tP+gg/L4ZjjfZaMl51hT7MYHDVYAJQxdLiIE5iYkvcbJAi2QyMWUszj78b7ur71sjPRd NOr1xdR7HOBkId2xuycX3gbTzX3v5VNjfFp9TmeWsh6f5o9OL0SgcRdHRBhn5IAun4q4 kuSS1MLa4ob4vIWgTyDvXZP6w5QtfetuS6jzMJAB3BHWd75AIXVbtEyREr/Ap2tpYTzS 1Nyw== X-Gm-Message-State: ALoCoQl+ttynVvvCS2S1Yo6bbpA/LG8kpfyWzpj537i3sNhtWS+rlEHVZbW42yn0BknAkIDHMass X-Received: by 10.224.54.136 with SMTP id q8mr46890533qag.79.1406093679289; Tue, 22 Jul 2014 22:34:39 -0700 (PDT) MIME-Version: 1.0 Received: by 10.96.92.103 with HTTP; Tue, 22 Jul 2014 22:34:19 -0700 (PDT) From: =?UTF-8?B?5LiB5qGC5rab77yI5qGC6Iqx77yJ?= Date: Wed, 23 Jul 2014 13:34:19 +0800 Message-ID: Subject: Hive UDF gives duplicate result regardless of parameters, when nested in a subquery To: user@hive.apache.org Content-Type: multipart/alternative; boundary=001a11c31f0246723104fed5b292 X-Virus-Checked: Checked by ClamAV on apache.org --001a11c31f0246723104fed5b292 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Recently I developed a Hive Generic UDF *getad*. It accepts a map type and a string type parameter and outputs a string value. But I found the UDF output really confusing in different conditions. Condition A: select getad(map_col, 'tp') as tp, getad(map_col, 'p') as p, getad(map_col, 'sp') as sp from table_name where id =3D xxxx; The output is right: 'tp', 'p', 'sp'. Condition B: select array(tp, p, sp) as ps from ( select getad(map_col, 'tp') as tp, getad(map_col, 'p') as p, getad(map_col, 'sp') as sp from table_name where id =3D xxxx ) t; The output is wrong: 'tp', 'tp', 'tp'. And the following query outputs the same result: select array( getad(map_col, 'tp'), getad(map_col, 'p'), getad(map_col, 'sp') ) as ps from table_name where id =3D xxxx; Could you please provide me some hints on this? Thanks! --=20 =E4=B8=81=E6=A1=82=E6=B6=9B --001a11c31f0246723104fed5b292 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

Recently I developed a Hive Generic UDF=C2=A0getad= . It accepts a map type and a string type parameter and outputs a string va= lue. But I found the UDF output really confusing in different conditions.

Condition A:


select
  getad(map_col, 'tp') as tp,
  getad(map_col, 'p') as p,
  getad(map_col, 'sp') as sp
from
  table_name
where
  id =3D xxxx;

The output is right: 'tp', 'p', 'sp'.

Condition B:


select
  array(tp, p, sp) as ps
from
  (
  select
    getad(map_col, 'tp') as tp,
    getad(map_col, 'p') as p,
    getad(map_col, 'sp') as sp
  from
    table_name
  where
    id =3D xxxx
  ) t;

The output is wrong: 'tp', 'tp', 'tp'. And the foll= owing query outputs the same result:


select
  array(
    getad(map_col, 'tp'),
    getad(map_col, 'p'),
    getad(map_col, 'sp')
  ) as ps
from
  table_name
where
  id =3D xxxx;

Could you please provide me some hints on this? Thanks!


-= -
=E4=B8=81=E6=A1=82=E6=B6=9B
--001a11c31f0246723104fed5b292--