Skip to content

[CALCITE-6445] Add REVERSE function (enabled in Spark library)#3830

Merged
mihaibudiu merged 1 commit into
apache:mainfrom
YiwenWu:reverse_func
Jul 13, 2024
Merged

[CALCITE-6445] Add REVERSE function (enabled in Spark library)#3830
mihaibudiu merged 1 commit into
apache:mainfrom
YiwenWu:reverse_func

Conversation

@YiwenWu
Copy link
Copy Markdown
Contributor

@YiwenWu YiwenWu commented Jun 23, 2024

}

/**
* Tests {@code REVERSE} function from Spark.
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java
Comment thread babel/src/test/resources/sql/spark.iq
@YiwenWu YiwenWu requested a review from NobiGo June 27, 2024 02:42
Comment thread site/_docs/reference.md Outdated
| 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
Copy Markdown
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
Copy Markdown
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

Comment thread testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java
Comment thread testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java
Comment thread site/_docs/reference.md
@YiwenWu YiwenWu requested a review from NobiGo June 30, 2024 09:08
Copy link
Copy Markdown
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.

Comment thread testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java
Copy link
Copy Markdown
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

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud 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
@YiwenWu
Copy link
Copy Markdown
Contributor Author

YiwenWu commented Jul 13, 2024

@NobiGo @mihaibudiu Could you please merge this PR?

@mihaibudiu mihaibudiu merged commit f68af8c into apache:main Jul 13, 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

Development

Successfully merging this pull request may close these issues.

5 participants