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 A7B68200BD8 for ; Wed, 7 Dec 2016 18:32:00 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id A66E1160B2B; Wed, 7 Dec 2016 17:32:00 +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 00B35160AF9 for ; Wed, 7 Dec 2016 18:31:59 +0100 (CET) Received: (qmail 22732 invoked by uid 500); 7 Dec 2016 17:31:59 -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 22712 invoked by uid 99); 7 Dec 2016 17:31:59 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Dec 2016 17:31:59 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 132752C0086 for ; Wed, 7 Dec 2016 17:31:59 +0000 (UTC) Date: Wed, 7 Dec 2016 17:31:59 +0000 (UTC) From: "Herman van Hovell (JIRA)" To: issues@spark.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (SPARK-17760) DataFrame's pivot doesn't see column created in groupBy MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 07 Dec 2016 17:32:00 -0000 [ https://issues.apache.org/jira/browse/SPARK-17760?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Herman van Hovell updated SPARK-17760: -------------------------------------- Fix Version/s: 2.0.3 > DataFrame's pivot doesn't see column created in groupBy > ------------------------------------------------------- > > Key: SPARK-17760 > URL: https://issues.apache.org/jira/browse/SPARK-17760 > Project: Spark > Issue Type: Bug > Components: PySpark > Affects Versions: 2.0.0 > Environment: Databrick's community version, spark 2.0.0, pyspark, python 2. > Reporter: Alberto Bonsanto > Assignee: Andrew Ray > Labels: easytest, newbie > Fix For: 2.0.3, 2.1.0 > > > Related to [https://stackoverflow.com/questions/39817993/pivoting-with-missing-values]. I'm not completely sure if this is a bug or expected behavior. > When you `groypBy` by a column generated inside of it, the `pivot` method apparently doesn't find this column during the analysis. > E.g. > {code:none} > df = (sc.parallelize([(1.0, "2016-03-30 01:00:00"), > (30.2, "2015-01-02 03:00:02")]) > .toDF(["amount", "Date"]) > .withColumn("Date", col("Date").cast("timestamp"))) > (df.withColumn("hour",hour("date")) > .groupBy(dayofyear("date").alias("date")) > .pivot("hour").sum("amount").show()){code} > Shows the following exception. > {quote} > AnalysisException: u'resolved attribute(s) date#140688 missing from dayofyear(date)#140994,hour#140977,sum(`amount`)#140995 in operator !Aggregate \[dayofyear(cast(date#140688 as date))], [dayofyear(cast(date#140688 as date)) AS dayofyear(date)#140994, pivotfirst(hour#140977, sum(`amount`)#140995, 1, 3, 0, 0) AS __pivot_sum(`amount`) AS `sum(``amount``)`#141001\];' > {quote} > To solve it you have to add the column {{date}} before grouping and pivoting. -- 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