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/08/10 07:26:35 UTC
[GitHub] [flink] dianfu opened a new pull request #13099: [FLINK-18848][python] Fix to_pandas to handle retraction data properly
dianfu opened a new pull request #13099:
URL: https://github.com/apache/flink/pull/13099
## What is the purpose of the change
*This pull request fix to_pandas to handle retraction data properly*
## Brief change log
- *fix to_pandas to handle retraction data properly*
## Verifying this change
This change added tests and can be verified as follows:
- *Added tests test_to_pandas_for_retract_table*
## 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)
----------------------------------------------------------------
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 #13099: [FLINK-18848][python] Fix to_pandas to handle retraction data properly
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13099:
URL: https://github.com/apache/flink/pull/13099#issuecomment-671214264
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "fb7db0d2124b3c76ce8f00ca266667f734cb879c",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5337",
"triggerID" : "fb7db0d2124b3c76ce8f00ca266667f734cb879c",
"triggerType" : "PUSH"
}, {
"hash" : "9a00303f439ee4020c46565de7adfb4dafa74e0a",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5354",
"triggerID" : "9a00303f439ee4020c46565de7adfb4dafa74e0a",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 9a00303f439ee4020c46565de7adfb4dafa74e0a Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5354)
<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 #13099: [FLINK-18848][python] Fix to_pandas to handle retraction data properly
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13099:
URL: https://github.com/apache/flink/pull/13099#issuecomment-671214264
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "fb7db0d2124b3c76ce8f00ca266667f734cb879c",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5337",
"triggerID" : "fb7db0d2124b3c76ce8f00ca266667f734cb879c",
"triggerType" : "PUSH"
}, {
"hash" : "9a00303f439ee4020c46565de7adfb4dafa74e0a",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5354",
"triggerID" : "9a00303f439ee4020c46565de7adfb4dafa74e0a",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* fb7db0d2124b3c76ce8f00ca266667f734cb879c Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5337)
* 9a00303f439ee4020c46565de7adfb4dafa74e0a Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5354)
<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 closed pull request #13099: [FLINK-18848][python] Fix to_pandas to handle retraction data properly
Posted by GitBox <gi...@apache.org>.
dianfu closed pull request #13099:
URL: https://github.com/apache/flink/pull/13099
----------------------------------------------------------------
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 #13099: [FLINK-18848][python] Fix to_pandas to handle retraction data properly
Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #13099:
URL: https://github.com/apache/flink/pull/13099#issuecomment-671204456
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 fb7db0d2124b3c76ce8f00ca266667f734cb879c (Mon Aug 10 07:29:09 UTC 2020)
✅no warnings
<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 #13099: [FLINK-18848][python] Fix to_pandas to handle retraction data properly
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13099:
URL: https://github.com/apache/flink/pull/13099#issuecomment-671214264
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "fb7db0d2124b3c76ce8f00ca266667f734cb879c",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5337",
"triggerID" : "fb7db0d2124b3c76ce8f00ca266667f734cb879c",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* fb7db0d2124b3c76ce8f00ca266667f734cb879c Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5337)
<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 #13099: [FLINK-18848][python] Fix to_pandas to handle retraction data properly
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13099:
URL: https://github.com/apache/flink/pull/13099#issuecomment-671214264
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "fb7db0d2124b3c76ce8f00ca266667f734cb879c",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5337",
"triggerID" : "fb7db0d2124b3c76ce8f00ca266667f734cb879c",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* fb7db0d2124b3c76ce8f00ca266667f734cb879c Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5337)
<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 #13099: [FLINK-18848][python] Fix to_pandas to handle retraction data properly
Posted by GitBox <gi...@apache.org>.
WeiZhong94 commented on a change in pull request #13099:
URL: https://github.com/apache/flink/pull/13099#discussion_r468369160
##########
File path: flink-python/src/main/java/org/apache/flink/table/runtime/arrow/ArrowUtils.java
##########
@@ -679,6 +707,24 @@ public boolean hasNext() {
};
}
+ private static Iterator<Row> filterOutRetractRows(Iterator<Row> data) {
+ LinkedHashMultiset<Row> result = LinkedHashMultiset.create();
+ while (data.hasNext()) {
+ Row element = data.next();
+ if (element.getKind() == RowKind.INSERT || element.getKind() == RowKind.UPDATE_AFTER) {
+ element.setKind(RowKind.INSERT);
+ result.add(element);
+ } else {
+ element.setKind(RowKind.INSERT);
+ if (!result.remove(element)) {
+ throw new RuntimeException(
+ String.format("Could not remove element '%s', should never happen", element));
Review comment:
ditto
##########
File path: flink-python/src/main/java/org/apache/flink/table/runtime/arrow/ArrowUtils.java
##########
@@ -611,6 +617,21 @@ private static void readFully(ReadableByteChannel channel, ByteBuffer dst) throw
*/
public static CustomIterator<byte[]> collectAsPandasDataFrame(Table table, int maxArrowBatchSize) throws Exception {
checkArrowUsable();
+ boolean isRetractTable = false;
+ if (isStreamingMode(table)) {
+ StreamTableEnvironment tableEnv = (StreamTableEnvironment) ((TableImpl) table).getTableEnvironment();
+ try {
+ tableEnv.toAppendStream(table, Row.class);
+ } catch (Throwable t) {
+ if (t.getMessage().contains("toAppendStream doesn't support consuming update changes") ||
+ t.getMessage().contains("Table is not an append-only table")) {
+ isRetractTable = true;
+ } else {
+ throw new RuntimeException("Failed to determine whether the given table is append only", t);
Review comment:
Add a period at the end?
##########
File path: flink-python/src/main/java/org/apache/flink/table/runtime/arrow/ArrowUtils.java
##########
@@ -692,6 +738,22 @@ private static boolean isBlinkPlanner(Table table) {
}
}
+ private static boolean isStreamingMode(Table table) throws Exception {
+ TableEnvironment tableEnv = ((TableImpl) table).getTableEnvironment();
+ if (tableEnv instanceof BatchTableEnvironment || tableEnv instanceof BatchTableEnvImpl) {
+ return false;
+ } else if (tableEnv instanceof StreamTableEnvironment) {
+ return true;
+ } else if (tableEnv instanceof TableEnvironmentImpl) {
+ java.lang.reflect.Field isStreamingModeMethod = TableEnvironmentImpl.class.getDeclaredField("isStreamingMode");
+ isStreamingModeMethod.setAccessible(true);
+ return (boolean) isStreamingModeMethod.get(tableEnv);
+ } else {
+ throw new RuntimeException(String.format(
+ "Could not determine the streaming mode for table environment class %s", tableEnv.getClass()));
Review comment:
ditto
##########
File path: flink-python/pyflink/table/tests/test_pandas_conversion.py
##########
@@ -157,4 +167,5 @@ class BlinkBatchPandasConversionTests(PandasConversionTests,
class BlinkStreamPandasConversionTests(PandasConversionITTests,
PyFlinkBlinkStreamTableTestCase):
+
Review comment:
unnecessary changes
----------------------------------------------------------------
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 #13099: [FLINK-18848][python] Fix to_pandas to handle retraction data properly
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13099:
URL: https://github.com/apache/flink/pull/13099#issuecomment-671214264
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "fb7db0d2124b3c76ce8f00ca266667f734cb879c",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5337",
"triggerID" : "fb7db0d2124b3c76ce8f00ca266667f734cb879c",
"triggerType" : "PUSH"
}, {
"hash" : "9a00303f439ee4020c46565de7adfb4dafa74e0a",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "9a00303f439ee4020c46565de7adfb4dafa74e0a",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* fb7db0d2124b3c76ce8f00ca266667f734cb879c Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5337)
* 9a00303f439ee4020c46565de7adfb4dafa74e0a 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 #13099: [FLINK-18848][python] Fix to_pandas to handle retraction data properly
Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #13099:
URL: https://github.com/apache/flink/pull/13099#issuecomment-671214264
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "fb7db0d2124b3c76ce8f00ca266667f734cb879c",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "fb7db0d2124b3c76ce8f00ca266667f734cb879c",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* fb7db0d2124b3c76ce8f00ca266667f734cb879c 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] dianfu commented on pull request #13099: [FLINK-18848][python] Fix to_pandas to handle retraction data properly
Posted by GitBox <gi...@apache.org>.
dianfu commented on pull request #13099:
URL: https://github.com/apache/flink/pull/13099#issuecomment-671808829
@WeiZhong94 Thanks for the review. I will address the comments when merging 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