-
Notifications
You must be signed in to change notification settings - Fork 13.8k
[FLINK-33032][table-planner][JUnit5 Migration] Module: flink-table-planner (ExpressionTestBase) #23358
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
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.
@Jiabao-Sun Thanks for the pr. I left minor comment
...able-planner/src/test/scala/org/apache/flink/table/planner/expressions/DecimalTypeTest.scala
Show resolved
Hide resolved
...able-planner/src/test/scala/org/apache/flink/table/planner/expressions/DecimalTypeTest.scala
Show resolved
Hide resolved
import org.apache.flink.table.planner.utils.DateTimeTestUtil.{localDate, localDateTime, localTime => gLocalTime} | ||
|
||
import org.junit.Test | ||
import org.assertj.core.api.Assertions.{assertThatExceptionOfType, assertThatThrownBy} |
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.
Unused import statement
warning in my ide
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 it an IDE's mistake about Unused import statement warning
?
assertThatExceptionOfType
is used by line 150 and line 154.
assertThatThrownBy
is used by line 167.
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.
Are you sure is it used? I still couldn't find the usage of assertThatExceptionOfType
. Could you please post the link where it's used?
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.
Sorry, It's indeed unused.
|
||
// throw exception if plan contains more than a calc | ||
if (!optimized.getInput(0).getInputs.isEmpty) { | ||
fail("Expression is converted into more than a Calc operation. Use a different test method.") |
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.
Can we still keep the fail message?
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.
Fixed
case ((originalExpr, optimizedExpr, expected), actual) => | ||
val original = if (originalExpr == null) "" else s"for: [$originalExpr]" | ||
assertEquals( | ||
s"Wrong result $original optimized to: [$optimizedExpr]", |
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.
Can we still keep the fail message?
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.
There's some scala compilation errors when changed the code to :
assertThat(if (actual == null) "NULL" else actual)
.withFailMessage("Wrong result %s %s", original, optimizedExpr)
.isEqualTo(expected)
errors:
value isEqualTo is not a member of ?0
possible cause: maybe a semicolon is missing before `value isEqualTo'?
.isEqualTo(expected)
I change the assertions from org.assertj.core.api.Assertions
to org.junit.jupiter.api.Assertions
to keep the error message and it works.
e.getMessage.contains(keywords)) | ||
} | ||
case e: Throwable => | ||
e.printStackTrace() |
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.
Can we still keep the fail message?
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.
The changed code will print similar fail messages as the old code.
I think we needn't keep the redundant fail messages. WDT?
if (keywords != null) {
assertThatExceptionOfType(clazz)
.isThrownBy(callable)
.withMessageContaining(keywords)
} else {
assertThatExceptionOfType(clazz)
.isThrownBy(callable)
}
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.
Thx, make sense to me.
789cf16
to
cc66eca
Compare
Thanks @luoyuxia for detailed review. |
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.
@Jiabao-Sun Thanks for updating. Only one comment. Also, remember rebase when you want to append a commit.
import org.apache.flink.table.planner.utils.DateTimeTestUtil.{localDate, localDateTime, localTime => gLocalTime} | ||
|
||
import org.junit.Test | ||
import org.assertj.core.api.Assertions.{assertThatExceptionOfType, assertThatThrownBy} |
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.
Are you sure is it used? I still couldn't find the usage of assertThatExceptionOfType
. Could you please post the link where it's used?
e.getMessage.contains(keywords)) | ||
} | ||
case e: Throwable => | ||
e.printStackTrace() |
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.
Thx, make sense to me.
cc66eca
to
48f945d
Compare
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.
LGTM
Thanks @luoyuxia, the CI passed. |
What is the purpose of the change
[FLINK-33032][table-planner][JUnit5 Migration] Module: flink-table-planner (ExpressionTestBase)
Brief change log
JUnit5 Migration Module: flink-table-planner (ExpressionTestBase)
Verifying this change
This change is already covered by existing tests
Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: noDocumentation