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-16337][python][table-planner][table-planner-blink] Add support of vectorized Python UDF in blink planner and old planner #11252

Closed
wants to merge 2 commits into from

Conversation

dianfu
Copy link
Contributor

@dianfu dianfu commented Feb 28, 2020

What is the purpose of the change

This pull request adds the relNodes and rules to support vectorized Python UDF in blink planner and old planner.

Brief change log

  • *Introduce relNodes and rules to support vectorized Python UDF in blink planner such as StreamExecArrowPythonCalc, BatchExecArrowPythonCalc, etc *
  • Introduce relNodes and rules to support vectorized Python UDF in old planner such as DataStreamArrowPythonCalc
  • Introduce PythonCalcSplitPandasInProjectionRule which is used to support use non-vectorized Python UDF and vectorized Python UDF in the same job

Verifying this change

This change added tests and can be verified as follows:

  • Added tests in PythonCalcSplitRuleTest

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/Mesos, 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

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 ec77755 (Fri Feb 28 13:09:25 UTC 2020)

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 Feb 28, 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

@dianfu dianfu force-pushed the FLINK-16337 branch 4 times, most recently from 10b2004 to d90b0eb Compare March 3, 2020 17:23
@hequn8128 hequn8128 self-assigned this Mar 4, 2020
@hequn8128 hequn8128 changed the title [FLINK-16337][python][table-planner-blink] Add support of vectorized Python UDF in blink planner [FLINK-16337][python][table-planner-blink] Add support of vectorized Python UDF in blink planner and old planner Mar 4, 2020
@hequn8128 hequn8128 changed the title [FLINK-16337][python][table-planner-blink] Add support of vectorized Python UDF in blink planner and old planner [FLINK-16337][python][table-planner][table-planner-blink] Add support of vectorized Python UDF in blink planner and old planner Mar 4, 2020
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.

@dianfu Thanks a lot for the PR. Overall it looks good to me except that I'm wondering if we can reuse the current PythonCalRule and PythonCalRelNode. The reasons are:

  • Most code between PythonCalcRule and ArrowPythonCalcRule, PythonCalRelNode and ArrowPythonCalRelNode are same.
  • The Rule even doesn't need to be changed if we reuse the Rule and RelNode.
  • The change in the RelNode would be also small, e.g., adding some if else to load the corresponding runtime operator.

Besides, is it possible to support pandas udf for batch mode in old planner?

What do you think?

@@ -32,51 +33,85 @@ object PythonUtil {
* @param node the RexNode to check
* @return true if it contains the Python function call in the specified node.
*/
def containsPythonCall(node: RexNode): Boolean = node.accept(new FunctionFinder(true, true))
def containsPythonCall(node: RexNode): Boolean =
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 merging the two containsPythonCall . I see two options:

  • Add a default parameter for pythonFunctionKind.
  • Add a GENERAL_PANDAS enum type in PythonFunctionKind.

/**
* Rule that converts [[FlinkLogicalCalc]] to [[BatchExecArrowPythonCalc]].
*/
class BatchExecArrowPythonCalcRule
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 reusing the current PythonCalcRule and PythonCalRelNode? Most code between PythonCalcRule and ArrowPythonCalcRule, PythonCalRelNode and ArrowPythonCalRelNode are same. The Rules even don't need to be changed.

Besides, we may need to convert this class to Java? In the long term, it's better to avoid new scala classes. Also see discussion here: #11051 (comment)

What do you think?

ret, getPythonWorkerMemory(planner.getTableConfig.getConfiguration))
}

private def getPythonWorkerMemory(config: Configuration): Long = {
Copy link
Contributor

Choose a reason for hiding this comment

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

This method is copied from BatchExecPythonCalc. How about putting this method into the CommonPythonCalc?

import org.apache.flink.table.functions.{FunctionContext, ScalarFunction, TableFunction}
import org.apache.flink.types.Row

Copy link
Contributor

Choose a reason for hiding this comment

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

Unnecessary changes.

@dianfu
Copy link
Contributor Author

dianfu commented Mar 5, 2020

@hequn8128 Thanks a lot for your great review and suggestions. That makes much sense to me and have updated the PR accordingly. Regarding to the support of pandas udf for batch mode in old planner, I'd like to add it in a separate PR as the operator for this case is still not added. What's your thoughts?

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.

@dianfu Thanks a lot for the update. LGTM. Will merge this once test passed.

hequn8128 pushed a commit to hequn8128/flink that referenced this pull request Mar 6, 2020
@hequn8128 hequn8128 closed this in 3ebc162 Mar 6, 2020
@dianfu dianfu deleted the FLINK-16337 branch June 10, 2020 02:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants