cloud-fan commented on code in PR #49609:
URL: https://github.com/apache/spark/pull/49609#discussion_r1931411436


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/variant/variantExpressions.scala:
##########
@@ -287,23 +282,35 @@ case class VariantGet(
     timeZoneId,
     zoneId)
 
-  protected override def nullSafeEval(input: Any, path: Any): Any = {
-    VariantGet.variantGet(input.asInstanceOf[VariantVal], parsedPath, 
dataType, castArgs)
+  protected override def nullSafeEval(input: Any, path: Any): Any = parsedPath 
match {
+    case Some(pp) =>
+      VariantGet.variantGet(input.asInstanceOf[VariantVal], pp, dataType, 
castArgs)
+    case _ =>
+      VariantGet.variantGet(input.asInstanceOf[VariantVal], 
path.asInstanceOf[UTF8String], dataType,
+        castArgs, prettyName)
   }
 
   protected override def doGenCode(ctx: CodegenContext, ev: ExprCode): 
ExprCode = {
-    val childCode = child.genCode(ctx)
     val tmp = ctx.freshVariable("tmp", classOf[Object])
-    val parsedPathArg = ctx.addReferenceObj("parsedPath", parsedPath)
+    val childCode = child.genCode(ctx)
+    val pathCode = path.genCode(ctx)
     val dataTypeArg = ctx.addReferenceObj("dataType", dataType)
     val castArgsArg = ctx.addReferenceObj("castArgs", castArgs)
+    val parsedPathArg = if (parsedPath.isEmpty) {
+      pathCode.value
+    } else {
+      ctx.addReferenceObj("parsedPath", parsedPath.get)
+    }

Review Comment:
   ```suggestion
       val (pathCode, parsedPathArg) = if (parsedPath.isEmpty) {
         val pathCode = path.genCode(ctx)
         (pathCode, pathCode.value)
       } else {
         (EmptyBlock, ctx.addReferenceObj("parsedPath", parsedPath.get))
       }
   ```



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