Github user cloud-fan commented on a diff in the pull request: https://github.com/apache/spark/pull/17123#discussion_r104224870 --- 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 -- Ideally we should use `row.getDouble(index)` and `row.isNullAt(index)` together to get values for primitive types, but technically `Row` is just a `Array[Object]`, so there is no performance penalty by using `java.lang.Double`.(this may change in the future, if possible we should prefer `isNullAt` and `getDouble`)
--- 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