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 2021/05/30 07:46:18 UTC
[GitHub] [flink] beyond1920 opened a new pull request #16024: [FLINK-22038][table-planner-blink] Update TopN to be without rowNumber if rowNumber field is never used by the successor Calc
beyond1920 opened a new pull request #16024:
URL: https://github.com/apache/flink/pull/16024
## What is the purpose of the change
This pull request aims to do an improvement about TopN, it is to update TopN to be without rowNumber if rowNumber field is never used by the successor Calc.
## Brief change log
- Rename original `RankNumberColumnRemoveRule` to `ConstantRankNumberColumnRemoveRule` to distinguish with the new introduced `RedundantRankNumberColumnRemoveRule`
- Introduce `RedundantRankNumberColumnRemoveRule` to update TopN to be without rowNumber if rowNumber field is never used by the successor Calc
## Verifying this change
- Add UT in `RankTest`
## 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 #16024: [FLINK-22038][table-planner-blink] Update TopN to be without rowNumber if rowNumber field is never used by the successor Calc
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #16024:
URL: https://github.com/apache/flink/pull/16024#issuecomment-850960580
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "b1e458736ba06e8ab0dabcb14e1a77fc4068270c",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=18419",
"triggerID" : "b1e458736ba06e8ab0dabcb14e1a77fc4068270c",
"triggerType" : "PUSH"
}, {
"hash" : "d38e029356e1953280b072089f545739893931c3",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "d38e029356e1953280b072089f545739893931c3",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* b1e458736ba06e8ab0dabcb14e1a77fc4068270c Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=18419)
* d38e029356e1953280b072089f545739893931c3 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 edited a comment on pull request #16024: [FLINK-22038][table-planner-blink] Update TopN to be without rowNumber if rowNumber field is never used by the successor Calc
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #16024:
URL: https://github.com/apache/flink/pull/16024#issuecomment-850960580
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "b1e458736ba06e8ab0dabcb14e1a77fc4068270c",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=18419",
"triggerID" : "b1e458736ba06e8ab0dabcb14e1a77fc4068270c",
"triggerType" : "PUSH"
}, {
"hash" : "d38e029356e1953280b072089f545739893931c3",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=18528",
"triggerID" : "d38e029356e1953280b072089f545739893931c3",
"triggerType" : "PUSH"
}, {
"hash" : "37c65699113155acb03ef5b4da91d02b16fadf17",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=18561",
"triggerID" : "37c65699113155acb03ef5b4da91d02b16fadf17",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 37c65699113155acb03ef5b4da91d02b16fadf17 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=18561)
<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] rmetzger commented on pull request #16024: [FLINK-22038][table-planner-blink] Update TopN to be without rowNumber if rowNumber field is never used by the successor Calc
Posted by GitBox <gi...@apache.org>.
rmetzger commented on pull request #16024:
URL: https://github.com/apache/flink/pull/16024#issuecomment-854072045
This commit broke master https://dev.azure.com/apache-flink/apache-flink/_build/results?buildId=18646&view=logs&j=52b61abe-a3cc-5bde-cc35-1bbe89bb7df5&t=54421a62-0c80-5aad-3319-094ff69180bb
--
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 #16024: [FLINK-22038][table-planner-blink] Update TopN to be without rowNumber if rowNumber field is never used by the successor Calc
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #16024:
URL: https://github.com/apache/flink/pull/16024#issuecomment-850960580
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "b1e458736ba06e8ab0dabcb14e1a77fc4068270c",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=18419",
"triggerID" : "b1e458736ba06e8ab0dabcb14e1a77fc4068270c",
"triggerType" : "PUSH"
}, {
"hash" : "d38e029356e1953280b072089f545739893931c3",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=18528",
"triggerID" : "d38e029356e1953280b072089f545739893931c3",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* b1e458736ba06e8ab0dabcb14e1a77fc4068270c Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=18419)
* d38e029356e1953280b072089f545739893931c3 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=18528)
<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 #16024: [FLINK-22038][table-planner-blink] Update TopN to be without rowNumber if rowNumber field is never used by the successor Calc
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #16024:
URL: https://github.com/apache/flink/pull/16024#issuecomment-850960580
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "b1e458736ba06e8ab0dabcb14e1a77fc4068270c",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=18419",
"triggerID" : "b1e458736ba06e8ab0dabcb14e1a77fc4068270c",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* b1e458736ba06e8ab0dabcb14e1a77fc4068270c Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=18419)
<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] godfreyhe closed pull request #16024: [FLINK-22038][table-planner-blink] Update TopN to be without rowNumber if rowNumber field is never used by the successor Calc
Posted by GitBox <gi...@apache.org>.
godfreyhe closed pull request #16024:
URL: https://github.com/apache/flink/pull/16024
--
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 #16024: [FLINK-22038][table-planner-blink] Update TopN to be without rowNumber if rowNumber field is never used by the successor Calc
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #16024:
URL: https://github.com/apache/flink/pull/16024#issuecomment-850957894
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 37c65699113155acb03ef5b4da91d02b16fadf17 (Sat Aug 28 12:15:11 UTC 2021)
**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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] beyond1920 commented on pull request #16024: [FLINK-22038][table-planner-blink] Update TopN to be without rowNumber if rowNumber field is never used by the successor Calc
Posted by GitBox <gi...@apache.org>.
beyond1920 commented on pull request #16024:
URL: https://github.com/apache/flink/pull/16024#issuecomment-852902155
@godfreyhe I've port `RedundantRankNumberColumnRemoveRule` to java and fix failed testcases. Please have a look. Thanks a lot.
--
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] godfreyhe commented on pull request #16024: [FLINK-22038][table-planner-blink] Update TopN to be without rowNumber if rowNumber field is never used by the successor Calc
Posted by GitBox <gi...@apache.org>.
godfreyhe commented on pull request #16024:
URL: https://github.com/apache/flink/pull/16024#issuecomment-852659321
@beyond1920 some tests failed
--
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 #16024: [FLINK-22038][table-planner-blink] Update TopN to be without rowNumber if rowNumber field is never used by the successor Calc
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #16024:
URL: https://github.com/apache/flink/pull/16024#issuecomment-850960580
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "b1e458736ba06e8ab0dabcb14e1a77fc4068270c",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=18419",
"triggerID" : "b1e458736ba06e8ab0dabcb14e1a77fc4068270c",
"triggerType" : "PUSH"
}, {
"hash" : "d38e029356e1953280b072089f545739893931c3",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=18528",
"triggerID" : "d38e029356e1953280b072089f545739893931c3",
"triggerType" : "PUSH"
}, {
"hash" : "37c65699113155acb03ef5b4da91d02b16fadf17",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=18561",
"triggerID" : "37c65699113155acb03ef5b4da91d02b16fadf17",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* d38e029356e1953280b072089f545739893931c3 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=18528)
* 37c65699113155acb03ef5b4da91d02b16fadf17 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=18561)
<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] godfreyhe closed pull request #16024: [FLINK-22038][table-planner-blink] Update TopN to be without rowNumber if rowNumber field is never used by the successor Calc
Posted by GitBox <gi...@apache.org>.
godfreyhe closed pull request #16024:
URL: https://github.com/apache/flink/pull/16024
--
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] beyond1920 commented on a change in pull request #16024: [FLINK-22038][table-planner-blink] Update TopN to be without rowNumber if rowNumber field is never used by the successor Calc
Posted by GitBox <gi...@apache.org>.
beyond1920 commented on a change in pull request #16024:
URL: https://github.com/apache/flink/pull/16024#discussion_r643086398
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/rules/FlinkStreamRuleSets.scala
##########
@@ -374,6 +374,8 @@ object FlinkStreamRuleSets {
PythonCorrelateSplitRule.INSTANCE,
// merge calc after calc transpose
FlinkCalcMergeRule.INSTANCE,
+ // remove output of rank number when it is not used by successor calc
+ RedundantRankNumberColumnRemoveRule.INSTANCE,
Review comment:
Because rank rules works in logical phase in batch, and works in physical phase in stream.
--
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 #16024: [FLINK-22038][table-planner-blink] Update TopN to be without rowNumber if rowNumber field is never used by the successor Calc
Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #16024:
URL: https://github.com/apache/flink/pull/16024#issuecomment-850960580
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "b1e458736ba06e8ab0dabcb14e1a77fc4068270c",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "b1e458736ba06e8ab0dabcb14e1a77fc4068270c",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* b1e458736ba06e8ab0dabcb14e1a77fc4068270c 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] beyond1920 commented on a change in pull request #16024: [FLINK-22038][table-planner-blink] Update TopN to be without rowNumber if rowNumber field is never used by the successor Calc
Posted by GitBox <gi...@apache.org>.
beyond1920 commented on a change in pull request #16024:
URL: https://github.com/apache/flink/pull/16024#discussion_r643103674
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/rules/logical/RedundantRankNumberColumnRemoveRule.scala
##########
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.plan.rules.logical
+
+import org.apache.flink.table.planner.plan.nodes.logical.{FlinkLogicalCalc, FlinkLogicalRank}
+import org.apache.flink.table.planner.plan.utils.InputRefVisitor
+
+import org.apache.calcite.plan.RelOptRule.{any, operand}
+import org.apache.calcite.plan.{RelOptRule, RelOptRuleCall}
+import org.apache.calcite.rex.RexProgramBuilder
+
+import scala.collection.JavaConversions._
+
+/**
+ * Planner rule that removes the output column of rank number
+ * iff the rank number column is not used by successor calc.
+ */
+class RedundantRankNumberColumnRemoveRule
+ extends RelOptRule(
+ operand(classOf[FlinkLogicalCalc],
+ operand(classOf[FlinkLogicalRank], any())),
+ "RedundantRankNumberColumnRemoveRule") {
+
+ override def matches(call: RelOptRuleCall): Boolean = {
+ val calc: FlinkLogicalCalc = call.rel(0)
+ val rank: FlinkLogicalRank = call.rel(1)
+ val rankNumberColumnIdx = rank.getRowType.getFieldCount - 1
Review comment:
yes ,but the rule only matches if rank.outputRankNumber is true
--
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 #16024: [FLINK-22038][table-planner-blink] Update TopN to be without rowNumber if rowNumber field is never used by the successor Calc
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #16024:
URL: https://github.com/apache/flink/pull/16024#issuecomment-850960580
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "b1e458736ba06e8ab0dabcb14e1a77fc4068270c",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=18419",
"triggerID" : "b1e458736ba06e8ab0dabcb14e1a77fc4068270c",
"triggerType" : "PUSH"
}, {
"hash" : "d38e029356e1953280b072089f545739893931c3",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=18528",
"triggerID" : "d38e029356e1953280b072089f545739893931c3",
"triggerType" : "PUSH"
}, {
"hash" : "37c65699113155acb03ef5b4da91d02b16fadf17",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "37c65699113155acb03ef5b4da91d02b16fadf17",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* d38e029356e1953280b072089f545739893931c3 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=18528)
* 37c65699113155acb03ef5b4da91d02b16fadf17 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] rmetzger commented on pull request #16024: [FLINK-22038][table-planner-blink] Update TopN to be without rowNumber if rowNumber field is never used by the successor Calc
Posted by GitBox <gi...@apache.org>.
rmetzger commented on pull request #16024:
URL: https://github.com/apache/flink/pull/16024#issuecomment-854088994
I reverted this merge https://github.com/apache/flink/commit/214ade6d0d73b21e8a541501ecb64b4d28bdc74d
--
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] rmetzger commented on pull request #16024: [FLINK-22038][table-planner-blink] Update TopN to be without rowNumber if rowNumber field is never used by the successor Calc
Posted by GitBox <gi...@apache.org>.
rmetzger commented on pull request #16024:
URL: https://github.com/apache/flink/pull/16024#issuecomment-854072045
--
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] beyond1920 commented on a change in pull request #16024: [FLINK-22038][table-planner-blink] Update TopN to be without rowNumber if rowNumber field is never used by the successor Calc
Posted by GitBox <gi...@apache.org>.
beyond1920 commented on a change in pull request #16024:
URL: https://github.com/apache/flink/pull/16024#discussion_r643085769
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/rules/FlinkBatchRuleSets.scala
##########
@@ -307,6 +307,9 @@ object FlinkBatchRuleSets {
CoreRules.PROJECT_TO_CALC,
FlinkCalcMergeRule.INSTANCE,
+ // remove output of rank number when it is not used by successor calc
+ RedundantRankNumberColumnRemoveRule.INSTANCE,
Review comment:
The rule should be in a HepPlanner phase instead of VolcanoPlanner phase.
--
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 #16024: [FLINK-22038][table-planner-blink] Update TopN to be without rowNumber if rowNumber field is never used by the successor Calc
Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #16024:
URL: https://github.com/apache/flink/pull/16024#issuecomment-850957894
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 b1e458736ba06e8ab0dabcb14e1a77fc4068270c (Sun May 30 07:48:06 UTC 2021)
**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 #16024: [FLINK-22038][table-planner-blink] Update TopN to be without rowNumber if rowNumber field is never used by the successor Calc
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #16024:
URL: https://github.com/apache/flink/pull/16024#issuecomment-850960580
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "b1e458736ba06e8ab0dabcb14e1a77fc4068270c",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=18419",
"triggerID" : "b1e458736ba06e8ab0dabcb14e1a77fc4068270c",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* b1e458736ba06e8ab0dabcb14e1a77fc4068270c Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=18419)
<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 #16024: [FLINK-22038][table-planner-blink] Update TopN to be without rowNumber if rowNumber field is never used by the successor Calc
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #16024:
URL: https://github.com/apache/flink/pull/16024#issuecomment-850960580
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "b1e458736ba06e8ab0dabcb14e1a77fc4068270c",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=18419",
"triggerID" : "b1e458736ba06e8ab0dabcb14e1a77fc4068270c",
"triggerType" : "PUSH"
}, {
"hash" : "d38e029356e1953280b072089f545739893931c3",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=18528",
"triggerID" : "d38e029356e1953280b072089f545739893931c3",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* d38e029356e1953280b072089f545739893931c3 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=18528)
<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] godfreyhe commented on a change in pull request #16024: [FLINK-22038][table-planner-blink] Update TopN to be without rowNumber if rowNumber field is never used by the successor Calc
Posted by GitBox <gi...@apache.org>.
godfreyhe commented on a change in pull request #16024:
URL: https://github.com/apache/flink/pull/16024#discussion_r642744349
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/rules/FlinkStreamRuleSets.scala
##########
@@ -374,6 +374,8 @@ object FlinkStreamRuleSets {
PythonCorrelateSplitRule.INSTANCE,
// merge calc after calc transpose
FlinkCalcMergeRule.INSTANCE,
+ // remove output of rank number when it is not used by successor calc
+ RedundantRankNumberColumnRemoveRule.INSTANCE,
Review comment:
The solution for batch and stream are different ?
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/rules/FlinkBatchRuleSets.scala
##########
@@ -307,6 +307,9 @@ object FlinkBatchRuleSets {
CoreRules.PROJECT_TO_CALC,
FlinkCalcMergeRule.INSTANCE,
+ // remove output of rank number when it is not used by successor calc
+ RedundantRankNumberColumnRemoveRule.INSTANCE,
Review comment:
please move this rule close to other rank rules
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/rules/logical/RedundantRankNumberColumnRemoveRule.scala
##########
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.plan.rules.logical
+
+import org.apache.flink.table.planner.plan.nodes.logical.{FlinkLogicalCalc, FlinkLogicalRank}
+import org.apache.flink.table.planner.plan.utils.InputRefVisitor
+
+import org.apache.calcite.plan.RelOptRule.{any, operand}
+import org.apache.calcite.plan.{RelOptRule, RelOptRuleCall}
+import org.apache.calcite.rex.RexProgramBuilder
+
+import scala.collection.JavaConversions._
+
+/**
+ * Planner rule that removes the output column of rank number
+ * iff the rank number column is not used by successor calc.
+ */
+class RedundantRankNumberColumnRemoveRule
+ extends RelOptRule(
+ operand(classOf[FlinkLogicalCalc],
+ operand(classOf[FlinkLogicalRank], any())),
+ "RedundantRankNumberColumnRemoveRule") {
+
+ override def matches(call: RelOptRuleCall): Boolean = {
+ val calc: FlinkLogicalCalc = call.rel(0)
+ val rank: FlinkLogicalRank = call.rel(1)
+ val rankNumberColumnIdx = rank.getRowType.getFieldCount - 1
+ rank.outputRankNumber && !isFieldUsedByCalc(calc, rankNumberColumnIdx)
+ }
+
+ override def onMatch(call: RelOptRuleCall): Unit = {
+ val calc: FlinkLogicalCalc = call.rel(0)
+ val rank: FlinkLogicalRank = call.rel(1)
+ val newRank = new FlinkLogicalRank(
+ rank.getCluster,
+ rank.getTraitSet,
+ rank.getInput,
+ rank.partitionKey,
+ rank.orderKey,
+ rank.rankType,
+ rank.rankRange,
+ rank.rankNumberType,
+ outputRankNumber = false)
+
+ val rexBuilder = rank.getCluster.getRexBuilder
+ val oldProgram = calc.getProgram
+ val programBuilder = new RexProgramBuilder(newRank.getRowType, rexBuilder)
+ oldProgram.getNamedProjects.foreach { pair =>
+ programBuilder.addProject(oldProgram.expandLocalRef(pair.left), pair.right)
+ }
+ if (oldProgram.getCondition != null) {
+ programBuilder.addCondition(oldProgram.expandLocalRef(oldProgram.getCondition))
+ }
+ val rexProgram = programBuilder.getProgram
Review comment:
we can use `RexProgramBuilder.create` to simplify these code
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/rules/logical/RedundantRankNumberColumnRemoveRule.scala
##########
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.plan.rules.logical
+
+import org.apache.flink.table.planner.plan.nodes.logical.{FlinkLogicalCalc, FlinkLogicalRank}
+import org.apache.flink.table.planner.plan.utils.InputRefVisitor
+
+import org.apache.calcite.plan.RelOptRule.{any, operand}
+import org.apache.calcite.plan.{RelOptRule, RelOptRuleCall}
+import org.apache.calcite.rex.RexProgramBuilder
+
+import scala.collection.JavaConversions._
+
+/**
+ * Planner rule that removes the output column of rank number
+ * iff the rank number column is not used by successor calc.
+ */
+class RedundantRankNumberColumnRemoveRule
+ extends RelOptRule(
+ operand(classOf[FlinkLogicalCalc],
+ operand(classOf[FlinkLogicalRank], any())),
+ "RedundantRankNumberColumnRemoveRule") {
+
+ override def matches(call: RelOptRuleCall): Boolean = {
+ val calc: FlinkLogicalCalc = call.rel(0)
+ val rank: FlinkLogicalRank = call.rel(1)
+ val rankNumberColumnIdx = rank.getRowType.getFieldCount - 1
Review comment:
actually, the result is wrong if `rank.outputRankNumber` is false
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/rules/logical/RedundantRankNumberColumnRemoveRule.scala
##########
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.plan.rules.logical
+
+import org.apache.flink.table.planner.plan.nodes.logical.{FlinkLogicalCalc, FlinkLogicalRank}
+import org.apache.flink.table.planner.plan.utils.InputRefVisitor
+
+import org.apache.calcite.plan.RelOptRule.{any, operand}
+import org.apache.calcite.plan.{RelOptRule, RelOptRuleCall}
+import org.apache.calcite.rex.RexProgramBuilder
+
+import scala.collection.JavaConversions._
+
+/**
+ * Planner rule that removes the output column of rank number
+ * iff the rank number column is not used by successor calc.
+ */
+class RedundantRankNumberColumnRemoveRule
+ extends RelOptRule(
+ operand(classOf[FlinkLogicalCalc],
+ operand(classOf[FlinkLogicalRank], any())),
+ "RedundantRankNumberColumnRemoveRule") {
+
+ override def matches(call: RelOptRuleCall): Boolean = {
+ val calc: FlinkLogicalCalc = call.rel(0)
+ val rank: FlinkLogicalRank = call.rel(1)
+ val rankNumberColumnIdx = rank.getRowType.getFieldCount - 1
+ rank.outputRankNumber && !isFieldUsedByCalc(calc, rankNumberColumnIdx)
+ }
+
+ override def onMatch(call: RelOptRuleCall): Unit = {
+ val calc: FlinkLogicalCalc = call.rel(0)
+ val rank: FlinkLogicalRank = call.rel(1)
+ val newRank = new FlinkLogicalRank(
+ rank.getCluster,
+ rank.getTraitSet,
+ rank.getInput,
+ rank.partitionKey,
+ rank.orderKey,
+ rank.rankType,
+ rank.rankRange,
+ rank.rankNumberType,
+ outputRankNumber = false)
+
+ val rexBuilder = rank.getCluster.getRexBuilder
+ val oldProgram = calc.getProgram
+ val programBuilder = new RexProgramBuilder(newRank.getRowType, rexBuilder)
+ oldProgram.getNamedProjects.foreach { pair =>
+ programBuilder.addProject(oldProgram.expandLocalRef(pair.left), pair.right)
+ }
+ if (oldProgram.getCondition != null) {
+ programBuilder.addCondition(oldProgram.expandLocalRef(oldProgram.getCondition))
+ }
+ val rexProgram = programBuilder.getProgram
+ val newCalc = FlinkLogicalCalc.create(newRank, rexProgram)
+ call.transformTo(newCalc)
+ }
+
+ private def isFieldUsedByCalc(calc: FlinkLogicalCalc, inputRefIdx: Int): Boolean = {
+ val projectsAndConditions = calc.getProgram.split()
+ val projects = projectsAndConditions.left
+ val conditions = projectsAndConditions.right
+ val visitor = new InputRefVisitor
+ // extract referenced input fields from projections
+ projects.foreach(exp => exp.accept(visitor))
+ // extract referenced input fields from condition
+ conditions.foreach(_.accept(visitor))
+ visitor.getFields.contains(inputRefIdx)
Review comment:
nit: we can also use `RelOptUtil.bits`
##########
File path: flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/planner/plan/stream/sql/RankTest.scala
##########
@@ -705,5 +705,56 @@ class RankTest extends TableTestBase {
util.verifyExecPlan(sql)
}
+ @Test
+ def testRedundantRankNumberColumnRemove(): Unit = {
Review comment:
please add some tests for batch
--
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