spark-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hyukjin Kwon (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (SPARK-20528) Add BinaryFileReader and Writer for DataFrames
Date Wed, 11 Oct 2017 04:23:00 GMT

    [ https://issues.apache.org/jira/browse/SPARK-20528?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16199788#comment-16199788
] 

Hyukjin Kwon edited comment on SPARK-20528 at 10/11/17 4:22 AM:
----------------------------------------------------------------

The Scala one in the JIRA description looks not working BTW in the current master:

{code}
scala> val binaryFilesRDD = sc.binaryFiles("README.md")
binaryFilesRDD: org.apache.spark.rdd.RDD[(String, org.apache.spark.input.PortableDataStream)]
= mypath BinaryFileRDD[0] at binaryFiles at <console>:24

scala> val binaryFilesDF = spark.createDataFrame(binaryFilesRDD)
java.lang.UnsupportedOperationException: No Encoder found for org.apache.spark.input.PortableDataStream
- field (class: "org.apache.spark.input.PortableDataStream", name: "_2")
- root class: "scala.Tuple2"
{code}


was (Author: hyukjin.kwon):
The Scala one looks not working BTW in the current master:

{code}
scala> val binaryFilesRDD = sc.binaryFiles("README.md")
binaryFilesRDD: org.apache.spark.rdd.RDD[(String, org.apache.spark.input.PortableDataStream)]
= mypath BinaryFileRDD[0] at binaryFiles at <console>:24

scala> val binaryFilesDF = spark.createDataFrame(binaryFilesRDD)
java.lang.UnsupportedOperationException: No Encoder found for org.apache.spark.input.PortableDataStream
- field (class: "org.apache.spark.input.PortableDataStream", name: "_2")
- root class: "scala.Tuple2"
{code}

> Add BinaryFileReader and Writer for DataFrames
> ----------------------------------------------
>
>                 Key: SPARK-20528
>                 URL: https://issues.apache.org/jira/browse/SPARK-20528
>             Project: Spark
>          Issue Type: New Feature
>          Components: SQL
>    Affects Versions: 2.2.0
>            Reporter: Joseph K. Bradley
>
> It would be very useful to have a binary data reader/writer for DataFrames, presumably
called via {{spark.read.binaryFiles}}, etc.
> Currently, going through RDDs is annoying since it requires different code paths for
Scala vs Python:
> Scala:
> {code}
> val binaryFilesRDD = sc.binaryFiles("mypath")
> val binaryFilesDF = spark.createDataFrame(binaryFilesRDD)
> {code}
> Python:
> {code}
> binaryFilesRDD = sc.binaryFiles("mypath")
> binaryFilesRDD_recast = binaryFilesRDD.map(lambda x: (x[0], bytearray(x[1])))
> binaryFilesDF = spark.createDataFrame(binaryFilesRDD_recast)
> {code}
> This is because Scala and Python {{sc.binaryFiles}} return different types, which makes
sense in RDD land but not DataFrame land.
> My motivation here is working with images in Spark.



--
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


Mime
View raw message