Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

YiwenWu
Copy link
Contributor

@YiwenWu YiwenWu commented Jun 23, 2024

}

/**
* Tests {@code REVERSE} function from Spark.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add jira link

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@YiwenWu YiwenWu requested a review from NobiGo June 27, 2024 02:42
@@ -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
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, updated the description

site/_docs/reference.md Show resolved Hide resolved
@YiwenWu YiwenWu requested a review from NobiGo June 30, 2024 09:08
Copy link
Member

@caicancai caicancai left a 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.

Copy link
Member

@caicancai caicancai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

sonarcloud bot commented Jul 8, 2024

@NobiGo NobiGo added the LGTM-will-merge-soon Overall PR looks OK. Only minor things left. label Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LGTM-will-merge-soon Overall PR looks OK. Only minor things left.
Projects
None yet
5 participants