Github user crackcell commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17123#discussion_r103954857
  
    --- Diff: mllib/src/main/scala/org/apache/spark/ml/feature/Bucketizer.scala 
---
    @@ -105,20 +106,24 @@ final class Bucketizer @Since("1.4.0") 
(@Since("1.4.0") override val uid: String
         transformSchema(dataset.schema)
         val (filteredDataset, keepInvalid) = {
           if (getHandleInvalid == Bucketizer.SKIP_INVALID) {
    -        // "skip" NaN option is set, will filter out NaN values in the 
dataset
    +        // "skip" NaN/NULL option is set, will filter out NaN/NULL values 
in the dataset
             (dataset.na.drop().toDF(), false)
           } else {
             (dataset.toDF(), getHandleInvalid == Bucketizer.KEEP_INVALID)
           }
         }
     
    -    val bucketizer: UserDefinedFunction = udf { (feature: Double) =>
    -      Bucketizer.binarySearchForBuckets($(splits), feature, keepInvalid)
    +    val bucketizer: UserDefinedFunction = udf { (row: Row) =>
    +      Bucketizer.binarySearchForBuckets(
    +        $(splits),
    +        row.getAs[java.lang.Double]($(inputCol)),
    --- End diff --
    
    Hi, Scala's Double will convert null to zero. Say:
    > scala> val a: Double = null.asInstanceOf[Double]
    > a: Double = 0.0
    So I use Java's Double instead to hold NULLs. I feel it a litte ugly, any 
better way?


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