Hi devs!
Given a datatype RankingResultType and a dataset
RankingResult(RankingResultType) which contains only one record, what is the
correct approach when I want to pass a single RankingResult record as an
argument to a Java UDF in a SQL++ UDF? The resulting record of the Java UDF
should be selected at the end of the UDF as it is going to be stored in the
dataset the feed which uses the SQL++ UDF is attached to.
CREATE FUNCTION rank(newItem) {
LET rankingResult = *must select the record here*,
SELECT testlib#detectRelevance(newItem, *must pass RankingResult record here*)
};
I have tried some different approaches, for instance
1. running LET rankingResult = (SELECT VALUE r FROM RankingResult r)
SELECT testlib#detectRelevance(newItem, rankingResult)
2. running LET rankingResult = (SELECT VALUE r FROM RankingResult r)[0] SELECT
testlib#detectRelevance(newItem, rankingResult)
The first approach throws a TypeMismatchException, ASX1002: Type mismatch:
function testlib#detectRelevance expects its 2nd input parameter to be of type
object, but the actual input type is array
So I therefore tried to access the first element of the array in the second
approach, but the second approach does not compile:
SX1079: Compilation error: The input type union(RankingResultType: closed {
id: bigint,
first: RankingType: open { score: double },
second: RankingType: open {score: double},
third: RankingType: open { score: double},
fourth: RankingType: open {score: double},
fifth: RankingType: open {score: double}
} , null, missing) is not a valid record type!
Could you maybe point me in the right direction?
Thanks in advance!
Best,
Sandra