Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,12 @@ final class DataFrameWriter private[sql](df: DataFrame) {
* format("parquet").save(path)
* }}}
*
* You can set the following JSON-specific options for writing JSON files:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it's in the wrong place?

* <li>`compression` or `codec` (default `null`): compression codec to use when saving to file.
* This should be the fully qualified name of a class implementing
* [[org.apache.hadoop.io.compress.CompressionCodec]] or one of the known case-insensitive
* shorten names(`bzip2`, `gzip`, `lz4`, and `snappy`). </li>
*
* @since 1.4.0
*/
def parquet(path: String): Unit = format("parquet").save(path)
Expand Down Expand Up @@ -492,10 +498,33 @@ final class DataFrameWriter private[sql](df: DataFrame) {
* df.write().text("/path/to/output")
* }}}
*
* You can set the following options for writing text files:
* <li>`compression` or `codec` (default `null`): compression codec to use when saving to file.
* This should be the fully qualified name of a class implementing
* [[org.apache.hadoop.io.compress.CompressionCodec]] or one of the known case-insensitive
* shorten names(`bzip2`, `gzip`, `lz4`, and `snappy`). </li>
*
* @since 1.6.0
*/
def text(path: String): Unit = format("text").save(path)

/**
* Saves the content of the [[DataFrame]] in CSV format at the specified path.
* This is equivalent to:
* {{{
* format("csv").save(path)
* }}}
*
* You can set the following CSV-specific options for writing CSV files:
* <li>`compression` or `codec` (default `null`): compression codec to use when saving to file.
* This should be the fully qualified name of a class implementing
* [[org.apache.hadoop.io.compress.CompressionCodec]] or one of the known case-insensitive
* shorten names(`bzip2`, `gzip`, `lz4`, and `snappy`). </li>
*
* @since 2.0.0
*/
def csv(path: String): Unit = format("csv").save(path)

///////////////////////////////////////////////////////////////////////////////////////
// Builder pattern config options
///////////////////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,8 @@ class CSVSuite extends QueryTest with SharedSQLContext with SQLTestUtils {
.load(testFile(carsFile))

cars.coalesce(1).write
.format("csv")
.option("header", "true")
.save(csvDir)
.csv(csvDir)

val carsCopy = sqlContext.read
.format("csv")
Expand Down