-
Notifications
You must be signed in to change notification settings - Fork 0
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
concat()
support multiple string arguments
#200
concat()
support multiple string arguments
#200
Conversation
Codecov Report
@@ Coverage Diff @@
## integ-concat-support-many-args #200 +/- ##
====================================================================
- Coverage 98.35% 95.94% -2.42%
- Complexity 3609 3624 +15
====================================================================
Files 344 355 +11
Lines 8946 9657 +711
Branches 569 693 +124
====================================================================
+ Hits 8799 9265 +466
- Misses 142 334 +192
- Partials 5 58 +53
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
Is it possible to replace concat(one, two, three)
with concat(one, concat(two, three))
? In that case you don't need a vararg function.
core/src/main/java/org/opensearch/sql/expression/function/BuiltinFunctionRepository.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/opensearch/sql/expression/function/DefaultFunctionResolver.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/opensearch/sql/expression/function/FunctionDSL.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/opensearch/sql/expression/function/FunctionDSL.java
Outdated
Show resolved
Hide resolved
@@ -182,6 +182,9 @@ private FunctionBuilder getFunctionBuilder( | |||
if (isCastFunction(functionName) || sourceTypes.equals(targetTypes)) { | |||
return funcBuilder; | |||
} | |||
if (functionResolverMap.get(functionName) instanceof VarargsFunctionResolver) { | |||
return castArguments(sourceTypes, sourceTypes, funcBuilder); |
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.
sourceTypes twice?
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.
As concat()
has variable number of args and targetTypes will always be 0 (as the function signature is not fixed), failure will occur. So, in this case sourceTypes are passed instead of targetTypes to address that.
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.
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.
I think a code comment is required to make things clear
concat()
support multiple string arguments
concat()
support multiple string argumentsconcat()
support multiple string arguments
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.
👍
@@ -182,6 +182,9 @@ private FunctionBuilder getFunctionBuilder( | |||
if (isCastFunction(functionName) || sourceTypes.equals(targetTypes)) { | |||
return funcBuilder; | |||
} | |||
if (functionResolverMap.get(functionName) instanceof VarargsFunctionResolver) { | |||
return castArguments(sourceTypes, sourceTypes, funcBuilder); |
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.
I think a code comment is required to make things clear
core/src/main/java/org/opensearch/sql/expression/function/FunctionDSL.java
Show resolved
Hide resolved
core/src/main/java/org/opensearch/sql/expression/function/VarargsFunctionResolver.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Margarit Hakobyan <[email protected]>
Signed-off-by: Margarit Hakobyan <[email protected]>
Signed-off-by: Margarit Hakobyan <[email protected]>
Signed-off-by: Margarit Hakobyan <[email protected]>
Signed-off-by: Margarit Hakobyan <[email protected]>
Signed-off-by: Margarit Hakobyan <[email protected]>
Signed-off-by: Margarit Hakobyan <[email protected]>
Signed-off-by: Margarit Hakobyan <[email protected]>
Signed-off-by: Margarit Hakobyan <[email protected]>
Signed-off-by: Margarit Hakobyan <[email protected]>
Signed-off-by: Margarit Hakobyan <[email protected]>
Signed-off-by: Margarit Hakobyan <[email protected]>
8281bf8
to
82acb60
Compare
#200) * Refactor concat() to support multiple string arguments Signed-off-by: Margarit Hakobyan <[email protected]>
opensearch-project#1279) * Enable `concat()` string function to support multiple string arguments (#200) Signed-off-by: Margarit Hakobyan <[email protected]>
opensearch-project#1279) (opensearch-project#1297) * Enable `concat()` string function to support multiple string arguments (#200) Signed-off-by: Margarit Hakobyan <[email protected]> (cherry picked from commit 45fc371) Co-authored-by: Margarit Hakobyan <[email protected]>
#200) Signed-off-by: dblock <[email protected]> Signed-off-by: dblock <[email protected]>
Signed-off-by: Margarit Hakobyan [email protected]
Description
These changes enable
concat()
string function to accept more than two arguments.Usage: CONCAT(str1, str2, ...., str_n) adds two or more strings together.
Argument type: STRING, STRING, ...., STRING
Return type: STRING
Example::
Issues Resolved
[List any issues this PR will resolve]
Check List
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.