-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-12289][SQL] Support UnsafeRow in TakeOrderedAndProject/Limit #10330
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
acb3a58
304c94a
ecf7ec8
ba06795
c343447
fdc0097
04eb37e
6a519d8
f3054d6
c44c93a
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 |
|---|---|---|
|
|
@@ -162,6 +162,10 @@ case class Limit(limit: Int, child: SparkPlan) | |
| override def output: Seq[Attribute] = child.output | ||
| override def outputPartitioning: Partitioning = SinglePartition | ||
|
|
||
| override def outputsUnsafeRows: Boolean = child.outputsUnsafeRows | ||
| override def canProcessUnsafeRows: Boolean = true | ||
| override def canProcessSafeRows: Boolean = true | ||
|
|
||
| override def executeCollect(): Array[InternalRow] = child.executeTake(limit) | ||
|
|
||
| protected override def doExecute(): RDD[InternalRow] = { | ||
|
|
@@ -200,18 +204,31 @@ case class TakeOrderedAndProject( | |
| projectOutput.getOrElse(child.output) | ||
| } | ||
|
|
||
| override def outputsUnsafeRows: Boolean = if (projectList.isDefined) { | ||
| true | ||
| } else { | ||
| child.outputsUnsafeRows | ||
| } | ||
|
|
||
| override def canProcessUnsafeRows: Boolean = true | ||
| override def canProcessSafeRows: Boolean = true | ||
|
|
||
| override def outputPartitioning: Partitioning = SinglePartition | ||
|
|
||
| // We need to use an interpreted ordering here because generated orderings cannot be serialized | ||
| // and this ordering needs to be created on the driver in order to be passed into Spark core code. | ||
| private val ord: InterpretedOrdering = new InterpretedOrdering(sortOrder, child.output) | ||
|
|
||
| // TODO: remove @transient after figure out how to clean closure at InsertIntoHiveTable. | ||
| @transient private val projection = projectList.map(new InterpretedProjection(_, child.output)) | ||
| @transient private val projection = projectList.map(UnsafeProjection.create(_, child.output)) | ||
|
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.
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. I think it is ok. 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. Sorry, I still have a dumb question. When calling the 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. I think it is just because not all expressions support unsafe before. 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. So now all the expressions can support unsafe? 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. I think so. If there are expressions still not supporting unsafe, we should make it support. 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. Got it. Thank you! |
||
|
|
||
| private def collectData(): Array[InternalRow] = { | ||
| val data = child.execute().map(_.copy()).takeOrdered(limit)(ord) | ||
| projection.map(data.map(_)).getOrElse(data) | ||
| if (projection.isDefined) { | ||
| projection.map(p => data.map(p(_).copy().asInstanceOf[InternalRow])).get | ||
|
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. Do we need 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.
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. Seems it will be a problem without this copy(). HiveCompatibilitySuite will be failed. 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. I re-checked GenerateUnsafeProjection, it will return the same unsafe row. So we should use another copy() here. 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 misread the code, the |
||
| } else { | ||
| data | ||
| } | ||
| } | ||
|
|
||
| override def executeCollect(): Array[InternalRow] = { | ||
|
|
||
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.
Would it be easy that just process UnsafeRow and output UnsafeRow?
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.
So I need to close this again.....