-
Notifications
You must be signed in to change notification settings - Fork 2.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
[CALCITE-6445] Add REVERSE function (enabled in Spark library) #3830
base: main
Are you sure you want to change the base?
Conversation
} | ||
|
||
/** | ||
* Tests {@code REVERSE} function from Spark. |
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 jira link
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.
done
site/_docs/reference.md
Outdated
@@ -2850,6 +2850,7 @@ In the following: | |||
| b | REGEXP_SUBSTR(string, regexp [, position [, occurrence]]) | Synonym for REGEXP_EXTRACT | |||
| b m p s | REPEAT(string, integer) | Returns a string consisting of *string* repeated of *integer* times; returns an empty string if *integer* is less than 1 | |||
| b m | REVERSE(string) | Returns *string* with the order of the characters reversed | |||
| s | REVERSE( string | array ) | Returns *string* or *array* with the order of the characters reversed |
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.
Returns string with the characters in reverse order or array with elements in reverse order
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.
Done, updated the description
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.
Most functions in Spark actually allow mixed use of numeric types, such as int and double, which will eventually be converted to the biggest type. For example
scala> val df = spark.sql("SELECT REVERSE(array(2, 1, 4, 3.0))")
df: org.apache.spark.sql.DataFrame = [reverse(array(2, 1, 4, 3.0)): array<decimal(11,1)>]
scala> df.show()
+----------------------------+
|reverse(array(2, 1, 4, 3.0))|
+----------------------------+
| [3.0, 4.0, 1.0, 2.0]|
+----------------------------+
Maybe we should write a method to imitate the operation of spark later.
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.
LGTM
|
https://issues.apache.org/jira/browse/CALCITE-6445
Add Function REVERSE in Spark library.