panbingkun commented on code in PR #48509: URL: https://github.com/apache/spark/pull/48509#discussion_r1804339739
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/jsonExpressions.scala: ########## @@ -718,6 +692,21 @@ case class JsonToStructs( override def prettyName: String = "from_json" + @transient + private val nameOfCorruptRecord = SQLConf.get.getConf(SQLConf.COLUMN_NAME_OF_CORRUPT_RECORD) + + @transient + lazy val evaluator = new JsonToStructsEvaluator( + options, nullableSchema, nameOfCorruptRecord, timeZoneId, variantAllowDuplicateKeys) + + override def replacement: Expression = Invoke( Review Comment: Yes, in `Invoke`, `cast` is added by default to the results of method calls, as shown below - Invoke https://github.com/apache/spark/blob/2469a6f29c0e6f59e928f4f4e7aa9709768d4757/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala#L477 https://github.com/apache/spark/blob/2469a6f29c0e6f59e928f4f4e7aa9709768d4757/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala#L481 - StaticInvoke (while `StaticInvoke` does not) https://github.com/apache/spark/blob/2469a6f29c0e6f59e928f4f4e7aa9709768d4757/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala#L325 https://github.com/apache/spark/blob/2469a6f29c0e6f59e928f4f4e7aa9709768d4757/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala#L331 https://github.com/apache/spark/blob/2469a6f29c0e6f59e928f4f4e7aa9709768d4757/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala#L345 - I think it's also necessary to add `cast` on `StaticInvoke`. we haven't encountered any similar cases so far. (At least this case was bypassed using `Invoke`) -- 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]
