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 2019/01/21 14:49:33 UTC
[GitHub] MaxGekk commented on a change in pull request #23596:
[SPARK-26652][SQL] Use Proleptic Gregorian Calendar in Literal.fromString
MaxGekk commented on a change in pull request #23596: [SPARK-26652][SQL] Use Proleptic Gregorian Calendar in Literal.fromString
URL: https://github.com/apache/spark/pull/23596#discussion_r249477301
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
##########
@@ -1552,17 +1552,15 @@ class AstBuilder(conf: SQLConf) extends SqlBaseBaseVisitor[AnyRef] with Logging
override def visitTypeConstructor(ctx: TypeConstructorContext): Literal = withOrigin(ctx) {
val value = string(ctx.STRING)
val valueType = ctx.identifier.getText.toUpperCase(Locale.ROOT)
- def toLiteral[T](f: UTF8String => Option[T], t: DataType): Literal = {
- f(UTF8String.fromString(value)).map(Literal(_, t)).getOrElse {
+ def toLiteral(t: DataType): Literal = {
+ Try {Literal.fromString(value, t)}.getOrElse {
throw new ParseException(s"Cannot parse the $valueType value: $value", ctx)
}
}
try {
valueType match {
- case "DATE" => toLiteral(stringToDate, DateType)
- case "TIMESTAMP" =>
- val timeZone = getTimeZone(SQLConf.get.sessionLocalTimeZone)
- toLiteral(stringToTimestamp(_, timeZone), TimestampType)
+ case "DATE" => toLiteral(DateType)
Review comment:
I did that in another PR but @hvanhovell doesn't like that.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org