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 08441200CA6 for ; Tue, 13 Jun 2017 15:02:06 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 06830160BE9; Tue, 13 Jun 2017 13:02:06 +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 4DA5F160BC9 for ; Tue, 13 Jun 2017 15:02:05 +0200 (CEST) Received: (qmail 3424 invoked by uid 500); 13 Jun 2017 13:02:04 -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 3409 invoked by uid 99); 13 Jun 2017 13:02:04 -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; Tue, 13 Jun 2017 13:02:04 +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 07241C0335 for ; Tue, 13 Jun 2017 13:02:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id CWAXGVCwzAwE for ; Tue, 13 Jun 2017 13:02:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 5C9375FD83 for ; Tue, 13 Jun 2017 13:02:01 +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 995D8E0933 for ; Tue, 13 Jun 2017 13:02: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 218E421E0E for ; Tue, 13 Jun 2017 13:02:00 +0000 (UTC) Date: Tue, 13 Jun 2017 13:02:00 +0000 (UTC) From: "Michel Lemay (JIRA)" To: issues@spark.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (SPARK-21021) Reading partitioned parquet does not respect specified schema column order MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 13 Jun 2017 13:02:06 -0000 [ https://issues.apache.org/jira/browse/SPARK-21021?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16047849#comment-16047849 ] Michel Lemay edited comment on SPARK-21021 at 6/13/17 1:01 PM: --------------------------------------------------------------- Yes, as a workaround, we do a {code}df.select(schema.fieldNames.head, schema.fieldNames.tail: _*){code} However, I think that the reader should respect schema column order even in the case of partitions. something like `dataSchema ++ (partitionSchema - dataSchema)` was (Author: flamingmike): Yes, as a workaround, we do a `df.select(schema.fieldNames.head, schema.fieldNames.tail: _*)` However, I think that the reader should respect schema column order even in the case of partitions. something like `dataSchema ++ (partitionSchema - dataSchema)` > Reading partitioned parquet does not respect specified schema column order > -------------------------------------------------------------------------- > > Key: SPARK-21021 > URL: https://issues.apache.org/jira/browse/SPARK-21021 > Project: Spark > Issue Type: Bug > Components: SQL > Affects Versions: 2.1.0 > Reporter: Michel Lemay > Priority: Minor > > When reading back a partitioned parquet folder, column order gets messed up. > Consider the following example: > {code} > case class Event(f1: String, f2: String, f3: String) > val df = Seq(Event("v1", "v2", "v3")).toDF > df.write.partitionBy("f1", "f2").parquet("out") > val schema: StructType = StructType(StructField("f1", StringType, true) :: StructField("f2", StringType, true) :: StructField("f3", StringType, true) :: Nil) > val dfRead = spark.read.schema(schema).parquet("out") > dfRead.show > +---+---+---+ > | f3| f1| f2| > +---+---+---+ > | v3| v1| v2| > +---+---+---+ > dfRead.columns > Array[String] = Array(f3, f1, f2) > schema.fields > Array(StructField(f1,StringType,true), StructField(f2,StringType,true), StructField(f3,StringType,true)) > {code} > This makes it really hard to have compatible schema when reading from multiple sources. -- 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