Hi Matt, Sorry for not getting back with you… I think the issue you’re really trying to solve is how do you write a Drill UDF that accepts a complex field as an input parameter. What you need to do is define a map or array using a ComplexHolder.
@Param ComplexHolder someMapOrArray; Once you’ve done this, take a look at the implementation for KVGEN()/Mappify() (https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/MappifyUtility.java <https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/MappifyUtility.java>) and you’ll see how to iterate through the map. If you get stuck, I can help you get it to work. — C > On Jun 27, 2017, at 23:10, Mike Smoot <[email protected]> wrote: > > Thanks Charles, euclidean distance > <https://en.wikipedia.org/wiki/Euclidean_distance> or l2 norm, but to be > clear my column is a list of floats and the calculation needs to be between > two lists. It's the list of floats bit that seems to be causing me trouble. > > > Mike > > On Tue, Jun 27, 2017 at 4:52 PM, Charles Givre <[email protected]> wrote: > >> Mike, >> What distance function are you looking to implement. I actually have a >> bunch of these done and can push them to github. >> — C >>> On Jun 27, 2017, at 19:20, Mike Smoot <[email protected]> wrote: >>> >>> Hello, >>> >>> I've got some JSON files where each record contains a list of floats as >> one >>> column. I'd like to write a custom function that given a query list of >>> floats will then calculate the euclidean (l2) distance between my query >>> list and each list in the table. I've gotten the example custom function >>> <https://github.com/tgrall/drill-simple-mask-function> working and I've >> got >>> my own function set up, but I'm unclear about which classes I should be >>> using to represent the input parameters. Given some of the errors I've >>> seen while querying my json file I'm guessing that drill thinks the >> column >>> type is ANY. >>> >>> Can anyone provide guidance on which class I should use for my input >> param: >>> >>> @Param >>> >>> ???? input; >>> >>> And once the input is defined, how I should access the list of floats >> from >>> said input? >>> >>> >>> thanks, >>> >>> Mike >> >>
