-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-21743][SQL] top-most limit should not cause memory leak #18955
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 2 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 |
|---|---|---|
|
|
@@ -54,6 +54,16 @@ trait BaseLimitExec extends UnaryExecNode with CodegenSupport { | |
| val limit: Int | ||
| override def output: Seq[Attribute] = child.output | ||
|
|
||
| // Do not enable whole stage codegen for a single limit. | ||
| override def supportCodegen: Boolean = child match { | ||
| case plan: CodegenSupport => plan.supportCodegen | ||
| case _ => false | ||
| } | ||
|
|
||
| override def executeTake(n: Int): Array[InternalRow] = child.executeTake(math.min(n, limit)) | ||
|
|
||
| override def executeCollect(): Array[InternalRow] = child.executeTake(limit) | ||
|
||
|
|
||
| protected override def doExecute(): RDD[InternalRow] = child.execute().mapPartitions { iter => | ||
| iter.take(limit) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2658,4 +2658,9 @@ class SQLQuerySuite extends QueryTest with SharedSQLContext { | |
| checkAnswer(sql("SELECT __auto_generated_subquery_name.i from (SELECT i FROM v)"), Row(1)) | ||
| } | ||
| } | ||
|
|
||
| test("SPARK-21743: top-most limit should not cause memory leak") { | ||
| // In unit test, Spark will fail the query if memory leak detected. | ||
|
||
| spark.range(100).groupBy("id").count().limit(1).collect() | ||
| } | ||
| } | ||
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.
typo?
LogicalLimitExec->LocalLimitExec.