LuciferYang opened a new pull request, #38396:
URL: https://github.com/apache/spark/pull/38396
### What changes were proposed in this pull request?
This pr refactor `AnalysisTest#assertAnalysisErrorClass` method to use
`e.messageParameters.toSeq.sorted == expectedMessageParameters.toSeq.sorted`
instead of `e.messageParameters.sameElements(expectedMessageParameters)` to
avoid wrong check result when `expectedMessageParameters.size <= 4`
### Why are the changes needed?
Avoid wrong check result of `AnalysisTest#assertAnalysisErrorClass` when
`expectedMessageParameters.size <= 4`.
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
- Pass GitHub Actions
- Manual test:
```scala
Welcome to Scala 2.12.16 (OpenJDK 64-Bit Server VM, Java 1.8.0_352).
Type in expressions for evaluation. Or try :help.
scala> :paste
// Entering paste mode (ctrl-D to finish)
val messageParameters = Map(
"exprName" -> "`window_duration`",
"valueRange" -> s"(0, 9223372036854775807]",
"currentValue" -> "-1000000L",
"sqlExpr" -> "\"window(2016-01-01 01:01:01, -1000000, 1000000, 0)\""
)
val expectedMessageParameters = Map(
"sqlExpr" -> "\"window(2016-01-01 01:01:01, -1000000, 1000000, 0)\"",
"exprName" -> "`window_duration`",
"valueRange" -> s"(0, 9223372036854775807]",
"currentValue" -> "-1000000L"
)
val fret = messageParameters.sameElements(expectedMessageParameters)
def sameMapContents(left: Map[String, String], right: Map[String, String]):
Boolean =
left.toSeq.sorted == right.toSeq.sorted
val tret = sameMapContents(messageParameters, expectedMessageParameters)
// Exiting paste mode, now interpreting.
messageParameters: scala.collection.immutable.Map[String,String] =
Map(exprName -> `window_duration`, valueRange -> (0, 9223372036854775807],
currentValue -> -1000000L, sqlExpr -> "window(2016-01-01 01:01:01, -1000000,
1000000, 0)")
expectedMessageParameters: scala.collection.immutable.Map[String,String] =
Map(sqlExpr -> "window(2016-01-01 01:01:01, -1000000, 1000000, 0)", exprName ->
`window_duration`, valueRange -> (0, 9223372036854775807], currentValue ->
-1000000L)
fret: Boolean = false
sameMapContents: (left: Map[String,String], right: Map[String,String])Boolean
tret: Boolean = true
```
--
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]