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 @@ -87,6 +87,7 @@ abstract class ToNumberBase(left: Expression, right: Expression, errorOnFail: Bo
|${CodeGenerator.javaType(dataType)} ${ev.value} = ${CodeGenerator.defaultValue(dataType)};
|if (!${ev.isNull}) {
| ${ev.value} = $builder.parse(${eval.value});
| ${ev.isNull} = ${ev.isNull} || (${ev.value} == null);
|}
""".stripMargin)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,11 @@ class StringFunctionsSuite extends QueryTest with SharedSparkSession {
checkAnswer(df.select(try_to_number(col("a"), lit("$99.99"))), Seq(Row(78.12)))
}

test("SPARK-47646: try_to_number should return NULL for malformed input") {
val df = spark.createDataset(spark.sparkContext.parallelize(Seq("11")))
checkAnswer(df.select(try_to_number($"value", lit("$99.99"))), Seq(Row(null)))
}

test("SPARK-44905: stateful lastRegex causes NullPointerException on eval for regexp_replace") {
val df = sql("select regexp_replace('', '[a\\\\d]{0, 2}', 'x')")
intercept[SparkRuntimeException](df.queryExecution.optimizedPlan)
Expand Down