flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sunjincheng121 <...@git.apache.org>
Subject [GitHub] flink pull request #4199: [FLINK-6584] [table] Support multiple consecutive ...
Date Tue, 27 Jun 2017 17:44:43 GMT
Github user sunjincheng121 commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4199#discussion_r124344855
  
    --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/plan/rules/common/WindowStartEndPropertiesRule.scala
---
    @@ -54,34 +56,75 @@ class WindowStartEndPropertiesRule
         val project = call.rel(0).asInstanceOf[LogicalProject]
         val innerProject = call.rel(1).asInstanceOf[LogicalProject]
         val agg = call.rel(2).asInstanceOf[LogicalWindowAggregate]
    +    val window = agg.getWindow
     
    -    // Retrieve window start and end properties
    +    val isRowtime = isRowtimeAttribute(window.timeAttribute)
    +    val isProctime = isProctimeAttribute(window.timeAttribute)
    +
    +    val startEndProperties = Seq(
    +      NamedWindowProperty("w$start", WindowStart(window.aliasAttribute)),
    +      NamedWindowProperty("w$end", WindowEnd(window.aliasAttribute)))
    +
    +    // allow rowtime/proctime for rowtime windows and proctime for proctime windows
    +    val timeProperties = if (isRowtime) {
    +      Seq(
    +        NamedWindowProperty("w$rowtime", RowtimeAttribute(window.aliasAttribute)),
    +        NamedWindowProperty("w$proctime", ProctimeAttribute(window.aliasAttribute)))
    +    } else if (isProctime) {
    +      Seq(NamedWindowProperty("w$proctime", ProctimeAttribute(window.aliasAttribute)))
    +    } else {
    +      Seq()
    +    }
    +
    +    val properties = startEndProperties ++ timeProperties
    +
    +    // retrieve window start and end properties
         val transformed = call.builder()
         val rexBuilder = transformed.getRexBuilder
         transformed.push(LogicalWindowAggregate.create(
    -      agg.getWindow,
    -      Seq(
    -        NamedWindowProperty("w$start", WindowStart(agg.getWindow.aliasAttribute)),
    -        NamedWindowProperty("w$end", WindowEnd(agg.getWindow.aliasAttribute))
    -      ), agg)
    +      window,
    +      properties,
    +      agg)
         )
     
         // forward window start and end properties
         transformed.project(
    -      innerProject.getProjects ++ Seq(transformed.field("w$start"), transformed.field("w$end")))
    +      innerProject.getProjects ++ properties.map(np => transformed.field(np.name)))
     
         def replaceGroupAuxiliaries(node: RexNode): RexNode = {
           node match {
             case c: RexCall if WindowStartEndPropertiesRule.isWindowStart(c) =>
               // replace expression by access to window start
               rexBuilder.makeCast(c.getType, transformed.field("w$start"), false)
    +
             case c: RexCall if WindowStartEndPropertiesRule.isWindowEnd(c) =>
               // replace expression by access to window end
               rexBuilder.makeCast(c.getType, transformed.field("w$end"), false)
    +
    +        case c: RexCall if WindowStartEndPropertiesRule.isWindowRowtime(c) =>
    +          if (isProctime) {
    +            throw ValidationException("A proctime window cannot provide a rowtime attribute.")
    +          } else if (isRowtime) {
    +            // replace expression by access to window rowtime
    +            transformed.field("w$rowtime")
    +          } else {
    +            throw TableException("Accessing the rowtime attribute of a window is not
yet " +
    +              "supported in a batch environment.")
    +          }
    +
    +        case c: RexCall if WindowStartEndPropertiesRule.isWindowProctime(c) =>
    +          if (isProctime) {
    +            // replace expression by access to window proctime
    +            transformed.field("w$proctime")
    +          } else {
    +            throw ValidationException("Proctime is not supported in a batch environment.")
    +          }
    --- End diff --
    
    We can throw this exception in a Stream rowtime window if we want query `TUMBLE_PROCTIME`,
So I thinks this message should be improve or add a `isRowtime` process.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message