-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-40919][SQL][TESTS] Fix AnalysisTest#assertAnalysisErrorClass to avoid wrong check result when expectedMessageParameters.size <= 4
#38396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| line: Int = -1, | ||
| pos: Int = -1): Unit = { | ||
|
|
||
| def sameMapContents(left: Map[String, String], right: Map[String, String]): Boolean = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @MaxGekk fix the problem I mentioned in #38394 (comment)
AnalysisTest#assertAnalysisErrorClass to avoid bad case when expectedMessageParameters.size <= 4AnalysisTest#assertAnalysisErrorClass to avoid wrong check result when expectedMessageParameters.size <= 4
|
@LuciferYang How about to use 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"
)
// 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)
scala> messageParameters == expectedMessageParameters
res0: Boolean = true |
|
I think |
|
|
||
| if (e.getErrorClass != expectedErrorClass || | ||
| !e.messageParameters.sameElements(expectedMessageParameters) || | ||
| !(e.messageParameters == expectedMessageParameters) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's simplify this and use != instead of combination of ! and ==.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
MaxGekk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting for CI.
AnalysisTest#assertAnalysisErrorClass to avoid wrong check result when expectedMessageParameters.size <= 4AnalysisTest#assertAnalysisErrorClass to avoid wrong check result when expectedMessageParameters.size <= 4
|
|
||
| if (e.getErrorClass != expectedErrorClass || | ||
| !e.messageParameters.sameElements(expectedMessageParameters) || | ||
| e.messageParameters != expectedMessageParameters || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, Could you fix the indentation by adding two more space here while we are touching this line?
dongjoon-hyun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, LGTM (except a minor indentation comment)
| !e.messageParameters.sameElements(expectedMessageParameters) || | ||
| (line >= 0 && e.line.getOrElse(-1) != line) || | ||
| (pos >= 0) && e.startPosition.getOrElse(-1) != pos) { | ||
| e.messageParameters != expectedMessageParameters || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the indentation correct now?
|
+1, LGTM. All GAs passed. Merging to master. |
|
Thanks @MaxGekk @dongjoon-hyun @HyukjinKwon |
… to avoid wrong check result when `expectedMessageParameters.size <= 4`
### What changes were proposed in this pull request?
This pr refactor `AnalysisTest#assertAnalysisErrorClass` method to use `e.messageParameters != expectedMessageParameters` 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.17 (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 tret = !messageParameters.sameElements(expectedMessageParameters)
val fret = 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)
tret: Boolean = true
fret: Boolean = false
```
Closes apache#38396 from LuciferYang/SPARK-40919.
Authored-by: yangjie01 <yangjie01@baidu.com>
Signed-off-by: Max Gekk <max.gekk@gmail.com>
What changes were proposed in this pull request?
This pr refactor
AnalysisTest#assertAnalysisErrorClassmethod to usee.messageParameters != expectedMessageParametersinstead of!e.messageParameters.sameElements(expectedMessageParameters)to avoid wrong check result whenexpectedMessageParameters.size <= 4Why are the changes needed?
Avoid wrong check result of
AnalysisTest#assertAnalysisErrorClasswhenexpectedMessageParameters.size <= 4.Does this PR introduce any user-facing change?
No
How was this patch tested?