You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/09/04 05:32:28 UTC
[GitHub] [flink] dianfu opened a new pull request #13325: [FLINK-15974][python] Support to use the Python UDF directly in the Python Table API
dianfu opened a new pull request #13325:
URL: https://github.com/apache/flink/pull/13325
## What is the purpose of the change
*This pull request add support to use the Python UDF directly in the Python Table API. E.g. for Python UDF inc, users could use it directly in the Python Table API: tab.select(inc(tab.a)).insert_into("sink")*
## Verifying this change
This change is already covered by the updated existing tests test_udf.py, test_pandas_udf.py, etc.*.
## 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? (yes)
- If yes, how is the feature documented? (Will add documentation in a separate PR)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #13325: [FLINK-15974][python] Support to use the Python UDF directly in the Python Table API
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13325:
URL: https://github.com/apache/flink/pull/13325#issuecomment-686925091
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "26abf1ecf936d0232c6d49c0bdd4fe3beae6252e",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=6187",
"triggerID" : "26abf1ecf936d0232c6d49c0bdd4fe3beae6252e",
"triggerType" : "PUSH"
}, {
"hash" : "6f65076badbf59b1ded4e7778a0349d489138e7f",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "6f65076badbf59b1ded4e7778a0349d489138e7f",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 26abf1ecf936d0232c6d49c0bdd4fe3beae6252e Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=6187)
* 6f65076badbf59b1ded4e7778a0349d489138e7f UNKNOWN
<details>
<summary>Bot commands</summary>
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
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot commented on pull request #13325: [FLINK-15974][python] Support to use the Python UDF directly in the Python Table API
Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #13325:
URL: https://github.com/apache/flink/pull/13325#issuecomment-686918964
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 26abf1ecf936d0232c6d49c0bdd4fe3beae6252e (Fri Sep 04 05:34:06 UTC 2020)
**Warnings:**
* No documentation files were touched! Remember to keep the Flink docs up to date!
<sub>Mention the bot in a comment to re-run the automated checks.</sub>
## 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](https://flink.apache.org/contributing/reviewing-prs.html) 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 <summary>Bot commands</summary>
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
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #13325: [FLINK-15974][python] Support to use the Python UDF directly in the Python Table API
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13325:
URL: https://github.com/apache/flink/pull/13325#issuecomment-686925091
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "26abf1ecf936d0232c6d49c0bdd4fe3beae6252e",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=6187",
"triggerID" : "26abf1ecf936d0232c6d49c0bdd4fe3beae6252e",
"triggerType" : "PUSH"
}, {
"hash" : "6f65076badbf59b1ded4e7778a0349d489138e7f",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=6195",
"triggerID" : "6f65076badbf59b1ded4e7778a0349d489138e7f",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 26abf1ecf936d0232c6d49c0bdd4fe3beae6252e Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=6187)
* 6f65076badbf59b1ded4e7778a0349d489138e7f Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=6195)
<details>
<summary>Bot commands</summary>
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
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] dianfu merged pull request #13325: [FLINK-15974][python] Support to use the Python UDF directly in the Python Table API
Posted by GitBox <gi...@apache.org>.
dianfu merged pull request #13325:
URL: https://github.com/apache/flink/pull/13325
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] dianfu commented on pull request #13325: [FLINK-15974][python] Support to use the Python UDF directly in the Python Table API
Posted by GitBox <gi...@apache.org>.
dianfu commented on pull request #13325:
URL: https://github.com/apache/flink/pull/13325#issuecomment-686950814
@WeiZhong94 Thanks for the review. Updated the PR.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #13325: [FLINK-15974][python] Support to use the Python UDF directly in the Python Table API
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13325:
URL: https://github.com/apache/flink/pull/13325#issuecomment-686925091
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "26abf1ecf936d0232c6d49c0bdd4fe3beae6252e",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=6187",
"triggerID" : "26abf1ecf936d0232c6d49c0bdd4fe3beae6252e",
"triggerType" : "PUSH"
}, {
"hash" : "6f65076badbf59b1ded4e7778a0349d489138e7f",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=6195",
"triggerID" : "6f65076badbf59b1ded4e7778a0349d489138e7f",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 6f65076badbf59b1ded4e7778a0349d489138e7f Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=6195)
<details>
<summary>Bot commands</summary>
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
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] WeiZhong94 commented on a change in pull request #13325: [FLINK-15974][python] Support to use the Python UDF directly in the Python Table API
Posted by GitBox <gi...@apache.org>.
WeiZhong94 commented on a change in pull request #13325:
URL: https://github.com/apache/flink/pull/13325#discussion_r483411913
##########
File path: flink-python/pyflink/table/expressions.py
##########
@@ -538,9 +538,44 @@ def call(f: Union[str, UserDefinedFunctionWrapper], *args) -> Expression:
:param args: parameters of the user-defined function.
"""
gateway = get_gateway()
- return Expression(gateway.jvm.Expressions.call(
- f if isinstance(f, str) else f.java_user_defined_function(),
- to_jarray(gateway.jvm.Object, [_get_java_expression(arg) for arg in args])))
+
+ if isinstance(f, str):
+ return Expression(gateway.jvm.Expressions.call(
+ f, to_jarray(gateway.jvm.Object, [_get_java_expression(arg) for arg in args])))
+
+ def get_function_definition(f):
+ if isinstance(f, UserDefinedTableFunctionWrapper):
+ """
+ TypeInference was not supported for TableFunction in the old planner. Use
+ TableFunctionDefinition to work around this issue.
+ """
+ j_result_types = to_jarray(gateway.jvm.TypeInformation,
+ [_to_java_type(i) for i in f._result_types])
+ j_result_type = gateway.jvm.org.apache.flink.api.java.typeutils.RowTypeInfo(
+ j_result_types)
+ return gateway.jvm.org.apache.flink.table.functions.TableFunctionDefinition(
+ 'f', f.java_user_defined_function(), j_result_type)
+ else:
+ return f.java_user_defined_function()
+
+ expressions_clz = gateway.jvm.Class \
Review comment:
Can be replaced by pyflink.util.utils.load_java_class()?
##########
File path: flink-python/pyflink/table/udf.py
##########
@@ -184,6 +184,10 @@ def __init__(self, func, input_types, deterministic=None, name=None):
self._deterministic = deterministic if deterministic is not None else (
func.is_deterministic() if isinstance(func, UserDefinedFunction) else True)
+ def __call__(self, *args):
Review comment:
add a type hint?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #13325: [FLINK-15974][python] Support to use the Python UDF directly in the Python Table API
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13325:
URL: https://github.com/apache/flink/pull/13325#issuecomment-686925091
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "26abf1ecf936d0232c6d49c0bdd4fe3beae6252e",
"status" : "CANCELED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=6187",
"triggerID" : "26abf1ecf936d0232c6d49c0bdd4fe3beae6252e",
"triggerType" : "PUSH"
}, {
"hash" : "6f65076badbf59b1ded4e7778a0349d489138e7f",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=6195",
"triggerID" : "6f65076badbf59b1ded4e7778a0349d489138e7f",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 26abf1ecf936d0232c6d49c0bdd4fe3beae6252e Azure: [CANCELED](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=6187)
* 6f65076badbf59b1ded4e7778a0349d489138e7f Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=6195)
<details>
<summary>Bot commands</summary>
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
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #13325: [FLINK-15974][python] Support to use the Python UDF directly in the Python Table API
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13325:
URL: https://github.com/apache/flink/pull/13325#issuecomment-686925091
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "26abf1ecf936d0232c6d49c0bdd4fe3beae6252e",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=6187",
"triggerID" : "26abf1ecf936d0232c6d49c0bdd4fe3beae6252e",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 26abf1ecf936d0232c6d49c0bdd4fe3beae6252e Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=6187)
<details>
<summary>Bot commands</summary>
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
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot commented on pull request #13325: [FLINK-15974][python] Support to use the Python UDF directly in the Python Table API
Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #13325:
URL: https://github.com/apache/flink/pull/13325#issuecomment-686925091
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "26abf1ecf936d0232c6d49c0bdd4fe3beae6252e",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "26abf1ecf936d0232c6d49c0bdd4fe3beae6252e",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 26abf1ecf936d0232c6d49c0bdd4fe3beae6252e UNKNOWN
<details>
<summary>Bot commands</summary>
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
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org