Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class Dataset[T] private[sql](
case Union(children) if children.forall(hasSideEffects) =>
LogicalRDD(queryExecution.analyzed.output, queryExecution.toRdd)(sparkSession)
case _ =>
queryExecution.analyzed
queryExecution.withCachedData
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,13 @@ class QueryExecution(val sparkSession: SparkSession, val logical: LogicalPlan) {

lazy val withCachedData: LogicalPlan = {
assertAnalyzed()
assertSupported()
sparkSession.sharedState.cacheManager.useCachedData(analyzed)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is actually moved to optimizedPlan. It's for fixing the streaming test failures.

Although streaming queries doesn't use QueryExecution for actual execution, it somehow triggers this line after changes made in the previous commit and throws exception. Not quite familiar with structured streaming though, I may missed something here.

}

lazy val optimizedPlan: LogicalPlan = sparkSession.sessionState.optimizer.execute(withCachedData)
lazy val optimizedPlan: LogicalPlan = {
assertSupported()
sparkSession.sessionState.optimizer.execute(withCachedData)
}

lazy val sparkPlan: SparkPlan = {
SparkSession.setActiveSession(sparkSession)
Expand Down Expand Up @@ -226,6 +228,8 @@ class QueryExecution(val sparkSession: SparkSession, val logical: LogicalPlan) {
|${stringOrError(logical.treeString(verbose = true))}
|== Analyzed Logical Plan ==
|$analyzedPlan
|== With cache data ==
|$withCachedData
|== Optimized Logical Plan ==
|${stringOrError(optimizedPlan.treeString(verbose = true))}
|== Physical Plan ==
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ case class InMemoryRelation(

cached.setName(
tableName.map(n => s"In-memory table $n")
.getOrElse(StringUtils.abbreviate(child.toString, 1024)))
.getOrElse(StringUtils.abbreviate(child.simpleString, 1024)))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original toString method may OOM for super large query plans. This is especially true for those plan trees built in iterative manner and grow exponentially.

_cachedColumnBuffers = cached
}

Expand Down