Open auden-woolfson opened 2 months ago
Can you add tests ? Take a look at TestRowExpressionTranslator
- this uses translations defined in TestRowExpressionTranslator.TestFunctions
Hi Auden,
1) how does the annotation on a scalar function with two parameters and both parameter having different Sql types, look like?
2) Can we provide alternatives with different argument types?
For example:
@SupportedSignatures(
{@SqlSignature(argumentType = {StandardTypes.BIGINT, StandardTypes.Double}, returnType = StandardTypes.BIGINT),
@SqlSignature(argumentType = {StandardTypes.BIGINT, StandardTypes.BIGINT}, returnType = StandardTypes.BIGINT)})
public static ClickHouseExpression add(ClickHouseExpression left, ClickHouseExpression right)
{
return new ClickHouseExpression(infixOperation("+", left, right), forwardBindVariables(left, right));
}
Do you think it makes sense?
Thanks for the release note entry! Just a formatting nit.
== RELEASE NOTES ==
General Changes
* Add SupportedSignatures and SqlSignature annotations. :pr:`23642`
* Update OperatorTranslators and tests to use new annotations. :pr:`23642`
Hi Auden,
1. how does the annotation on a scalar function with two parameters and both parameter having different Sql types, look like? 2. Can we provide alternatives with different argument types?
For example:
@SupportedSignatures( {@SqlSignature(argumentType = {StandardTypes.BIGINT, StandardTypes.Double}, returnType = StandardTypes.BIGINT), @SqlSignature(argumentType = {StandardTypes.BIGINT, StandardTypes.BIGINT}, returnType = StandardTypes.BIGINT)}) public static ClickHouseExpression add(ClickHouseExpression left, ClickHouseExpression right) { return new ClickHouseExpression(infixOperation("+", left, right), forwardBindVariables(left, right)); }
Do you think it makes sense?
Yes this makes sense. I considered adding this functionality as well but as far as I can tell there are no SQL functions that we currently support that take multiple parameters of different types. If this is something that you could see happening in the future I can update this PR with that functionality, but my original thinking was that we would handle this case if and when it arises.
StringFunctions.java is one example
StringFunctions.java is one example
Thanks. I just added support for multiple argument types in a signature if you could please review my new commits.
Description
Fix for issue #23605
Currently in order to add new operator/function mappings a new function needs to be defined for each possible mapping. By introducing some new annotations for functions and handling the case we can re use function definitions with different possible type signatures.