GitHub user dongjoon-hyun opened a pull request:

    https://github.com/apache/spark/pull/13545

    [SPARK-15807][SQL] Support varargs for distinct/dropDuplicates in 
Dataset/DataFrame

    ## What changes were proposed in this pull request?
    This PR adds `varargs`-types `distinct/dropDuplicates` functions in 
`Dataset/DataFrame`. Currently, `distinct` does not get arguments, and 
`dropDuplicates` supports only `Seq` or `Array`.
    
    **Before**
    ```scala
    scala> val ds = spark.createDataFrame(Seq(("a", 1), ("b", 2), ("a", 2)))
    ds: org.apache.spark.sql.DataFrame = [_1: string, _2: int]
    
    scala> ds.dropDuplicates(Seq("_1", "_2"))
    res0: org.apache.spark.sql.Dataset[org.apache.spark.sql.Row] = [_1: string, 
_2: int]
    
    scala> ds.dropDuplicates("_1", "_2")
    <console>:26: error: overloaded method value dropDuplicates with 
alternatives:
      (colNames: 
Array[String])org.apache.spark.sql.Dataset[org.apache.spark.sql.Row] <and>
      (colNames: 
Seq[String])org.apache.spark.sql.Dataset[org.apache.spark.sql.Row] <and>
      ()org.apache.spark.sql.Dataset[org.apache.spark.sql.Row]
     cannot be applied to (String, String)
           ds.dropDuplicates("_1", "_2")
              ^
    
    scala> ds.distinct("_1", "_2")
    <console>:26: error: too many arguments for method distinct: 
()org.apache.spark.sql.Dataset[org.apache.spark.sql.Row]
           ds.distinct("_1", "_2")
    ```
    
    **After**
    ```scala
    scala> val ds = spark.createDataFrame(Seq(("a", 1), ("b", 2), ("a", 2)))
    ds: org.apache.spark.sql.DataFrame = [_1: string, _2: int]
    
    scala> ds.dropDuplicates("_1", "_2")
    res0: org.apache.spark.sql.Dataset[org.apache.spark.sql.Row] = [_1: string, 
_2: int]
    
    scala> ds.distinct("_1", "_2")
    res1: org.apache.spark.sql.Dataset[org.apache.spark.sql.Row] = [_1: string, 
_2: int]
    ```
    
    ## How was this patch tested?
    
    Pass the Jenkins tests with new testcases.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/dongjoon-hyun/spark SPARK-15807

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/13545.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #13545
    
----
commit 33f446f4bb04e2ea0014c385b6f0d1b290db5a90
Author: Dongjoon Hyun <dongj...@apache.org>
Date:   2016-06-07T18:34:24Z

    [SPARK-15807][SQL] Support varargs for distinct/dropDuplicates

----


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to