-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-26450][SQL] Avoid rebuilding map of schema for every column in projection #23392
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 6 commits
6b66711
a9dbbec
67a943a
3362744
306e0a5
a25b59c
b977d3e
1497d3a
777c5b4
fbd6787
686e7b5
b1afb3a
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 |
|---|---|---|
|
|
@@ -88,8 +88,11 @@ package object expressions { | |
| /** | ||
| * A helper function to bind given expressions to an input schema. | ||
| */ | ||
| def toBoundExprs(exprs: Seq[Expression], inputSchema: Seq[Attribute]): Seq[Expression] = { | ||
| exprs.map(BindReferences.bindReference(_, inputSchema)) | ||
| def toBoundExprs[A <: Expression]( | ||
| exprs: Seq[A], | ||
|
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. nit: indent |
||
| inputSchema: Seq[Attribute]): Seq[A] = { | ||
|
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. why not just changing this to
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. Sometimes this function is called with a zero-length exprs (
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. How expensive is it to build those structures on empty data? We could consider cachin an empty attribute seq and use that when the there are no attributes.
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. I was thinking that just because exprs is empty, that would not necessarily mean inputSchema is empty. But experiments seem to indicate that inputSchema is also empty. So building the AttributeSeq would be extremely low-cost. I guess there is no reason to lazily build it. |
||
| lazy val inputSchemaAttrSeq: AttributeSeq = inputSchema | ||
| exprs.map(BindReferences.bindReference(_, inputSchemaAttrSeq)) | ||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -393,7 +393,8 @@ case class SortMergeJoinExec( | |
| input: Seq[Attribute]): Seq[ExprCode] = { | ||
| ctx.INPUT_ROW = row | ||
| ctx.currentVars = null | ||
| keys.map(BindReferences.bindReference(_, input).genCode(ctx)) | ||
| val inputAttributeSeq: AttributeSeq = input | ||
| keys.map(BindReferences.bindReference(_, inputAttributeSeq).genCode(ctx)) | ||
|
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. why not
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. It should be... |
||
| } | ||
|
|
||
| private def copyKeys(ctx: CodegenContext, vars: Seq[ExprCode]): Seq[ExprCode] = { | ||
|
|
||
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.
I would like to minimize the chance that future changes suffer from the same issue. In order to do that we should provide API in a logical place, it does not make a whole lot of sense to me that I need to look in
package.scalato find a more performant version ofBindReferences.bindReference(..)for a seq. Can we move this function toBindReferenceand name itbindReferences?