Skip to content
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

[FLINK-27741][table-planner] Fix NPE when use dense_rank() and rank()… #19797

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chenzihao5
Copy link

Fix NPE when use dense_rank() and rank() in over aggregation.

What is the purpose of the change

This pull request fixes NullPointException when use DENSE_RANK() and RANK() for an append stream.

Brief change log

  • Judge the null value
  • Add ITCase for DENSE_RANK and RANK

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 May 23, 2022

CI report:

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

Copy link
Contributor

@xuyangzhong xuyangzhong left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution on fixing this bug. The code looks good to me overall and I left some comments on it. ; )

@@ -98,7 +98,7 @@ protected Expression orderKeyEqualsExpression() {
equalTo(lasValue, operand(i)));
}
Optional<Expression> ret = Arrays.stream(orderKeyEquals).reduce(ExpressionBuilder::and);
return ret.orElseGet(() -> literal(true));
return ret.orElseGet(() -> literal(false));
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi, I just wander why this value should be changed ?

Copy link
Author

Choose a reason for hiding this comment

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

@xuyangzhong The default value of true will cause the sort value to be unchanged, which I don't think conforms to the semantics of sorting.

@@ -159,6 +159,66 @@ class OverAggregateITCase(mode: StateBackendMode) extends StreamingWithStateTest
assertEquals(expected.sorted, sink.getAppendResults.sorted)
}

@Test
def testDenseRankOnOver(): Unit = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you can add some test cases for testing plan, not only just for ITCases.

Copy link
Author

Choose a reason for hiding this comment

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

Hi, @xuyangzhong . Thanks for your review and sorry for delay response. I didn't find the UT of AggFunctionFactory, so I borrowed the test for ROW_NUMBER. And I haven't waited for the community's reply, I can add corresponding unit tests later if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants