maropu commented on a change in pull request #29065:
URL: https://github.com/apache/spark/pull/29065#discussion_r499577826
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/DataFrameStatFunctions.scala
##########
@@ -580,23 +581,11 @@ final class DataFrameStatFunctions private[sql](df:
DataFrame) {
val singleCol = df.select(col)
val colType = singleCol.schema.head.dataType
- require(colType == StringType || colType.isInstanceOf[IntegralType],
- s"Bloom filter only supports string type and integral types, but got
$colType.")
-
- val updater: (BloomFilter, InternalRow) => Unit = colType match {
- // For string type, we can get bytes of our `UTF8String` directly, and
call the `putBinary`
- // instead of `putString` to avoid unnecessary conversion.
- case StringType => (filter, row) =>
filter.putBinary(row.getUTF8String(0).getBytes)
- case ByteType => (filter, row) => filter.putLong(row.getByte(0))
- case ShortType => (filter, row) => filter.putLong(row.getShort(0))
- case IntegerType => (filter, row) => filter.putLong(row.getInt(0))
- case LongType => (filter, row) => filter.putLong(row.getLong(0))
- case _ =>
- throw new IllegalArgumentException(
- s"Bloom filter only supports string type and integral types, " +
- s"and does not support type $colType."
- )
- }
+ require(colType.isInstanceOf[AtomicType],
+ s"Bloom filter only supports atomic types, but got
${colType.catalogString}.")
+
+ val updater: (BloomFilter, InternalRow) => Unit =
+ (filter, row) => BloomFilterUtils.putValue(filter, row.get(0, colType))
Review comment:
I think this change can cause perf. regression because the pattern
matching of `colType` happens every time `updater` called.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]