Skip to content

Conversation

@HuangXingBo
Copy link
Contributor

What is the purpose of the change

This pull request introduce Python Physical Correlate RelNodes which are containers for Python TableFunction

Brief change log

  • Add Physical Python Correlate Rule BatchExecPythonCorrelateRule ,StreamExecPythonCorrelateRule and DataStreamPythonCorrelateRule
  • Add Physical Python Correlate Node DataStreamPythonCorrelate, StreamExecPythonCorrelate and BatchExecPythonCorrelate

Verifying this change

This change added tests and can be verified as follows:

  • Added ut case testCorrelatePythonTableFunction

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, Yarn/Mesos, ZooKeeper: (no)
  • The S3 file system connector: (no)

Documentation

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

@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 68b0714 (Mon Feb 10 12:54:15 UTC 2020)

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.

Details
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 Feb 10, 2020

CI report:

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

Copy link
Contributor

@hequn8128 hequn8128 left a comment

Choose a reason for hiding this comment

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

@HuangXingBo Thanks a lot for the PR. Some comments below.

Comment on lines 120 to 125
for (i <- 0 until y) {
val row = new Row(2)
row.setField(0, x)
row.setField(1, i * i)
collect(row)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

How about remove these lines. The code will never be called.

Comment on lines 179 to 183
for (i <- 0 until y) {
val row = new Row(2)
row.setField(0, x)
row.setField(1, i * i)
collect(row)
Copy link
Contributor

Choose a reason for hiding this comment

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

How about remove these lines?

right match {
// right node is a table function
case scan: FlinkLogicalTableFunctionScan => true
// right node is a java table function
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think the right node must be a java table function. The original comment is ok.

// a filter is pushed above the table function
case calc: FlinkLogicalCalc if CorrelateUtil.getTableFunctionScan(calc).isDefined => true
case calc: FlinkLogicalCalc =>
PythonUtil.isNonPythonCall(CorrelateUtil.getTableFunctionScan(calc).get.getCall)
Copy link
Contributor

Choose a reason for hiding this comment

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

The method getTableFunctionScan may returns None.

scan: FlinkLogicalTableFunctionScan,
condition: Option[RexNode],
schema: RowSchema,
joinSchema: RowSchema,
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this member. It has never been used.


/**
* Flink RelNode which matches along with join a user defined table function.
* Flink RelNode which matches along with join a java user defined table function.
Copy link
Contributor

Choose a reason for hiding this comment

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

java => Java/Scala

// a filter is pushed above the table function
FlinkLogicalCalc calc = (FlinkLogicalCalc) right;
RelSubset input = (RelSubset) calc.getInput();
FlinkLogicalTableFunctionScan scan = (FlinkLogicalTableFunctionScan) input.getOriginal();
Copy link
Contributor

Choose a reason for hiding this comment

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

We can't cast the original node to FlinkLogicalTableFunctionScan.

private final RelNode right;

BatchExecPythonCorrelateFactory(RelNode rel) {
this.correlateRel = rel;
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this member?

* The factory is responsible to creating {@link StreamExecPythonCorrelate}.
*/
private static class StreamExecPythonCorrelateFactory {
private final RelNode correlateRel;
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this member.

}

/**
* The factory is responsible to creating {@link StreamExecPythonCorrelate}.
Copy link
Contributor

Choose a reason for hiding this comment

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

responsible to => responsible for

@HuangXingBo
Copy link
Contributor Author

Thanks a lot for @hequn8128 review, I have addressed the comments at the latest commit.

Copy link
Contributor

@hequn8128 hequn8128 left a comment

Choose a reason for hiding this comment

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

@HuangXingBo Thanks a lot for the update. The test failed due to the problems in BatchExecCorrelateBase and StreamExecCorrelateBase. See the detailed comments below.

As for the last commit that adding implementations for the Python Correlate RelNode, maybe it's better to add the commit later. Because in this PR, there are no ways to write tests to cover the implementation.

What do you think?


override def explainTerms(pw: RelWriter): RelWriter = {
val rexCall = scan.getCall.asInstanceOf[RexCall]
val sqlFunction = rexCall.getOperator.asInstanceOf[TableSqlFunction]
Copy link
Contributor

@hequn8128 hequn8128 Feb 17, 2020

Choose a reason for hiding this comment

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

The test failed due to this line. We can remove this line as it has never been used.
Remember to remove the useless import after removing this line.


override def explainTerms(pw: RelWriter): RelWriter = {
val rexCall = scan.getCall.asInstanceOf[RexCall]
val sqlFunction = rexCall.getOperator.asInstanceOf[TableSqlFunction]
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

@HuangXingBo
Copy link
Contributor Author

@HuangXingBo Thanks a lot for the update. The test failed due to the problems in BatchExecCorrelateBase and StreamExecCorrelateBase. See the detailed comments below.

As for the last commit that adding implementations for the Python Correlate RelNode, maybe it's better to add the commit later. Because in this PR, there are no ways to write tests to cover the implementation.

What do you think?

Thanks a lot for @hequn8128 , I will move the last commit to FLINK-15972.

@hequn8128
Copy link
Contributor

@flinkbot run travis

hequn8128 pushed a commit to hequn8128/flink that referenced this pull request Feb 18, 2020
@hequn8128
Copy link
Contributor

@HuangXingBo Hi, the jira id in the commit log is wrong. Would be great if you can check on this next time.
Merging...

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.

5 participants