Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ final class DataFrameNaFunctions private[sql](df: DataFrame)
val typeMatches = (targetType, col.dataType) match {
case (NumericType, dt) => dt.isInstanceOf[NumericType]
case (StringType, _: StringType) => true
case (StringType, _) => false
case (BooleanType, dt) => dt == BooleanType
case _ =>
throw new IllegalArgumentException(s"$targetType is not matched at fillValue")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ import scala.jdk.CollectionConverters._
import org.apache.spark.SparkUnsupportedOperationException
import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.test.SharedSparkSession
import org.apache.spark.sql.types.{CharType, StringType, StructField, StructType, VarcharType}
import org.apache.spark.sql.types.{
CharType,
IntegerType,
StringType,
StructField,
StructType,
VarcharType
}

class DataFrameNaFunctionsSuite extends SharedSparkSession {
import testImplicits._
Expand Down Expand Up @@ -219,10 +226,12 @@ class DataFrameNaFunctionsSuite extends SharedSparkSession {
withSQLConf(SQLConf.CHAR_VARCHAR_STANDARD_SEMANTICS.key -> "true") {
val schema = StructType(Seq(
StructField("c", CharType(3)),
StructField("v", VarcharType(3))))
val input = spark.createDataFrame(sparkContext.parallelize(Seq(Row(null, null))), schema)
StructField("v", VarcharType(3)),
StructField("i", IntegerType)))
val input = spark.createDataFrame(
sparkContext.parallelize(Seq(Row(null, null, null))), schema)

checkAnswer(input.na.fill("x"), Row("x ", "x"))
checkAnswer(input.na.fill("x"), Row("x ", "x", null))
}
}

Expand Down