Skip to content

Conversation

@xinyual
Copy link
Contributor

@xinyual xinyual commented Mar 7, 2025

Description

This pr add string builtin functions with corresponding IT. Some ITs are mapped from spark, others are written by ourseleves

Functions Covered by Spark IT Covered by IT
CONCAT Y Y
CONCAT_WS   Y
LIKE   Y
LTRIM Y Y
RTRIM  Y Y
TRIM Y Y
LENGTH Y Y
LOWER   Y
POSITION Y
REVERSE Y
RIGHT Y
SUBSTRING Y   Y
UPPER Y Y

Related Issues

Resolves #3399

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • New functionality has javadoc added.
  • New functionality has a user manual doc added.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

xinyual added 3 commits March 5, 2025 10:35
Signed-off-by: xinyual <xinyual@amazon.com>
Signed-off-by: xinyual <xinyual@amazon.com>
Signed-off-by: xinyual <xinyual@amazon.com>
@xinyual
Copy link
Contributor Author

xinyual commented Mar 7, 2025

./gradlew :integ-test:integTest --tests 'CalciteIT' succeed in local

Signed-off-by: xinyual <xinyual@amazon.com>

// Needed for BWC tests
zipArchive group: 'org.opensearch.plugin', name:'opensearch-job-scheduler', version: "${opensearch_build}"
zipArchive group: 'org.opensearch.plugin', name:'opensearch-job-scheduler', version:"${opensearch_build}"
Copy link
Member

Choose a reason for hiding this comment

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

restore this change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Already revert.

@LantaoJin LantaoJin added the calcite calcite migration releated label Mar 7, 2025
Copy link
Collaborator

@penghuo penghuo left a comment

Choose a reason for hiding this comment

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

Thx!

Comment on lines +129 to +144
case "LTRIM":
List<RexNode> LTrimArgs =
new ArrayList<>(
List.of(
context.rexBuilder.makeFlag(SqlTrimFunction.Flag.LEADING),
context.rexBuilder.makeLiteral(" ")));
LTrimArgs.addAll(argList);
return LTrimArgs;
case "RTRIM":
List<RexNode> RTrimArgs =
new ArrayList<>(
List.of(
context.rexBuilder.makeFlag(SqlTrimFunction.Flag.TRAILING),
context.rexBuilder.makeLiteral(" ")));
RTrimArgs.addAll(argList);
return RTrimArgs;
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit, Calcite defined RTRIM and LTRIM , could we consider reuse it in future?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In our current implementation, we will use the RexCallImplementor in https://github.com/apache/calcite/blob/48648b391367eeb7910e934cc73dabbe1d7370c0/core/src/main/java/org/apache/calcite/adapter/enumerable/RexToLixTranslator.java#L1416, and the ltrim and rtrim is not actually defined in the RexImpTable. So these two functions are not suitable for our current implementation. But we could track them and see whether we could change our logic to reuse them.

Signed-off-by: xinyual <xinyual@amazon.com>
@LantaoJin LantaoJin merged commit b7f6cf7 into opensearch-project:feature/calcite-engine Mar 10, 2025
4 of 13 checks passed
penghuo pushed a commit to penghuo/os-sql that referenced this pull request Mar 12, 2025
* add string udfs

Signed-off-by: xinyual <xinyual@amazon.com>

* add it to string

Signed-off-by: xinyual <xinyual@amazon.com>

* add IT for string function

Signed-off-by: xinyual <xinyual@amazon.com>

* remove change for local test

Signed-off-by: xinyual <xinyual@amazon.com>

* revert change

Signed-off-by: xinyual <xinyual@amazon.com>

---------

Signed-off-by: xinyual <xinyual@amazon.com>
penghuo pushed a commit that referenced this pull request Jun 16, 2025
* add string udfs

Signed-off-by: xinyual <xinyual@amazon.com>

* add it to string

Signed-off-by: xinyual <xinyual@amazon.com>

* add IT for string function

Signed-off-by: xinyual <xinyual@amazon.com>

* remove change for local test

Signed-off-by: xinyual <xinyual@amazon.com>

* revert change

Signed-off-by: xinyual <xinyual@amazon.com>

---------

Signed-off-by: xinyual <xinyual@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

calcite calcite migration releated

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants