From issues-return-118917-archive-asf-public=cust-asf.ponee.io@hive.apache.org Fri May 18 20:09:07 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 3F025180648 for ; Fri, 18 May 2018 20:09:07 +0200 (CEST) Received: (qmail 82701 invoked by uid 500); 18 May 2018 18:09:06 -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 82692 invoked by uid 99); 18 May 2018 18:09:06 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 May 2018 18:09:06 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id C58F3C0148 for ; Fri, 18 May 2018 18:09:05 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -109.511 X-Spam-Level: X-Spam-Status: No, score=-109.511 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id n_D_gKf0z52F for ; Fri, 18 May 2018 18:09: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 E75785F2C4 for ; Fri, 18 May 2018 18:09: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 84F95E02EB for ; Fri, 18 May 2018 18:09: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 4EF8D217A2 for ; Fri, 18 May 2018 18:09:00 +0000 (UTC) Date: Fri, 18 May 2018 18:09:00 +0000 (UTC) From: "Ashutosh Chauhan (JIRA)" To: issues@hive.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (HIVE-19586) Optimize Count(distinct X) pushdown based on the storage capabilities MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HIVE-19586?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Ashutosh Chauhan updated HIVE-19586: ------------------------------------ Target Version/s: 3.1.0 Fix Version/s: (was: 3.0.0) > Optimize Count(distinct X) pushdown based on the storage capabilities > ---------------------------------------------------------------------- > > Key: HIVE-19586 > URL: https://issues.apache.org/jira/browse/HIVE-19586 > Project: Hive > Issue Type: Improvement > Components: Druid integration, Logical Optimizer > Reporter: slim bouguerra > Assignee: slim bouguerra > Priority: Major > Attachments: HIVE-19586.2.patch, HIVE-19586.patch > > > h1. Goal > Provide a way to rewrite queries with combination of COUNT(Distinct) and Aggregates like SUM as a series of Group By. > This can be useful to push down to Druid queries like > {code} > select count(DISTINCT interval_marker), count (distinct dim), sum(num_l) FROM druid_test_table GROUP BY `__time`, `zone` ; > {code} > In general this can be useful to be used in cases where storage handlers can not perform count (distinct column) > h1. How to do it. > Use the Calcite rule {code} org.apache.calcite.rel.rules.AggregateExpandDistinctAggregatesRule{code} that breaks down Count distinct to a single Group by with Grouping sets or multiple series of Group by that might be linked with Joins if multiple counts are present. > FYI today Hive does have a similar rule {code} org.apache.hadoop.hive.ql.optimizer.calcite.rules.HiveExpandDistinctAggregatesRule{code}, but it only provides a rewrite to Grouping sets based plan. > I am planing to use the actual Calcite rule, [~ashutoshc] any concerns or caveats to be aware of? > h2. Concerns/questions > Need to have a way to switch between Grouping sets or Simple chained group by based on the plan cost. For instance for Druid based scan it makes always sense (at least today) to push down a series of Group by and stitch result sets in Hive later (as oppose to scan everything). > But this might be not true for other storage handler that can handle Grouping sets it is better to push down the Grouping sets as one table scan. > Am still unsure how i can lean on the cost optimizer to select the best plan, [~ashutoshc]/[~jcamachorodriguez] any inputs? -- This message was sent by Atlassian JIRA (v7.6.3#76005)