Skip to content

Conversation

@chenzhx
Copy link
Contributor

@chenzhx chenzhx commented Apr 24, 2022

What changes were proposed in this pull request?

Currently, Spark have some string functions of ANSI standard. Please refer

These functions show below:
SUBSTRING,
UPPER,
LOWER,
TRANSLATE,
TRIM,
OVERLAY

The mainstream databases support these functions show below.

Function PostgreSQL ClickHouse H2 MySQL Oracle Redshift Presto Teradata Snowflake DB2 Vertica Exasol SqlServer Yellowbrick Impala Mariadb Druid Pig SQLite Influxdata Singlestore ElasticSearch
SUBSTRING Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
UPPER Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
LOWER Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes YES Yes Yes Yes Yes
TRIM Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
TRANSLATE Yes No Yes No Yes Yes No No Yes Yes Yes Yes No Yes Yes Yes No No No No No No
OVERLAY Yes No No No Yes No No No No Yes Yes No No No No No No No No No No No

DS V2 should supports push down these string functions.

Why are the changes needed?

DS V2 supports push down string functions

Does this PR introduce any user-facing change?

'No'.
New feature.

How was this patch tested?

New tests.

@github-actions github-actions bot added the SQL label Apr 24, 2022
@beliefer
Copy link
Contributor

Please add databases supports these functions into description.

Copy link
Contributor

@beliefer beliefer left a comment

Choose a reason for hiding this comment

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

Please investigate the syntax of trim carefully.

@HyukjinKwon HyukjinKwon changed the title [SPARK-38897][SQL]DS V2 supports push down string functions [SPARK-38897][SQL] DS V2 supports push down string functions Apr 25, 2022
Copy link
Contributor

@beliefer beliefer left a comment

Choose a reason for hiding this comment

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

LGTM except one comment.

Copy link
Contributor

@beliefer beliefer left a comment

Choose a reason for hiding this comment

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

LGTM

@beliefer
Copy link
Contributor

cc @huaxingao @cloud-fan

" FOR " + inputs(3) + ")";
} else {
throw new IllegalStateException("Unexpected V2 function: OVERLAY");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

         if (inputs.length == 3) {
           "OVERLAY(" + inputs(0) + " PLACING " + inputs(1) + " FROM " + inputs(2) + ")";
         } else {
           "OVERLAY(" + inputs(0) + " PLACING " + inputs(1) + " FROM " + inputs(2) +
             " FOR " + inputs(3) + ")";
         }

@cloud-fan
Copy link
Contributor

thanks, merging to master!

@cloud-fan cloud-fan closed this in 724fb08 May 23, 2022
@chenzhx
Copy link
Contributor Author

chenzhx commented May 23, 2022

@cloud-fan @huaxingao @beliefer Thank you a lot!

@7yyo
Copy link

7yyo commented Dec 15, 2024

@cloud-fan Hello, may I ask how to push down the above functions in MySQL protocol? After studying this PR, does it solve the problem of deriving the str function from H2DB?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants