Calling UDF that takes varags with ARRAY
type not handled correctly
#3620
Labels
Projects
ARRAY
type not handled correctly
#3620
Describe the bug
Any UDF that has a varargs currently passes analysis if called with an
ARRAY
type.For example, the
FIELD
UDF has a signature ofpublic int field(final String str, final String... args)
. It's designed to be called like:FIELD("findMe", "possibility 1", "possibility 2")
, but can also be currently be called just two params, the first aSTRING
and the second anARRAY<STRING>
.Though this passed through the Query Analyser without issue, it then fails at runtime.
To Reproduce
Here's a QTT test case that highlights the issue:
Expected behavior
This should ideally be either supported, or rejected when issuing the statement.
Actual behaviour
It fails at runtime when processing each row, with the error:
Additional context
One solution might be to add a variant of
FIELD
that acceptsSTRING, ARRAY<STRING>
parameters. However, that's only a partial fix: it only fixes this instance. The same issue exists for any UDF that has varargs. So the true fix is to either coerce theList<String>
into aString[]
, or at the very least detect this during analysis and reject it.The text was updated successfully, but these errors were encountered: