Skip to content

Conversation

Jiabao-Sun
Copy link
Contributor

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:

  • Dependencies (does it add or upgrade a dependency): no
  • The public API, i.e., is any changed class annotated with @Public(Evolving): no
  • The serializers: no
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? not applicable

@flinkbot
Copy link
Collaborator

flinkbot commented Sep 5, 2023

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

Copy link
Contributor

@luoyuxia luoyuxia left a 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

import org.apache.flink.table.planner.utils.DateTimeTestUtil.{localDate, localDateTime, localTime => gLocalTime}

import org.junit.Test
import org.assertj.core.api.Assertions.{assertThatExceptionOfType, assertThatThrownBy}
Copy link
Contributor

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

Copy link
Contributor Author

@Jiabao-Sun Jiabao-Sun Sep 8, 2023

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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.")
Copy link
Contributor

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?

Copy link
Contributor Author

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]",
Copy link
Contributor

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?

Copy link
Contributor Author

@Jiabao-Sun Jiabao-Sun Sep 8, 2023

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()
Copy link
Contributor

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?

Copy link
Contributor Author

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)
        }

Copy link
Contributor

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.

@Jiabao-Sun
Copy link
Contributor Author

Thanks @luoyuxia for detailed review.
Could you help review it again when you have time?
Thanks again!

@Jiabao-Sun Jiabao-Sun requested a review from luoyuxia September 8, 2023 15:06
Copy link
Contributor

@luoyuxia luoyuxia left a 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}
Copy link
Contributor

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()
Copy link
Contributor

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.

Copy link
Contributor

@luoyuxia luoyuxia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Jiabao-Sun
Copy link
Contributor Author

Thanks @luoyuxia, the CI passed.

@luoyuxia luoyuxia merged commit 50939cd into apache:master Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants