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-25379][connectors] Support limit push down in DATAGEN connector #18151

Merged
merged 1 commit into from
Apr 7, 2022

Conversation

ZhangChaoming
Copy link
Contributor

@ZhangChaoming ZhangChaoming commented Dec 20, 2021

What is the purpose of the change

Support limit push down in DATAGEN connector.

Brief change log

  • Support limit push down in DATAGEN connector.

Verifying this change

Apply LIMIT in datagen table query, see DataGeneratorConnectorITCase#testLimit.

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

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

Documentation

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

@flinkbot
Copy link
Collaborator

flinkbot commented Dec 20, 2021

CI report:

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

@flinkbot
Copy link
Collaborator

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 b2fc0dd (Mon Dec 20 07:18:03 UTC 2021)

Warnings:

  • No documentation files were touched! Remember to keep the Flink docs up to date!
  • This pull request references an unassigned Jira ticket. According to the code contribution guide, tickets need to be assigned before starting with the implementation work.

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

@ZhangChaoming
Copy link
Contributor Author

@flinkbot run azure

Copy link
Contributor

@MartijnVisser MartijnVisser left a comment

Choose a reason for hiding this comment

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

You can already specify the number of records for this connector per the documentation, see https://nightlies.apache.org/flink/flink-docs-stable/docs/connectors/table/datagen/

Copy link
Contributor

@slinkydeveloper slinkydeveloper left a comment

Choose a reason for hiding this comment

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

Nice change, can you add a simple test in DataGeneratorConnectorITCase that checks that using the LIMIT keyword instead of the number-of-rows option works fine?

@slinkydeveloper
Copy link
Contributor

@MartijnVisser this PR adds support for the limit keyword, that is instead of defining number-of-rows per doc, you can also omit that option and instead per query set the limit like this SELECT * FROM datagentable LIMIT 10

@slinkydeveloper
Copy link
Contributor

Thank you for the contribution @ZhangChaoming, just left another small comment and then it looks good!

@MartijnVisser
Copy link
Contributor

I am wondering if LIMIT is the best option for the Datagen connector, given the special circumstances for this connector because it generates random rows every time. I think LIMIT implies that a user wants to limit the available (or in this case, generated) results. If I would apply a LIMIT in combination with a specific reading position for Kafka, I get the same results over and over. That's not the case for Datagen of course, because it generates random values.

I rather be consistent in what LIMIT does for all connectors and keep the current method of number-of-rows to change the connector from unbounded to bounded, so a user doesn't have to read and understand the documentation that LIMIT does something differently for Datagen compared to other connectors.

@Airblader
Copy link
Contributor

The expectation that a query with LIMIT always returns the same results is only true for ordered output, which streaming queries don't support to begin with. I don't think the comparison to the Kafka connector is correct here; having to specify a fixed offset is an additional requirement (not mandated by the Kafka connector), and a similar thing could be done for datagen (specifying a seed for the RNG).

Let's keep in mind that the limit is already being applied, by Flink itself outside the source. The pushdown just allows the source itself to aid with that. I don't see a great reason why the datagen connector should need to support this, but I certainly don't see harm in it either.

@MartijnVisser
Copy link
Contributor

The expectation that a query with LIMIT always returns the same results is only true for ordered output, which streaming queries don't support to begin with.

For me the question is what a user expects when its applying LIMIT. The fact we don't (yet) support it is less relevant in that context. Is there anything on LIMIT in the SQL standards?

I don't see a great reason why the datagen connector should need to support this, but I certainly don't see harm in it either.

The harm I see is that we have two options to achieve apparently the same result, which could also be conflicting with each other ("What output can I expect when I set number-of-rows to 10 and LIMIT 5")?

@sjwiesman
Copy link
Contributor

@MartijnVisser

A datagen table with a set number of rows is BOUNDED and can be run under batch execution (this is why we added it originally). LIMIT is technically an orthogonal concept, but I agree it is murky.

@Airblader
Copy link
Contributor

The harm I see is that we have two options to achieve apparently the same result

But LIMIT does already work, it's just not pushed into the source (for this connector). For the user nothing really changes here(?)

What output can I expect when I set number-of-rows to 10 and LIMIT 5

Why should it behave differently than for any other bounded source to which a limit is applied?

@ZhangChaoming ZhangChaoming force-pushed the datagen-limit-push-down branch 2 times, most recently from 15cb79a to 74c203d Compare December 21, 2021 07:13
@MartijnVisser
Copy link
Contributor

But LIMIT does already work, it's just not pushed into the source (for this connector). For the user nothing really changes here(?)

If that's the case, then I agree that my argument is not applicable here.

Why should it behave differently than for any other bounded source to which a limit is applied?

It shouldn't, but Datagen itself behaves differently than any other bounded source because of its randomness.

@MartijnVisser
Copy link
Contributor

@ZhangChaoming Please have a look first at the CI, because the build is currently not passing

@ZhangChaoming ZhangChaoming force-pushed the datagen-limit-push-down branch 3 times, most recently from 95205ff to ec8d224 Compare March 18, 2022 02:48
@ZhangChaoming
Copy link
Contributor Author

@MartijnVisser I can not find any CI progress for this PR.

@MartijnVisser
Copy link
Contributor

@ZhangChaoming It always updates the one from the first comment, which you can find here #18151 (comment)

@ZhangChaoming ZhangChaoming force-pushed the datagen-limit-push-down branch 2 times, most recently from fc9c6f6 to 849140b Compare March 22, 2022 03:05
@ZhangChaoming
Copy link
Contributor Author

@flinkbot run azure

@ZhangChaoming
Copy link
Contributor Author

@MartijnVisser Thanks, check code style failed, I will fix it.

@ZhangChaoming
Copy link
Contributor Author

@MartijnVisser Pipeline still failed, but it seems the error was not caused by my code.

@MartijnVisser
Copy link
Contributor

@ZhangChaoming You should probably rebase your branch on the latest master to resolve those issues

@ZhangChaoming
Copy link
Contributor Author

ZhangChaoming commented Mar 28, 2022

@MartijnVisser I think my code is safe, since the error was caused by testing test_ci finegrained_resource_management. And This branch has no conflict with the base branch. Ref FLINK-26882

@MartijnVisser
Copy link
Contributor

@ZhangChaoming Still, I wouldn't merge it unless CI has fully passed. Note: you'll need a review from probably @slinkydeveloper before this could be merged

@ZhangChaoming
Copy link
Contributor Author

@flinkbot run azure

@ZhangChaoming
Copy link
Contributor Author

@MartijnVisser The CI has passed, and could you please review this PR?

@MartijnVisser
Copy link
Contributor

@ZhangChaoming I hope that @Airblader or @slinkydeveloper can take care of the review

@MartijnVisser MartijnVisser removed their request for review March 31, 2022 11:41
@ZhangChaoming
Copy link
Contributor Author

@flinkbot run azure

@ZhangChaoming
Copy link
Contributor Author

@MartijnVisser Could you please help review this ?

@MartijnVisser
Copy link
Contributor

slink

@slinkydeveloper Can you help with the review?

@MartijnVisser MartijnVisser merged commit ee28340 into apache:master Apr 7, 2022
@MartijnVisser
Copy link
Contributor

@slinkydeveloper Thanks for the review and @ZhangChaoming thanks for the PR. I've merged it.

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