saveAsTable {SparkR}R Documentation

saveAsTable

Description

Save the contents of the DataFrame to a data source as a table

Usage

## S4 method for signature 'DataFrame,character,character,character'
saveAsTable(df, tableName,
  source = NULL, mode = "append", ...)

saveAsTable(df, tableName, source, mode, ...)

Arguments

df

A SparkSQL DataFrame

tableName

A name for the table

source

A name for external data source

mode

One of 'append', 'overwrite', 'error', 'ignore'

Details

The data source is specified by the 'source' and a set of options (...). If 'source' is not specified, the default data source configured by spark.sql.sources.default will be used.

Additionally, mode is used to specify the behavior of the save operation when data already exists in the data source. There are four modes: append: Contents of this DataFrame are expected to be appended to existing data. overwrite: Existing data is expected to be overwritten by the contents of error: An exception is expected to be thrown. ignore: The save operation is expected to not save the contents of the DataFrame

Examples

## Not run: 
##D sc <- sparkR.init()
##D sqlContext <- sparkRSQL.init(sc)
##D path <- "path/to/file.json"
##D df <- jsonFile(sqlContext, path)
##D saveAsTable(df, "myfile")
## End(Not run)

[Package SparkR version 1.5.1 Index]