xkrogen commented on code in PR #37634:
URL: https://github.com/apache/spark/pull/37634#discussion_r960070035
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/GenerateUnsafeProjection.scala:
##########
@@ -252,28 +266,44 @@ object GenerateUnsafeProjection extends
CodeGenerator[Seq[Expression], UnsafePro
""".stripMargin
}
+ /**
+ * Wrap `inputExpr` in a try-catch block that will catch any
[[NullPointerException]] that is
+ * thrown, instead throwing a (more helpful) error message as provided by
+ *
[[org.apache.spark.sql.errors.QueryExecutionErrors.valueCannotBeNullError]].
+ */
+ private def wrapWithNpeHandling(inputExpr: String, descPath: Seq[String]):
String =
+ s"""
+ |try {
+ | ${inputExpr.trim}
+ |} catch (NullPointerException npe) {
+ | throw QueryExecutionErrors.valueCannotBeNullError(
Review Comment:
Printing the single datum won't be helpful since it's always NULL, and it
would be challenging to access the whole input row from this location. We
create the projection recursively, so at this point while recursing, we don't
even have a reference to the fully created projection to grab the other fields.
Note also that this is a failure to project the data, and we would also need to
project the data to print it, so we'd have to selectively skip this field.
Open to suggestions, but I don't see a clear path forward.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]