Github user chenghao-intel commented on a diff in the pull request:

    https://github.com/apache/spark/pull/3780#discussion_r22795027
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/SchemaRDDLike.scala 
---
    @@ -68,12 +68,29 @@ private[sql] trait SchemaRDDLike {
       /**
        * Saves the contents of this `SchemaRDD` as a parquet file, preserving 
the schema.  Files that
        * are written out using this method can be read back in as a SchemaRDD 
using the `parquetFile`
    -   * function.
    +   * function. It will raise exception if the specified path already 
existed.
        *
    +   * @param path   The destination path.
        * @group schema
        */
       def saveAsParquetFile(path: String): Unit = {
    -    sqlContext.executePlan(WriteToFile(path, logicalPlan)).toRdd
    +    // We provide override functions for the ability of default function 
argument value,
    +    // which is not naturely supported by Java
    +    saveAsParquetFile(path, false)
    +  }
    +
    +  /**
    +   * Saves the contents of this `SchemaRDD` as a parquet file, preserving 
the schema.  Files that
    +   * are written out using this method can be read back in as a SchemaRDD 
using the `parquetFile`
    +   * function.
    +   * @param path      The destination path.
    +   * @param overwrite If it's false, an exception will raise if the path 
already existed,
    --- End diff --
    
    @marmbrus this comment actually is my intention. Not like the API 
`insertInto`, which work as `overwrite` or `append` mode, `saveAsParquetFile` 
originally throws exception when the specified path is existed, but in some ETL 
application, we need to overwrite the existed path without any caution, that's 
why I add a new API for this purpose. And you're right, the implementation that 
you were reviewing contains a bug, now it has been fixed.
    
    @rxin We save the entire schema rdd as multiple files under the specified 
path. 
    And from the API design, I am not sure if we need to merge these 2 APIs 
`saveAsParquetFile` and `insertInto`, by specifying the mode 
(`append`,`overwrite`) and file types (parquet format, rcfile etc.). 
    
    What do you think?


---
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]

Reply via email to