You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Sebb (JIRA)" <ji...@apache.org> on 2017/06/19 15:46:00 UTC

[jira] [Resolved] (CSV-212) Empty dataframe being written as an empty CSV, without header

     [ https://issues.apache.org/jira/browse/CSV-212?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sebb resolved CSV-212.
----------------------
    Resolution: Invalid

This may be an issue with Commons CSV or it may equally be a problem with Spark.

Please provide a stand-alone test case that does not rely on using Spark.



> Empty dataframe being written as an empty CSV, without header
> -------------------------------------------------------------
>
>                 Key: CSV-212
>                 URL: https://issues.apache.org/jira/browse/CSV-212
>             Project: Commons CSV
>          Issue Type: Bug
>    Affects Versions: 2.0
>            Reporter: Konrad Scorciapino
>            Priority: Minor
>
> On Spark 2.1. 
> How to reproduce:
> {{> $SPARK_HOME/bin/spark-shell
> ...
> scala> import spark.implicits._
> import spark.implicits._
> scala> val emptyDF = Seq[(Int)]().toDF("foo")
> emptyDF: org.apache.spark.sql.DataFrame = [foo: int]
> scala> emptyDF.write.option("header","true").csv("/tmp/emptyDF")
> scala> spark.read.option("header", "true").csv("/tmp/emptyDF")
> java.lang.UnsupportedOperationException: empty collection
>   at org.apache.spark.rdd.RDD$$anonfun$first$1.apply(RDD.scala:1369)
>   at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
>   at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:112)
>   at org.apache.spark.rdd.RDD.withScope(RDD.scala:362)
>   at org.apache.spark.rdd.RDD.first(RDD.scala:1366)
>   at org.apache.spark.sql.execution.datasources.csv.CSVFileFormat.findFirstLine(CSVFileFormat.scala:206)
>   at org.apache.spark.sql.execution.datasources.csv.CSVFileFormat.inferSchema(CSVFileFormat.scala:60)
>   at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$7.apply(DataSource.scala:184)
>   at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$7.apply(DataSource.scala:184)
>   at scala.Option.orElse(Option.scala:289)
>   at org.apache.spark.sql.execution.datasources.DataSource.org$apache$spark$sql$execution$datasources$DataSource$$getOrInferFileFormatSchema(DataSource.scala:183)
>   at org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:387)
>   at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:152)
>   at org.apache.spark.sql.DataFrameReader.csv(DataFrameReader.scala:415)
>   at org.apache.spark.sql.DataFrameReader.csv(DataFrameReader.scala:352)
>   ... 48 elided
> scala> :quit
> > ls -lh /tmp/emptyDF                                                                                                                                                                                         
> total 0
> -rw-r--r-- 1 konrad konrad 0 Jun 19 12:00 part-00000-523374b7-b117-4f36-a428-f43bcb405077.csv
> -rw-r--r-- 1 konrad konrad 0 Jun 19 12:00 _SUCCESS}}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)