GitHub user KurtYoung opened a pull request: https://github.com/apache/flink/pull/2961
[FLINK-5266] [table] eagerly project unused fields when selecting aggregation fields This PR is based on #2926 , only the second commit is related. I add a "plan" test directory to hold all the plan level tests. And i also did a small refactory for ProjectionTranslator, thought it's better to keep each method only do one thing. @fhueske As we discussed earlier in the jira: https://issues.apache.org/jira/browse/FLINK-5266 about where the logics should be added. I decided to add them when we selecting fields from a normal or grouped table. Since this kind of logics involves some fields references rewrite, if we choose to add the needed projection node when we convert the LogicalPlan to Calcite's RelNode, we should also take care the whole rewrite thing. However, if we add the project node in the first place, we only need to extract all the field references used in all selecting expressions, and treat them as UnresolvedFieldReferences. The validation part will take care of the rewrite thing. I think this will be easier and more consistent with other procedures. (Noticed all the "construct" logic are fairly simple) You can merge this pull request into a Git repository by running: $ git pull https://github.com/KurtYoung/flink flink-5266 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/flink/pull/2961.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #2961 ---- commit 374d231d44f84ae385d8f8adb2353685e1214ff6 Author: Kurt Young <ykt...@gmail.com> Date: 2016-12-08T01:27:55Z [FLINK-5226] [table] Use correct DataSetCostFactory and improve DataSetCalc costs. commit 8a3ecf8e6362acd9370b11f08018a0143fc9be18 Author: Kurt Young <ykt...@gmail.com> Date: 2016-12-08T02:35:43Z [FLINK-5266] [table] eagerly project unused fields when selecting aggregation fields Add a "plan" test dir to hold all the plan level unit tests Small refactory with ProjectionTranslator, keep each method handle one single thing ---- --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---