From issues-return-202889-archive-asf-public=cust-asf.ponee.io@spark.apache.org Tue Sep 25 04:38:05 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 D3EAB18067B for ; Tue, 25 Sep 2018 04:38:04 +0200 (CEST) Received: (qmail 7317 invoked by uid 500); 25 Sep 2018 02:38:03 -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 7308 invoked by uid 99); 25 Sep 2018 02:38:03 -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; Tue, 25 Sep 2018 02:38:03 +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 76F5E1A039D for ; Tue, 25 Sep 2018 02:38:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -109.501 X-Spam-Level: X-Spam-Status: No, score=-109.501 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, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id GXj243rIU2hQ for ; Tue, 25 Sep 2018 02:38: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 AA80A5F4DA for ; Tue, 25 Sep 2018 02:38: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 D5758E0E5D for ; Tue, 25 Sep 2018 02: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 2E87F23F9F for ; Tue, 25 Sep 2018 02:38:00 +0000 (UTC) Date: Tue, 25 Sep 2018 02:38:00 +0000 (UTC) From: "Apache Spark (JIRA)" To: issues@spark.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Assigned] (SPARK-25517) Spark DataFrame option inferSchema="true", dataFormat=MM/dd/yyyy, fails to detect date type from the csv file while reading MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/SPARK-25517?page=3Dcom.atlassi= an.jira.plugin.system.issuetabpanels:all-tabpanel ] Apache Spark reassigned SPARK-25517: ------------------------------------ Assignee: Apache Spark > Spark DataFrame option inferSchema=3D"true", dataFormat=3DMM/dd/yyyy, fai= ls to detect date type from the csv file while reading > -------------------------------------------------------------------------= -------------------------------------------------- > > Key: SPARK-25517 > URL: https://issues.apache.org/jira/browse/SPARK-25517 > Project: Spark > Issue Type: Bug > Components: SQL > Affects Versions: 2.3.0, 2.3.1 > Environment: Spark 2.3.0 > Reporter: Manoranjan Kumar > Assignee: Apache Spark > Priority: Major > Labels: easyfix > Original Estimate: 48h > Remaining Estimate: 48h > > spark.read.format("csv").option("inferSchema", true).option("dateFormat",= "MM/dd/yyyy") fails to detect or infer the date type=C2=A0while reading th= e csv file having date column in the specified format(MM/dd/yyyy) > For example:- > An employee csv file (employee.csv) has following two sample dummy record= s (with header): > emp_id,emp_name,joining_date,emp_age, emp_in_time,emp_salary > 100,Bradd Pitt,{color:#f6c342}09/25/2018{color},26,{color:#f691b2}09/25/2= 018 10:12:36{color},10000.00 > 101,Angel Joli,{color:#f6c342}08/20/2018{color},28,{color:#f691b2}08/20/2= 018 11:32:58{color},12000.00 > when I read the above csv file as dataframe like below:=20 > val empDF =3D spark.read.format("csv").option("inferSchema", true).option= ("dateFormat","MM/dd/yyyy").option("timestampFormat","MM/dd/yyyy HH:mm:ss")= .load(employee.csv) > empDF.printSchema() > results/output: > root > |-- emp_id: integer (nullable =3D true) > |-- emp_name: string (nullable =3D true) > |-- {color:#d04437}joining_date: string{color} (nullable =3D true) > |-- emp_age: integer (nullable =3D true) > |-- {color:#d04437}emp_in_time: timestamp{color} (nullable =3D true) > |-- emp_salary: double (nullable =3D true) > Please notice above (marked in {color:#d04437}red{color} color) the data = type automatically inferred by spark for joining_date and emp_in_time, for = joining_date, it fails to detect as date type and the type remains as {colo= r:#d04437}string{color} as it is, whereas it detects well for emp_in_time a= s {color:#d04437}timestamp{color} > This was the issue that I struggled with for a complete day, and when I d= ived deep into the spark source code, i found the implementation for date t= ype is missing whereas the implementation for timestamp is present in all i= ts glory. > I am new to this place (exactly first timer), please get back in case of = further information or live example with running code. -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org For additional commands, e-mail: issues-help@spark.apache.org