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-14053] [blink-planner] DenseRankAggFunction.accumulateExpressions. it should be thinki… #9966

Closed
wants to merge 6 commits into from

Conversation

liuyongvs
Copy link
Contributor

What is the purpose of the change

  • dense_rank is not thinking about the the order by expression equals to inital lastValue. This PR is to fix this corner case

Brief change log

  • modify the logic
  • add one unit test

Does this pull request potentially affect one of the following parts:

  • doen't affect others

Documentation

Does this pull request introduce a new feature? (yes / no)
If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)

…ng about a corner case when the order by expression equals to inital lastValue.
@flinkbot
Copy link
Collaborator

flinkbot commented Oct 22, 2019

Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
to review your pull request. We will use this comment to track the progress of the review.

Automated Checks

Last check on commit c877c93 (Thu Oct 24 18:07:50 UTC 2019)

Warnings:

  • No documentation files were touched! Remember to keep the Flink docs up to date!

Mention the bot in a comment to re-run the automated checks.

Review Progress

  • ❓ 1. The [description] looks good.
  • ❓ 2. There is [consensus] that the contribution should go into to Flink.
  • ❓ 3. Needs [attention] from.
  • ❓ 4. The change fits into the overall [architecture].
  • ❓ 5. Overall code [quality] is good.

Please see the Pull Request Review Guide for a full explanation of the review process.


The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required Bot commands
The @flinkbot bot supports the following commands:

  • @flinkbot approve description to approve one or more aspects (aspects: description, consensus, architecture and quality)
  • @flinkbot approve all to approve all aspects
  • @flinkbot approve-until architecture to approve everything until architecture
  • @flinkbot attention @username1 [@username2 ..] to require somebody's attention
  • @flinkbot disapprove architecture to remove an approval you gave earlier

@flinkbot
Copy link
Collaborator

flinkbot commented Oct 22, 2019

CI report:

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

Copy link
Contributor

@KurtYoung KurtYoung 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 fixing this @liuyongvs

import static org.apache.flink.table.expressions.ExpressionBuilder.ifThenElse;
import static org.apache.flink.table.expressions.ExpressionBuilder.literal;
import static org.apache.flink.table.expressions.ExpressionBuilder.plus;
import static org.apache.flink.table.expressions.ExpressionBuilder.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't use import *

Copy link
Contributor Author

Choose a reason for hiding this comment

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

got it

// sequence = if (lastValues equalTo orderKeys) sequence else sequence + 1
accExpressions[0] = ifThenElse(orderKeyEqualsExpression(), sequence, plus(sequence, literal(1L)));
// sequence = if (lastValues equalTo orderKeys and sequence != 0) sequence else sequence + 1
accExpressions[0] = ifThenElse(and(orderKeyEqualsExpression(), not(equalTo(sequence, literal(0L)))), sequence, plus(sequence, literal(1L)));
Copy link
Contributor

Choose a reason for hiding this comment

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

inside orderKeyEqualsExpression(), we already compare the last_value with null which is the initial value. Why this conflicts with the order by key's value? Do you mean the order by key is null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you scan see the unit test i commit. it will be zero rank

@KurtYoung
Copy link
Contributor

Your base branch seems to be wrong, please use latest master branch and create a fix based on that.

@liuyongvs
Copy link
Contributor Author

Your base branch seems to be wrong, please use latest master branch and create a fix based on that.

Thanks, i found the conflict when i commited because of my personal respository, which it not the latest.

@liuyongvs
Copy link
Contributor Author

Your base branch seems to be wrong, please use latest master branch and create a fix based on that.

Hi @KurtYoung , I have already recolved the conflicts.

@KurtYoung
Copy link
Contributor

@liuyongvs There are some compilation errors, please fix it first.


// deal with input with 0 as the first row's rank field
checkResult(
"SELECT f, dense_rank() over (order by d) FROM Table5",
Copy link
Contributor

Choose a reason for hiding this comment

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

If I don't misunderstood anything, your test seems to be wrong.
The data of column d is 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, how could it possible that the dense_rank on column d becomes 1, 2, 3, ..., 14, 15?

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, i made a mistake becase of careless

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it should be SELECT f, dense_rank() over (order by f) FROM Table5

Copy link
Contributor

@KurtYoung KurtYoung left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the fix.

@KurtYoung
Copy link
Contributor

Merging this, but please don't open a pull request against master branch based on a non-master branch next time.. @liuyongvs

@KurtYoung KurtYoung closed this in 37f67b7 Oct 24, 2019
@liuyongvs liuyongvs deleted the master-rc branch October 26, 2019 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants