|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object org.apache.spark.sql.DataFrameWriter
public final class DataFrameWriter
:: Experimental ::
Interface used to write a DataFrame
to external storage systems (e.g. file systems,
key-value stores, etc). Use DataFrame.write
to access this.
Method Summary | |
---|---|
DataFrameWriter |
format(String source)
Specifies the underlying output data source. |
void |
insertInto(String tableName)
Inserts the content of the DataFrame to the specified table. |
void |
jdbc(String url,
String table,
java.util.Properties connectionProperties)
Saves the content of the DataFrame to a external database table via JDBC. |
void |
json(String path)
Saves the content of the DataFrame in JSON format at the specified path. |
DataFrameWriter |
mode(SaveMode saveMode)
Specifies the behavior when data or table already exists. |
DataFrameWriter |
mode(String saveMode)
Specifies the behavior when data or table already exists. |
DataFrameWriter |
option(String key,
String value)
Adds an output option for the underlying data source. |
DataFrameWriter |
options(scala.collection.Map<String,String> options)
(Scala-specific) Adds output options for the underlying data source. |
DataFrameWriter |
options(java.util.Map<String,String> options)
Adds output options for the underlying data source. |
void |
parquet(String path)
Saves the content of the DataFrame in Parquet format at the specified path. |
DataFrameWriter |
partitionBy(scala.collection.Seq<String> colNames)
Partitions the output by the given columns on the file system. |
DataFrameWriter |
partitionBy(String... colNames)
Partitions the output by the given columns on the file system. |
void |
save()
Saves the content of the DataFrame as the specified table. |
void |
save(String path)
Saves the content of the DataFrame at the specified path. |
void |
saveAsTable(String tableName)
Saves the content of the DataFrame as the specified table. |
Methods inherited from class Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public DataFrameWriter partitionBy(String... colNames)
This is only applicable for Parquet at the moment.
colNames
- (undocumented)
public DataFrameWriter mode(SaveMode saveMode)
SaveMode.Overwrite
: overwrite the existing data.
- SaveMode.Append
: append the data.
- SaveMode.Ignore
: ignore the operation (i.e. no-op).
- SaveMode.ErrorIfExists
: default option, throw an exception at runtime.
saveMode
- (undocumented)
public DataFrameWriter mode(String saveMode)
overwrite
: overwrite the existing data.
- append
: append the data.
- ignore
: ignore the operation (i.e. no-op).
- error
: default option, throw an exception at runtime.
saveMode
- (undocumented)
public DataFrameWriter format(String source)
source
- (undocumented)
public DataFrameWriter option(String key, String value)
key
- (undocumented)value
- (undocumented)
public DataFrameWriter options(scala.collection.Map<String,String> options)
options
- (undocumented)
public DataFrameWriter options(java.util.Map<String,String> options)
options
- (undocumented)
public DataFrameWriter partitionBy(scala.collection.Seq<String> colNames)
This is only applicable for Parquet at the moment.
colNames
- (undocumented)
public void save(String path)
DataFrame
at the specified path.
path
- (undocumented)public void save()
DataFrame
as the specified table.
public void insertInto(String tableName)
DataFrame
to the specified table. It requires that
the schema of the DataFrame
is the same as the schema of the table.
Because it inserts data to an existing table, format or options will be ignored.
tableName
- (undocumented)public void saveAsTable(String tableName)
DataFrame
as the specified table.
In the case the table already exists, behavior of this function depends on the
save mode, specified by the mode
function (default to throwing an exception).
When mode
is Overwrite
, the schema of the DataFrame
does not need to be
the same as that of the existing table.
When mode
is Append
, the schema of the DataFrame
need to be
the same as that of the existing table, and format or options will be ignored.
tableName
- (undocumented)public void jdbc(String url, String table, java.util.Properties connectionProperties)
DataFrame
to a external database table via JDBC. In the case the
table already exists in the external database, behavior of this function depends on the
save mode, specified by the mode
function (default to throwing an exception).
Don't create too many partitions in parallel on a large cluster; otherwise Spark might crash your external database systems.
url
- JDBC database url of the form jdbc:subprotocol:subname
table
- Name of the table in the external database.connectionProperties
- JDBC database connection arguments, a list of arbitrary string
tag/value. Normally at least a "user" and "password" property
should be included.public void json(String path)
DataFrame
in JSON format at the specified path.
This is equivalent to:
format("json").save(path)
path
- (undocumented)public void parquet(String path)
DataFrame
in Parquet format at the specified path.
This is equivalent to:
format("parquet").save(path)
path
- (undocumented)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |