I want to create a Java UDF that returns an array ...
# troubleshooting
a
I want to create a Java UDF that returns an array of three Doubles, and use it later from SQL. Here's some code how I was planning this to work:
Copy code
@Override
  public @DataTypeHint("ARRAY<DOUBLE>") Double[] getValue(@DataTypeHint("RAW") PercentileArrayAggregateAccumulator acc) {
    return acc.getValue();
  }
calling this in the accumulator
Copy code
public @DataTypeHint("ARRAY<DOUBLE>") Double[] getValue() {
    return new Double[]{
        digest.quantile(0.1), 
        digest.quantile(0.5), 
        digest.quantile(0.9)
    };
  }
Is this the right syntax? How would I handle the array in the SQL side? I saw
"ARRAY<DOUBLE>"
in some Flink code. edit: the docs have this kind of an example
Copy code
// define a nested data type
  @DataTypeHint("ROW<s STRING, t TIMESTAMP_LTZ(3)>")
  public Row eval(int i) {
    return Row.of(String.valueOf(i), Instant.ofEpochSecond(i));
  }