cloud-fan commented on a change in pull request #26595: [SPARK-29956][SQL] A 
literal number with an exponent should be parsed to Double
URL: https://github.com/apache/spark/pull/26595#discussion_r347891789
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
 ##########
 @@ -1939,11 +1939,32 @@ class AstBuilder(conf: SQLConf) extends 
SqlBaseBaseVisitor[AnyRef] with Logging
     Literal(BigDecimal(ctx.getText).underlying())
   }
 
+  /**
+   * Create a decimal literal for a regular decimal number.
+   */
+  override def visitLegacyDecimalLiteral(ctx: LegacyDecimalLiteralContext)
+    : Literal = withOrigin(ctx) {
+    Literal(BigDecimal(ctx.getText).underlying())
+  }
+
+  /**
+   * Create a double literal for number with an exponent, e.g. 1E-30
+   */
+  override def visitExponentLiteral(ctx: ExponentLiteralContext): Literal = {
+    numericLiteral(ctx, Double.MinValue, Double.MaxValue, 
DoubleType.simpleString)(_.toDouble)
 
 Review comment:
   hmm this looks hacky. Can we move the strip of suffix to the caller side? 
then `numericLiteral` can focus on the range check.

----------------------------------------------------------------
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]

Reply via email to