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 ED169200CF8 for ; Thu, 14 Sep 2017 17:38:03 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id EB4091609CD; Thu, 14 Sep 2017 15:38:03 +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 3D47B1609CC for ; Thu, 14 Sep 2017 17:38:03 +0200 (CEST) Received: (qmail 32026 invoked by uid 500); 14 Sep 2017 15:38:02 -0000 Mailing-List: contact issues-help@spark.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list issues@spark.apache.org Received: (qmail 32016 invoked by uid 99); 14 Sep 2017 15:38:02 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Sep 2017 15:38:02 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id E76111A4B71 for ; Thu, 14 Sep 2017 15:38:01 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.002 X-Spam-Level: X-Spam-Status: No, score=-100.002 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id xTe96Jl2WNXL for ; Thu, 14 Sep 2017 15:38:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id EA5C25FDBC for ; Thu, 14 Sep 2017 15:38:00 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 6A957E0E74 for ; Thu, 14 Sep 2017 15:38:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 1FBAE25386 for ; Thu, 14 Sep 2017 15:38:00 +0000 (UTC) Date: Thu, 14 Sep 2017 15:38:00 +0000 (UTC) From: "Dongjoon Hyun (JIRA)" To: issues@spark.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (SPARK-21858) Make Spark grouping_id() compatible with Hive grouping__id MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 14 Sep 2017 15:38:04 -0000 [ https://issues.apache.org/jira/browse/SPARK-21858?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D161= 66467#comment-16166467 ]=20 Dongjoon Hyun commented on SPARK-21858: --------------------------------------- Thank you for conclusion, [~cloud_fan]! > Make Spark grouping_id() compatible with Hive grouping__id > ---------------------------------------------------------- > > Key: SPARK-21858 > URL: https://issues.apache.org/jira/browse/SPARK-21858 > Project: Spark > Issue Type: Bug > Components: SQL > Affects Versions: 2.2.0 > Reporter: Yann Byron > > If you want to migrate some ETLs using `grouping__id` in Hive to Spark an= d use Spark `grouping_id()` instead of Hive `grouping__id`, you will find d= ifference between their evaluations. > Here is an example. > {code:java} > select A, B, grouping__id/grouping_id() from t group by A, B grouping set= s((), (A), (B), (A,B)) > {code} > Running it on Hive and Spark separately, you'll find this: (the selected = attribute in selected grouping set is represented by (/) and otherwise by = (x)) > ||A B||Binary Expression in Spark||Spark||Hive||Binary Expression in Hive= ||B A|| > |(x) (x)|11|3|0|00|(x) (x)| > |(x) (/)|10|2|2|10|(/) (x)| > |(/) (x)|01|1|1|01|(x) (/)| > |(/) (/)|00|0|3|11|(/) (/)| > As shown above=EF=BC=8CIn Hive, (/) set to 0, (x) set to 1, and in Spark = it's opposite. > Moreover, attributes in `group by` will reverse firstly in Hive. In Spark= it'll be evaluated directly. > In my opinion, I suggest that modifying the behavior of `grouping_id()` m= ake it compatible with Hive `grouping__id`. -- This message was sent by Atlassian JIRA (v6.4.14#64029) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org For additional commands, e-mail: issues-help@spark.apache.org