Example usage for org.apache.spark.sql SaveMode ErrorIfExists

List of usage examples for org.apache.spark.sql SaveMode ErrorIfExists

Introduction

In this page you can find the example usage for org.apache.spark.sql SaveMode ErrorIfExists.

Prototype

SaveMode ErrorIfExists

To view the source code for org.apache.spark.sql SaveMode ErrorIfExists.

Click Source Link

Document

ErrorIfExists mode means that when saving a DataFrame to a data source, if data already exists, an exception is expected to be thrown.

Usage

From source file:com.thinkbiganalytics.kylo.catalog.spark.SparkUtil.java

License:Apache License

/**
 * Returns the save mode with the specified name.
 *
 * @throws IllegalArgumentException if no save mode has the specified name
 *//*from w w  w  .j a va 2  s  .  c o  m*/
@Nonnull
public static SaveMode toSaveMode(final String s) {
    Preconditions.checkNotNull(s, "Save mode cannot be null");
    switch (s.toLowerCase()) {
    case "overwrite":
        return SaveMode.Overwrite;

    case "append":
        return SaveMode.Append;

    case "ignore":
        return SaveMode.Ignore;

    case "error":
    case "errorifexists":
    case "default":
        return SaveMode.ErrorIfExists;

    default:
        log.debug("Unknown save mode: {}", s);
        throw new IllegalArgumentException("Unknown save mode: " + s
                + ". Accepted save modes are 'overwrite', 'append', 'ignore', 'error', 'errorifexists'.");
    }
}