charlhhhh commented on code in PR #60148:
URL: https://github.com/apache/spark/pull/60148#discussion_r4542557516
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/toFromProtobufSqlFunctions.scala:
##########
@@ -167,7 +167,10 @@ case class FromProtobuf(
case bytes: Array[Byte] => Some(bytes)
case null => None
}
- val optionsValue: Map[String, String] = options.eval() match {
+ // Concurrent canonicalization can evaluate the same CreateMap and corrupt
its map builder.
+ // Copy stateful options to avoid duplicate-key errors and mismatched
key/value array lengths.
+ val freshOptions = options.freshCopyIfContainsStatefulExpression()
Review Comment:
This only happens when the message name or descriptor argument itself
contains a stateful expression such as map(...), for example
element_at(map('m', 'OtherExample'), 'm'). In practice these arguments are
string literals (a message name, and a file path or descriptor bytes), which
aren't stateful, so evaluating them in place is safe. Since this input is very
unusual and the failure is loud rather than silent, I'd prefer to keep this PR
focused on the options. @HeartSaVioR what do you think? Happy to copy these two
arguments as well if you'd prefer.
--
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]