MaxGekk commented on a change in pull request #25865: [SPARK-29187][SQL] Return
null from `date_part()` for the null `field`
URL: https://github.com/apache/spark/pull/25865#discussion_r326564984
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala
##########
@@ -2053,10 +2053,15 @@ case class DatePart(field: Expression, source:
Expression, child: Expression)
if (!field.foldable) {
throw new AnalysisException("The field parameter needs to be a
foldable string value.")
}
- val fieldStr = field.eval().asInstanceOf[UTF8String].toString
- DatePart.parseExtractField(fieldStr, source, {
- throw new AnalysisException(s"Literals of type '$fieldStr' are
currently not supported.")
- })
+ val fieldEval = field.eval()
+ if (fieldEval == null) {
+ Literal(null, DoubleType)
Review comment:
See the example in the description. PostgreSQL returns `NULL` of the `double
precision` type which is equivalent of `DOUBLE` type in Spark SQL. Which type
would you use here?
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]