Check the types of given parameters matches the types of SQL function declared parameters
Affected Version
ALL
Description
For APPROX_QUANTILE and related functions, the first parameter MUST be numeric column. however, currently the SQL planner does not check if the given expression is type of number, even a STRING is accepted. If users accidentally use single quote instead of double quote for a column, an hard to understand exception is thrown as follows>
SELECT channel,
APPROX_QUANTILE('r1', 0.990000, 100) AS "p99"
FROM "wikipedia"
GROUP BY channel
Error: RUNTIME_FAILURE (OPERATOR)
java.util.concurrent.ExecutionException: java.lang.ClassCastException: class java.lang.String cannot be cast to class java.lang.Number (java.lang.String and java.lang.Number are in module java.base of loader 'bootstrap')
java.lang.RuntimeException
This makes people think that there's an internal error at the engine side not at the SQL side. So, for these functions, a type check at SQL layer is needed to give a clear information instead of throwing an exception which makes people think there's internal error from the engine.
@FrankChen021 Hi! I'm new to contributing to open source, and this would be my very first contribution.
I'd really like to take on this issue. I understand the goal is to add type checking for APPROX_QUANTILE and related functions.
Just to make sure I’m on the right track — could you please clarify which functions are considered "related functions" in this context?
Thanks a lot in advance!
@CoodingPenguin
the related functions here, I mean, we should check all SQL functions if they check the types properly. And I think most of functions are lack of such type check.
Looking forward to your contribution.
Hi @CoodingPenguin ,
just wanted to follow up and see if you're still actively working on this issue. If not, I'm happy to contribute and help move it forward. Thank you.
@CuteChuanChuan Hi, thanks a lot for following up!
I haven’t been able to make progress on this recently, and realistically I won’t be able to pick it back up any time soon.
Please feel free to take over — I’d be really happy to see it move forward.