You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? If yes, please describe.
Using Decimals as parameters to UDFs requires precision and scale of parameters to match precisely those in the function declaration.
-- This is the form I would really like to see. It should work with any precision and scale as parameter
USING EXTERNAL FUNCTION to_string(n DECIMAL) VARCHAR
LAMBDA 'athena-user-defined-functions'SELECT to_string(CAST('1.234'ASDECIMAL(18,2))
-- Unexpected parameters (decimal(18,2)) for function to_string. Expected: to_string(decimal)
Given that DECIMAL() is shorthand for DECIMAL(38,0) and DECIMAL(n) shorthand for DECIMAL(n, 0), the example can be extended with any combination where precision_1 != precision_2 or scale_1 != scale_2.
This makes working with functions that take decimal parameters very cumbersome since we have to provide either function declarations with all possible combinations or have to cast n in every call to the precision/scale of the function definition.
Maybe I am missing something, but given that in Java, we only receive BigDecimal n, without any scale/precision constraints, it does not seem to make any sense to me to limit the interface here. Compare it with varchar, which behaves like I propose: A function declaration of to_string(s VARCHAR) can receive any varchar, both bound with any length and unbound, and we will get String on Java side.
Describe the solution you'd like DECIMAL in external function declaration allows any precision/scale in parameters since they do not matter. I.e., the example above works instead of throwing an exception.
Describe alternatives you've considered
[...] since we have to provide either function declarations with all possible combinations or have to cast n in every call to the precision/scale of the function definition.
Additional context
None.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? If yes, please describe.
Using Decimals as parameters to UDFs requires precision and scale of parameters to match precisely those in the function declaration.
Given that
DECIMAL()
is shorthand forDECIMAL(38,0)
andDECIMAL(n)
shorthand forDECIMAL(n, 0)
, the example can be extended with any combination whereprecision_1 != precision_2 or scale_1 != scale_2
.This makes working with functions that take decimal parameters very cumbersome since we have to provide either function declarations with all possible combinations or have to cast
n
in every call to the precision/scale of the function definition.Maybe I am missing something, but given that in Java, we only receive
BigDecimal n
, without any scale/precision constraints, it does not seem to make any sense to me to limit the interface here. Compare it withvarchar
, which behaves like I propose: A function declaration ofto_string(s VARCHAR)
can receive any varchar, both bound with any length and unbound, and we will getString
on Java side.Describe the solution you'd like
DECIMAL
in external function declaration allows any precision/scale in parameters since they do not matter. I.e., the example above works instead of throwing an exception.Describe alternatives you've considered
Additional context
None.
The text was updated successfully, but these errors were encountered: