I'm writing a Java Spark application and I'm trying to write a unit test for one of my UDFs. This UDF accept Array of String and return Long:
protected UDF1<WrappedArray<String>, Long> convertMyArray() {
return (WrappedArray<String> s) -> {
return ...;
};
}
When I test it with a Spark session, the logic works fine. my problem is how can I unittest this logic.
@Test
public void arrayConversion() throws Exception {
ArrayList<String> inputName = new ArrayList<String>() {
{
add("Inp1");
add("Inp2");
}
};
assertEquals(5, myUDF.convertMyArray().call(...);
}
How can I convert inputName into wappedArray. I can not just simply pass inputName into my UDF call because of input mismatch.
I have also tried to use make based on WrappedArray.scala::Make
WrappedArray<String> stringInput = WrappedArray.make(inputName);
But I still get run time error:
scala.MatchError: [Inp1, Inp2] when using make
makemethod. Is that method showing up in your setup?