GitHub user HyukjinKwon opened a pull request:
https://github.com/apache/spark/pull/13254
[SPARK-15475][SQL] Support for reading text data source without specifying
schema
## What changes were proposed in this pull request?
Currently, Text data source requires a schema.
So the codes below:
```scala
emptyDf.write
.format("text")
.save(path.getCanonicalPath)
val copyEmptyDf = spark.read
.format("text")
.load(path.getCanonicalPath)
copyEmptyDf.show()
```
throws an exception below:
```scala
key not found: dataSchema
java.util.NoSuchElementException: key not found: dataSchema
at scala.collection.MapLike$class.default(MapLike.scala:228)
at
org.apache.spark.sql.execution.datasources.CaseInsensitiveMap.default(ddl.scala:139)
at scala.collection.MapLike$class.apply(MapLike.scala:141)
at
org.apache.spark.sql.execution.datasources.CaseInsensitiveMap.apply(ddl.scala:139)
at
org.apache.spark.sql.sources.SimpleTextSource.inferSchema(SimpleTextRelation.scala:43)
at
org.apache.spark.sql.execution.datasources.DataSource$$anonfun$15.apply(DataSource.scala:347)
at
org.apache.spark.sql.execution.datasources.DataSource$$anonfun$15.apply(DataSource.scala:347)
at scala.Option.orElse(Option.scala:289)
```
This PR adds the support for a default schema with unnamed columns just
like CSV data sources.
## How was this patch tested?
Unit test in `SimpleTextHadoopFsRelationSuite`.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/HyukjinKwon/spark text-msg
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/13254.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #13254
----
commit a542335f42956d63c7d4513bbaa9097406677c9d
Author: hyukjinkwon <[email protected]>
Date: 2016-05-22T13:09:17Z
Support for reading text data source without specifying schema
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]