Github user zsxwing commented on a diff in the pull request:
https://github.com/apache/spark/pull/12049#discussion_r57973689
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/StreamExecution.scala
---
@@ -71,9 +71,18 @@ class StreamExecution(
/** The current batchId or -1 if execution has not yet been initialized.
*/
private var currentBatchId: Long = -1
+ private[sql] val logicalPlan = _logicalPlan.transform {
+ case StreamingRelation(sourceCreator, output) =>
+ // Materialize source to avoid creating it in every batch
+ val source = sourceCreator()
+ // We still need to use the previous `output` instead of
`source.schema` as attributes in
+ // "_logicalPlan" has already used attributes of the previous
`output`.
+ StreamingRelation(() => source, output)
--- End diff --
> I think its confusing to have an opaque function that sometimes is
creating a source and sometimes returning a static source. Its not going to be
clear from explain() which mode you are in.
How about adding a new Relation for a static source (maybe call it
StreamExecutionRelation)?
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]