-
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-23926][SQL] Extending reverse function to support ArrayType arguments #21034
[SPARK-23926][SQL] Extending reverse function to support ArrayType arguments #21034
Conversation
|
||
lazy val elementType: DataType = dataType.asInstanceOf[ArrayType].elementType | ||
|
||
override def checkInputDataTypes(): TypeCheckResult = { |
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 think you can just make the inputTypes
as Seq(TypeCollection(StringType, ArrayType))
. ExpectsInputTypes
can check the types.
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.
Great idea!
ok to test |
Test build #89175 has finished for PR 21034 at commit
|
retest this please |
Test build #89183 has finished for PR 21034 at commit
|
> SELECT _FUNC_(array(2, 1, 4, 3)); | ||
[3, 4, 1, 2] | ||
""", | ||
since = "2.4.0") |
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.
Hmmm. I think the function reverse
in SQL is there from 1.5 - SPARK-8258. Can we use 1.5.0 here and add a note via note
field saying array type is supported from 2.4.0? there's an example for note:
spark/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/regexpExpressions.scala
Lines 101 to 103 in 2ce37b5
note = """ | |
Use RLIKE to match with standard regular expressions. | |
""") |
} | ||
|
||
s""" | ||
|final int $length = $childName.numElements(); |
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.
nit: more spaces
Test build #89209 has finished for PR 21034 at commit
|
Test build #89219 has finished for PR 21034 at commit
|
Test build #89256 has finished for PR 21034 at commit
|
Test build #89301 has finished for PR 21034 at commit
|
Test build #89345 has finished for PR 21034 at commit
|
Any other comments? |
Test build #89396 has finished for PR 21034 at commit
|
LGTM. |
Thanks! merging to master. |
Thanks everybody for code reviews! |
What changes were proposed in this pull request?
This PR extends
reverse
functions to be able to operate over array columns and covers:Reverse
expression that represents logic for reversing arrays and also stringsStringReverse
expressionHow was this patch tested?
New tests added into:
Codegen examples
Primitive type
Result:
Non-primitive type
Result: