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 34C70200B8E for ; Mon, 26 Sep 2016 23:09:22 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 33A04160AE3; Mon, 26 Sep 2016 21:09:22 +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 7BAD1160ACA for ; Mon, 26 Sep 2016 23:09:21 +0200 (CEST) Received: (qmail 7148 invoked by uid 500); 26 Sep 2016 21:09:20 -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 7139 invoked by uid 99); 26 Sep 2016 21:09:20 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Sep 2016 21:09:20 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 723E62C0032 for ; Mon, 26 Sep 2016 21:09:20 +0000 (UTC) Date: Mon, 26 Sep 2016 21:09:20 +0000 (UTC) From: "Xiao Li (JIRA)" To: issues@spark.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (SPARK-17653) Optimizer should remove unnecessary distincts (in multiple unions) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 26 Sep 2016 21:09:22 -0000 [ https://issues.apache.org/jira/browse/SPARK-17653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15524175#comment-15524175 ] Xiao Li commented on SPARK-17653: --------------------------------- Since Simon already submitted the PR, I will not continue the investigation. Thanks for answering my original question. > Optimizer should remove unnecessary distincts (in multiple unions) > ------------------------------------------------------------------ > > Key: SPARK-17653 > URL: https://issues.apache.org/jira/browse/SPARK-17653 > Project: Spark > Issue Type: Improvement > Components: SQL > Affects Versions: 2.0.0 > Reporter: Reynold Xin > > Query: > {code} > select 1 a union select 2 b union select 3 c > {code} > Explain plan: > {code} > == Physical Plan == > *HashAggregate(keys=[a#13], functions=[]) > +- Exchange hashpartitioning(a#13, 200) > +- *HashAggregate(keys=[a#13], functions=[]) > +- Union > :- *HashAggregate(keys=[a#13], functions=[]) > : +- Exchange hashpartitioning(a#13, 200) > : +- *HashAggregate(keys=[a#13], functions=[]) > : +- Union > : :- *Project [1 AS a#13] > : : +- Scan OneRowRelation[] > : +- *Project [2 AS b#14] > : +- Scan OneRowRelation[] > +- *Project [3 AS c#15] > +- Scan OneRowRelation[] > {code} > Only one distinct should be necessary. This makes a bunch of unions slower than a bunch of union alls followed by a distinct. -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org For additional commands, e-mail: issues-help@spark.apache.org