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-24907] Support side out late data for interval join #18118

Merged
merged 6 commits into from
Sep 19, 2022

Conversation

chenyuzhi459
Copy link
Contributor

@chenyuzhi459 chenyuzhi459 commented Dec 15, 2021

What is the purpose of the change

This pull requst makes interval-join support side out late data.

Brief change log

Add OutputTag for left and right stream in org.apache.flink.streaming.api.operators.co.IntervalJoinOperator, and emit late data when isLate(ourTimestamp) = true

Verifying this change

IntervalJoinITCase.testIntervalJoinSideOutputLeftLateData
IntervalJoinITCase.testIntervalJoinSideOutputRightLateData

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

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 d8e09a1 (Wed Dec 15 11:06:23 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

@flinkbot
Copy link
Collaborator

flinkbot commented Dec 15, 2021

CI report:

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

@chenyuzhi459
Copy link
Contributor Author

@flinkbot re-run azure

@MartijnVisser
Copy link
Contributor

@gyfora Is this a PR that you could review? I recall that this was mentioned in the Flink Slack channel?

@gyfora
Copy link
Contributor

gyfora commented Aug 31, 2022

Thanks, I or someone from my team will review this ASAP .

@gyfora
Copy link
Contributor

gyfora commented Aug 31, 2022

@gaborgsomogyi will help reviewing this feature.

Copy link
Contributor

@gaborgsomogyi gaborgsomogyi left a comment

Choose a reason for hiding this comment

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

The functionality looks good in general, I have only a minor comment to refactor the tests.

@@ -155,6 +157,134 @@ public void testJoinsCorrectlyWithMultipleKeys() throws Exception {
"(key2,5):(key2,5)");
}

@Test
public void testIntervalJoinSideOutputLeftLateData() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

The 2 tests are 99% the same. Can we do something to merge then into a single function call w/ parameters?
For example the content of run can be a function pointer to the extracted function or something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your tips! I have merged the 2 tests into one test method by sideout the late data of left and right side at the same time .
Should I continue to extracted the run content ? Cause I am a little confuse about how to do that.

Copy link
Contributor

Choose a reason for hiding this comment

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

It would be better to have a private function which is called from 2 different tests in order not to mix-up left and right functionality but I'm personally fine w/ the actual code stand. It's a little bit harder to understand what's going on inside this single test but not horror.

Copy link
Contributor

Choose a reason for hiding this comment

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

The technique is create a function like

private void testIntervalJoinSideOutput(Consumer<SourceContext<Tuple2<String, Integer>>> streamOneRun) {
...
        DataStream<Tuple2<String, Integer>> streamOne =
                env.addSource(
                        new SourceFunction<Tuple2<String, Integer>>() {
                            @Override
                            public void run(SourceContext<Tuple2<String, Integer>> ctx) {
                                streamOneRun.accept(ctx);
                            }

                            @Override
                            public void cancel() {
                                // do nothing
                            }
                        });
...
}

and call it like this:

    @Test
    public void testIntervalJoinSideOutputLeftLateData() throws Exception {
        testIntervalJoinSideOutput(ctx -> {
          ctx.collectWithTimestamp(Tuple2.of("key", 2), 2L);
          ctx.collectWithTimestamp(Tuple2.of("key", 3), 3L);
          ctx.emitWatermark(new Watermark(3));
          ctx.collectWithTimestamp(Tuple2.of("key", 1), 1L); // late data
        });
...
        expectInAnyOrder("(key,1)");
}

Be aware that this may or may not compile, just wanted to show the way :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, I understand what you mean, thanks very much!
I have extracted the run content as a Consumer function

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good, thanks.

@chenyuzhi459
Copy link
Contributor Author

chenyuzhi459 commented Sep 7, 2022

@flinkbot run azure

@gaborgsomogyi
Copy link
Contributor

Test failed w/ unrelated error.

@gaborgsomogyi
Copy link
Contributor

@flinkbot re-run azure

.sideOutputLeftLateData(late)
.process(new CombineToStringJoinFunction());

process.getSideOutput(late)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to be complete a last beautification can be added, namely we can create a function something like and call it from the 2 places:

private void addSinkToSideOutput(...) {
...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, it has been optimized.

@gaborgsomogyi
Copy link
Contributor

When the last minor is resolved + unit tests passed then it's good to go.

Copy link
Contributor

@gaborgsomogyi gaborgsomogyi left a comment

Choose a reason for hiding this comment

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

LGTM.

@gaborgsomogyi
Copy link
Contributor

@flinkbot run azure

@gaborgsomogyi
Copy link
Contributor

Seems like there is a permanent issue w/ jenkins:

E: Unsupported file ./libssl1.0.0_1.0.2n-1ubuntu5.7_amd64.deb given on commandline

@MartijnVisser
Copy link
Contributor

@gaborgsomogyi The PR needs to be rebated since it doesn't contains the latest necessary changes to run the CI

@gaborgsomogyi
Copy link
Contributor

@MartijnVisser expected something like this. @chenyuzhi459 could you do a rebase to the latest master please?

@chenyuzhi459 chenyuzhi459 force-pushed the FLINK-24907-sideout-intervaljoin branch from d023ec5 to af9887e Compare September 9, 2022 13:21
@chenyuzhi459
Copy link
Contributor Author

@MartijnVisser expected something like this. @chenyuzhi459 could you do a rebase to the latest master please?

Ok, I have rebased it.

@chenyuzhi459
Copy link
Contributor Author

@flinkbot run azure

1 similar comment
@gaborgsomogyi
Copy link
Contributor

@flinkbot run azure

@gaborgsomogyi
Copy link
Contributor

Jenkins passed, good to go from my perspective.

@gyfora gyfora merged commit b515da4 into apache:master Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants