-
Notifications
You must be signed in to change notification settings - Fork 28.3k
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
[SPARK-8232][SQL] Add sort_array support #7581
Conversation
* the array elements and returns it. | ||
*/ | ||
case class SortArray(child: Expression) | ||
extends UnaryExpression with ExpectsInputTypes with CodegenFallback { |
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.
Use CodegenFallback
,as the sorting in codegen is quite complex, as we need to generate the java code to access the catalyst data type. (e.g. Seq
)
Test build #38018 has finished for PR 7581 at commit
|
cc @rxin |
@rxin, can you review this for me? |
def sort_array(col): | ||
""" | ||
Collection function: sorts the input array for the given column in ascending order. | ||
:param col: name of column or expression |
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.
add a new line here, or the parameter can not be rendered correctly in doc.
Test build #38489 has finished for PR 7581 at commit
|
override def dataType: DataType = child.dataType | ||
override def inputTypes: Seq[AbstractDataType] = Seq(ArrayType) | ||
|
||
override def checkInputDataTypes(): TypeCheckResult = child.dataType match { |
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.
Once we have checkInputDataTypes
, do we still need ExpectsInputTypes
?
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.
Yes, we probably need it, as the ExpectsInputTypes
does not support the input type as ArrayType(AtomicType, _)
ceb8a73
to
c725f6f
Compare
Test build #38798 has finished for PR 7581 at commit
|
c725f6f
to
384e373
Compare
Test build #38802 has finished for PR 7581 at commit
|
@davies any more comments? |
|
||
(left, right) => { | ||
if (left == null && right == null) { | ||
true |
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.
Should this be false
?
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.
Good catch.
Test build #39033 has finished for PR 7581 at commit
|
25fbede
to
664c960
Compare
Thank you @davies I've updated the code by using the |
Test build #39163 has finished for PR 7581 at commit
|
LGTM, will fix the conflict while merging. |
Merged into master, thanks! |
There are logical conflicts, reverted, will fix conflict again. |
This PR is based on #7581 , just fix the conflict. Author: Cheng Hao <hao.cheng@intel.com> Author: Davies Liu <davies@databricks.com> Closes #7851 from davies/sort_array and squashes the following commits: a80ef66 [Davies Liu] fix conflict 7cfda65 [Davies Liu] Merge branch 'master' of github.com:apache/spark into sort_array 664c960 [Cheng Hao] update the sort_array by using the ArrayData 276d2d5 [Cheng Hao] add empty line 0edab9c [Cheng Hao] Add asending/descending support for sort_array 80fc0f8 [Cheng Hao] Add type checking a42b678 [Cheng Hao] Add sort_array support
Add expression
sort_array
support.