Return-Path: X-Original-To: apmail-spark-issues-archive@minotaur.apache.org Delivered-To: apmail-spark-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8845619D4A for ; Fri, 22 Apr 2016 16:21:13 +0000 (UTC) Received: (qmail 2277 invoked by uid 500); 22 Apr 2016 16:21:13 -0000 Delivered-To: apmail-spark-issues-archive@spark.apache.org Received: (qmail 2236 invoked by uid 500); 22 Apr 2016 16:21:13 -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 2220 invoked by uid 99); 22 Apr 2016 16:21:13 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 22 Apr 2016 16:21:13 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id D8B8B2C1F4E for ; Fri, 22 Apr 2016 16:21:12 +0000 (UTC) Date: Fri, 22 Apr 2016 16:21:12 +0000 (UTC) From: "Davies Liu (JIRA)" To: issues@spark.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (SPARK-13266) Python DataFrameReader converts None to "None" instead of null 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/SPARK-13266?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Davies Liu updated SPARK-13266: ------------------------------- Assignee: Liang-Chi Hsieh > Python DataFrameReader converts None to "None" instead of null > -------------------------------------------------------------- > > Key: SPARK-13266 > URL: https://issues.apache.org/jira/browse/SPARK-13266 > Project: Spark > Issue Type: Bug > Components: PySpark, SQL > Affects Versions: 1.6.0 > Environment: Linux standalone but probably applies to all > Reporter: mathieu longtin > Assignee: Liang-Chi Hsieh > Labels: easyfix, patch > Fix For: 2.0.0 > > > If you do something like this: > {code:none} > tsv_loader = sqlContext.read.format('com.databricks.spark.csv') > tsv_loader.options(quote=None, escape=None) > {code} > The loader sees the string "None" as the _quote_ and _escape_ options. The loader should get a _null_. > An easy fix is to modify *python/pyspark/sql/readwriter.py* near the top, correct the _to_str_ function. Here's the patch: > {code:none} > diff --git a/python/pyspark/sql/readwriter.py b/python/pyspark/sql/readwriter.py > index a3d7eca..ba18d13 100644 > --- a/python/pyspark/sql/readwriter.py > +++ b/python/pyspark/sql/readwriter.py > @@ -33,10 +33,12 @@ __all__ = ["DataFrameReader", "DataFrameWriter"] > def to_str(value): > """ > - A wrapper over str(), but convert bool values to lower case string > + A wrapper over str(), but convert bool values to lower case string, and keep None > """ > if isinstance(value, bool): > return str(value).lower() > + elif value is None: > + return value > else: > return str(value) > {code} > This has been tested and works great. -- 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