You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/12/23 09:51:58 UTC
[GitHub] [spark] MaxGekk commented on a change in pull request #30904: [SPARK-33889][SQL] Fix NPE from `SHOW PARTITIONS` on V2 tables
MaxGekk commented on a change in pull request #30904:
URL: https://github.com/apache/spark/pull/30904#discussion_r547871911
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/ShowPartitionsExec.scala
##########
@@ -53,9 +53,12 @@ case class ShowPartitionsExec(
var i = 0
while (i < len) {
val dataType = schema(i).dataType
- val partValue = row.get(i, dataType)
- val partValueStr = Cast(Literal(partValue, dataType), StringType, Some(timeZoneId))
- .eval().toString
+ val partValueStr = if (row.isNullAt(i)) {
+ "null"
+ } else {
+ Cast(Literal(row.get(i, dataType), dataType), StringType, Some(timeZoneId))
+ .eval().toString
Review comment:
Actually, NPE occurs on `null.toString`. I am thinking of the case when `Cast(Literal(row.get(i, dataType), dataType), StringType, Some(timeZoneId)).eval()` returns `null` for non-null input. Maybe it is better to check the result of `eval()`, so, it should be much more reliable fix.
----------------------------------------------------------------
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org