Skip to content
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

[FEATURE] Allow broader Decimal type with connector athena-udfs #2572

Open
sbrandtb opened this issue Feb 4, 2025 · 0 comments
Open

[FEATURE] Allow broader Decimal type with connector athena-udfs #2572

sbrandtb opened this issue Feb 4, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@sbrandtb
Copy link

sbrandtb commented Feb 4, 2025

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' AS DECIMAL(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.

@sbrandtb sbrandtb added the enhancement New feature or request label Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant