Github user twalthr commented on a diff in the pull request:

    https://github.com/apache/flink/pull/1696#discussion_r53907367
  
    --- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/plan/rules/dataset/DataSetCalcRule.scala
 ---
    @@ -37,13 +45,90 @@ class DataSetCalcRule
         val traitSet: RelTraitSet = 
rel.getTraitSet.replace(DataSetConvention.INSTANCE)
         val convInput: RelNode = RelOptRule.convert(calc.getInput, 
DataSetConvention.INSTANCE)
     
    +    val calcFunc = (
    +        config: TableConfig,
    +        inputType: TypeInformation[Any],
    +        returnType: TypeInformation[Any]) => {
    +      val generator = new CodeGenerator(config, inputType)
    +
    +      val calcProgram = calc.getProgram
    +      val condition = calcProgram.getCondition
    +      val expandedExpressions = calcProgram.getProjectList.map(
    +          expr => 
calcProgram.expandLocalRef(expr.asInstanceOf[RexLocalRef]))
    +      val projection = generator.generateResultExpression(
    +        returnType,
    +        calc.getRowType.getFieldNames,
    +        expandedExpressions)
    +      
    +      val body = {
    +        if (condition == null) {
    +          // only projection
    +          s"""
    +            |${projection.code}
    +            |${generator.collectorTerm}.collect(${projection.resultTerm});
    +            |""".stripMargin
    +        }
    +        else {
    +          val filterCondition = generator.generateExpression(
    +              calcProgram.expandLocalRef(calcProgram.getCondition))
    +          if (projection == null) {
    +          // only filter
    --- End diff --
    
    Just a small comment: Maybe I'm alone in this opinion, but I think it's 
nicer to have the comment above the `if`, it improves the reading flow (for me 
at least). Then you also don't have wrong indention, like in this line.


---
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.
---

Reply via email to