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 A3ADC200B0F for ; Thu, 2 Jun 2016 12:12:01 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id A2CDB160A3F; Thu, 2 Jun 2016 10:12:01 +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 8F1A5160A56 for ; Thu, 2 Jun 2016 12:12:00 +0200 (CEST) Received: (qmail 58588 invoked by uid 500); 2 Jun 2016 10:11:59 -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 58526 invoked by uid 99); 2 Jun 2016 10:11:59 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Jun 2016 10:11:59 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 8C4822C1F77 for ; Thu, 2 Jun 2016 10:11:59 +0000 (UTC) Date: Thu, 2 Jun 2016 10:11:59 +0000 (UTC) From: "Jesus Camacho Rodriguez (JIRA)" To: issues@hive.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (HIVE-13414) Analytic functions windowing (preceding/following) does not work has expected MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 02 Jun 2016 10:12:01 -0000 [ https://issues.apache.org/jira/browse/HIVE-13414?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Jesus Camacho Rodriguez updated HIVE-13414: ------------------------------------------- Fix Version/s: (was: 2.1.0) > Analytic functions windowing (preceding/following) does not work has expected > ------------------------------------------------------------------------------ > > Key: HIVE-13414 > URL: https://issues.apache.org/jira/browse/HIVE-13414 > Project: Hive > Issue Type: Bug > Components: PTF-Windowing > Affects Versions: 0.14.0 > Reporter: Dudu Markovitz > > "min (j) over (order by i rows between 1 preceding and 1 preceding)" > is logically equal to > "lag (j) over (order by i)" > "min (j) over (order by i rows between 1 following and 1 following)" > is logically equal to > "lead (j) over (order by i)" > Has can be seen in the following examples lag/lead works fine but the logically equivalent syntax that uses preceding/following returns wrong results. > $ cat>t.txt > 23,29 > 84,15 > 58,19 > 81,17 > 48,15 > 36,49 > 91,26 > 89,22 > 63,57 > 33,10 > $ hdfs dfs -mkdir /user/dmarkovitz/t > $ hdfs dfs -put t.txt /user/dmarkovitz/t > $ hive > hive> create external table t (i int,j int) row format delimited fields terminated by ',' location '/user/dmarkovitz/t'; > hive> select * from t; > 23 29 > 84 15 > 58 19 > 81 17 > 48 15 > 36 49 > 91 26 > 89 22 > 63 57 > 33 10 > hive> select i,j,lag (j) over (order by i) as lag,min (j) over (order by i rows between 1 preceding and 1 preceding) as pseudo_lag from t; > 23 29 NULL 10 > 33 10 29 10 > 36 49 10 10 > 48 15 49 15 > 58 19 15 15 > 63 57 19 17 > 81 17 57 15 > 84 15 17 15 > 89 22 15 15 > 91 26 22 22 > hive> select i,j,lead (j) over (order by i) as lead,min (j) over (order by i rows between 1 following and 1 following) as pseudo_lead from t order by i; > 23 29 10 10 > 33 10 49 10 > 36 49 15 10 > 48 15 19 15 > 58 19 57 15 > 63 57 17 17 > 81 17 15 15 > 84 15 22 15 > 89 22 26 15 > 91 26 NULL 22 -- This message was sent by Atlassian JIRA (v6.3.4#6332)