File tree Expand file tree Collapse file tree
main/scala/org/apache/spark/sql/catalyst/expressions
test/scala/org/apache/spark/sql/catalyst/expressions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1039,7 +1039,9 @@ case class ScalaUDF(
10391039 try {
10401040 $resultTerm = ( ${ctx.boxedType(dataType)}) $catalystConverterTerm.apply( $getFuncResult);
10411041 } catch (NullPointerException e) {
1042- throw new RuntimeException( $scalaUDF.npeErrorMessage(), e);
1042+ NullPointerException npe = new NullPointerException( $scalaUDF.npeErrorMessage());
1043+ npe.setStackTrace(e.getStackTrace());
1044+ throw npe;
10431045 }
10441046 """ .stripMargin
10451047
@@ -1065,7 +1067,9 @@ case class ScalaUDF(
10651067 f(input)
10661068 } catch {
10671069 case e : NullPointerException =>
1068- throw new RuntimeException (npeErrorMessage, e)
1070+ val npe = new NullPointerException (npeErrorMessage)
1071+ npe.setStackTrace(e.getStackTrace)
1072+ throw npe
10691073 }
10701074
10711075 converter(result)
Original file line number Diff line number Diff line change @@ -36,10 +36,10 @@ class ScalaUDFSuite extends SparkFunSuite with ExpressionEvalHelper {
3636 StringType ,
3737 Literal .create(null , StringType ) :: Nil )
3838
39- val e1 = intercept[RuntimeException ](udf.eval())
39+ val e1 = intercept[NullPointerException ](udf.eval())
4040 assert(e1.getMessage.contains(" Given UDF throws NPE during execution" ))
4141
42- val e2 = intercept[RuntimeException ] {
42+ val e2 = intercept[NullPointerException ] {
4343 checkEvalutionWithUnsafeProjection(udf, null )
4444 }
4545 assert(e2.getMessage.contains(" Given UDF throws NPE during execution" ))
You can’t perform that action at this time.
0 commit comments