charlhhhh commented on code in PR #60354:
URL: https://github.com/apache/spark/pull/60354#discussion_r4555393591
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/avroSqlFunctions.scala:
##########
@@ -134,13 +136,30 @@ case class FromAvro(
}
override lazy val replacement: Expression = {
- val schemaValue: String = jsonFormatSchema.eval() match {
+ val conf = SQLConf.get
+ if (conf.getConf(SQLConf.MAP_KEY_DEDUP_POLICY) == mapKeyDedupPolicy) {
Review Comment:
@dichlorodiphen Could you take a look at this one? The finding is correct:
besides the map key policy, `ArrayBasedMapBuilder` also reads
`spark.sql.legacy.disableMapKeyNormalization` when it puts its first key
([ArrayBasedMapBuilder.scala#L64-L69](https://github.com/apache/spark/blob/99a5f5fc987f53c64cb19d06c72722870f415305/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/ArrayBasedMapBuilder.scala#L64-L69)),
so a fresh copy takes that flag from the evaluating session. But I'm not sure
it's worth fixing:
1. It's even rarer than the [map key policy case in
#60148](https://github.com/apache/spark/pull/60148#discussion_r4533237723).
Besides a flag change between analysis and a later canonicalization or
execution, an argument has to build a map with float or double keys that differ
only in the sign of zero. The options must be a [string-to-string
map](https://github.com/apache/spark/blob/99a5f5fc987f53c64cb19d06c72722870f415305/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/avroSqlFunctions.scala#L120-L130)
and the schema is a string, so such a map can only be nested inside an
argument, e.g. `element_at(map(0.0D, ..., -0.0D, ...), 0.0D)`, feels like no
real users will write like this?
2. The same gap exists in
[#60148](https://github.com/apache/spark/pull/60148), so fixing it here means
changing both PRs.
3. `spark.sql.legacy.disableMapKeyNormalization` is an [internal legacy
flag, off by
default](https://github.com/apache/spark/blob/99a5f5fc987f53c64cb19d06c72722870f415305/sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala#L6375-L6383).
What do you think? Happy to fix it in both PRs 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]