druid icon indicating copy to clipboard operation
druid copied to clipboard

Check the types of given parameters matches the types of SQL function declared parameters

Open FrankChen021 opened this issue 7 months ago • 4 comments

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 avatar May 16 '25 02:05 FrankChen021

@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 avatar May 26 '25 05:05 CoodingPenguin

@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.

FrankChen021 avatar May 26 '25 06:05 FrankChen021

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 avatar Jun 08 '25 16:06 CuteChuanChuan

@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.

CoodingPenguin avatar Jun 09 '25 01:06 CoodingPenguin