LiangchangZ opened a new pull request #24457: [SPARK-27340] Alias on TimeWindow expression may cause watermark metadata lost URL: https://github.com/apache/spark/pull/24457 ## What changes were proposed in this pull request? `window($"fooTime", "2 seconds").alias("fooWindow")` can generate an expression tree `Alias(fooWindow) <- TimeWindow`. The tree will become `Alias(fooWindow) <- Alias(window) <- Window(start, end)` after analyzed by TimeWindowing rule. The `Alias(window)` got metadata of watermark when created: ``` val windowStruct = Alias(getWindow(0, 1), WINDOW_COL_NAME)( exprId = windowAttr.exprId, explicitMetadata = Some(metadata)) ``` but the `Alias(fooWindow)` is created before TimeWindowing rule effected. Its code path is: ``` ... case ne: NamedExpression => Alias(expr, alias)(explicitMetadata = Some(ne.metadata)) ... ``` before TimeWindowing rule effected, the `ne.metadata` is None and cause the watermark metadata lost We make the `def name(alias: String)` return a `Alias` which get metadata from its child automatically, when not specifying metadata explicitly. Thank @LinhongLiu for helping analyzing this problem! ## How was this patch tested? integration tests, run the example in jira successfully and do not throw org.apache.spark.sql.AnalysisException anymore
---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
