-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-17356][SQL] Fix out of memory issue when generating JSON for TreeNode #14915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -617,7 +617,9 @@ abstract class TreeNode[BaseType <: TreeNode[BaseType]] extends Product { | |
| case s: String => JString(s) | ||
| case u: UUID => JString(u.toString) | ||
| case dt: DataType => dt.jsonValue | ||
| case m: Metadata => m.jsonValue | ||
| // SPARK-17356: In usage of mllib, Metadata may store a huge vector of data, transforming | ||
| // it to JSON may trigger OutOfMemoryError. | ||
| case m: Metadata => Metadata.empty.jsonValue | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shall we use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, we should not. JNothing is to map
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh sorry, I mean |
||
| case s: StorageLevel => | ||
| ("useDisk" -> s.useDisk) ~ ("useMemory" -> s.useMemory) ~ ("useOffHeap" -> s.useOffHeap) ~ | ||
| ("deserialized" -> s.deserialized) ~ ("replication" -> s.replication) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,7 +33,7 @@ import org.apache.spark.sql.execution.aggregate.TypedAggregateExpression | |
| import org.apache.spark.sql.execution.columnar.InMemoryRelation | ||
| import org.apache.spark.sql.execution.datasources.LogicalRelation | ||
| import org.apache.spark.sql.execution.streaming.MemoryPlan | ||
| import org.apache.spark.sql.types.ObjectType | ||
| import org.apache.spark.sql.types.{Metadata, ObjectType} | ||
|
|
||
|
|
||
| abstract class QueryTest extends PlanTest { | ||
|
|
@@ -274,6 +274,14 @@ abstract class QueryTest extends PlanTest { | |
| val normalized1 = logicalPlan.transformAllExpressions { | ||
| case udf: ScalaUDF => udf.copy(function = null) | ||
| case gen: UserDefinedGenerator => gen.copy(function = null) | ||
| // After SPARK-17356: the JSON representation no longer has the Metadata. We need to remove | ||
| // the Metadata from the normalized plan so that we can compare this plan with the | ||
| // JSON-deserialzed plan. | ||
| case a @ Alias(child, name) if a.explicitMetadata.isDefined => | ||
| Alias(child, name)(a.exprId, a.qualifier, Some(Metadata.empty), a.isGenerated) | ||
| case a: AttributeReference if a.metadata != Metadata.empty => | ||
| AttributeReference(a.name, a.dataType, a.nullable, Metadata.empty)(a.exprId, a.qualifier, | ||
| a.isGenerated) | ||
|
||
| } | ||
|
|
||
| // RDDs/data are not serializable to JSON, so we need to collect LogicalPlans that contains | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current implementation of toJSON recursively searches the Map and Seq, and try to convert every field to JSON.
It is quite risky, since we don't know what data is stored in unknown Seq and Map, and it may easily trigger OOM if the Seq or Map is a huge object.
Maybe we should disable converting Seq and Map?