vinodkc commented on code in PR #56455:
URL: https://github.com/apache/spark/pull/56455#discussion_r3406631659


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/literals.scala:
##########
@@ -562,13 +570,30 @@ case class Literal (value: Any, dataType: DataType) 
extends LeafExpression {
           ExprCode.forNonNullValue(JavaCode.expression(s"($javaType)$value", 
dataType))
         case TimestampType | TimestampNTZType | LongType | _: 
DayTimeIntervalType | _: TimeType =>
           toExprCode(s"${value}L")
+        case (_: TimestampNTZNanosType | _: TimestampLTZNanosType)
+            if TypeOps(dataType).isDefined =>
+          ExprCode.forNonNullValue(
+            JavaCode.expression(TypeOps(dataType).get.getJavaLiteral(value), 
dataType))
         case _ =>
           val constRef = ctx.addReferenceObj("literal", value, javaType)
           ExprCode.forNonNullValue(JavaCode.global(constRef, dataType))
       }
     }
   }
 
+  private def padToNanosPrecision(ts: String, precision: Int): String = {
+    val dotIdx = ts.indexOf('.')
+    if (dotIdx < 0) {
+      ts + "." + "0" * precision
+    } else {
+      val fracLen = ts.length - dotIdx - 1
+      // fracLen can never exceed precision: 
formatNanos/formatWithoutTimeZoneNanos truncate
+      // the value to `precision` digits before formatting, and the 
fractionFormatter only
+      // strips trailing zeros (never adds digits). The else branch is a 
defensive fallback.

Review Comment:
   Updated the comment to clarify the else branch is the normal path (fracLen 
== precision), not a rare fallback.



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

Reply via email to