You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by Charles Givre <cg...@gmail.com> on 2019/06/24 14:00:08 UTC
UDF Not Registering
Hello Drill Devs,
I'm having an issue with some UDFs I'm working on. Basically, whenever I write a UDF which returns a complex type, List or Map, Drill does not recognize the UDF. I know that Drill CAN do this, as I have written other UDFs that return maps, so I'm a little stumped as to why this is happening. Here is the full stack trace and UDF code. Any help would be greatly appreciated as I'm sure I'm missing some small step somewhere.
Thanks,
-- C
java.lang.Exception: org.apache.drill.common.exceptions.UserRemoteException: VALIDATION ERROR: From line 1, column 8 to line 1, column 38: No match found for function signature get_mx_records(<CHARACTER>)
[Error Id: 1b745443-e05d-4b7a-ada0-85a5a1f23567 ]
For query: select get_mx_records('216.239.36.21') as record from (values(1))
at org.apache.drill.test.DrillTestWrapper.compareMergedOnHeapVectors(DrillTestWrapper.java:639)
at org.apache.drill.test.DrillTestWrapper.compareOrderedResults(DrillTestWrapper.java:593)
at org.apache.drill.test.DrillTestWrapper.run(DrillTestWrapper.java:166)
at org.apache.drill.test.TestBuilder.go(TestBuilder.java:145)
at org.apache.drill.exec.udfs.TestDNSFunctions.testGetMXNames(TestDNSFunctions.java:101)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.drill.exec.rpc.RpcException: org.apache.drill.common.exceptions.UserRemoteException: VALIDATION ERROR: From line 1, column 8 to line 1, column 38: No match found for function signature get_mx_records(<CHARACTER>)
[Error Id: 1b745443-e05d-4b7a-ada0-85a5a1f23567 ]
at org.apache.drill.exec.rpc.RpcException.mapException(RpcException.java:60)
at org.apache.drill.exec.client.DrillClient$ListHoldingResultsListener.getResults(DrillClient.java:881)
at org.apache.drill.exec.client.DrillClient.runQuery(DrillClient.java:583)
at org.apache.drill.test.QueryBuilder.results(QueryBuilder.java:339)
at org.apache.drill.test.ClusterFixture$FixtureTestServices.testRunAndReturn(ClusterFixture.java:575)
at org.apache.drill.test.DrillTestWrapper.testRunAndReturn(DrillTestWrapper.java:935)
at org.apache.drill.test.DrillTestWrapper.compareMergedOnHeapVectors(DrillTestWrapper.java:607)
... 5 more
Caused by: org.apache.drill.common.exceptions.UserRemoteException: VALIDATION ERROR: From line 1, column 8 to line 1, column 38: No match found for function signature get_mx_records(<CHARACTER>)
@FunctionTemplate(name = "get_mx_records",
scope = FunctionTemplate.FunctionScope.SIMPLE,
nulls = FunctionTemplate.NullHandling.NULL_IF_NULL)
public static class MXRecordListFunction implements DrillSimpleFunc {
@Param
VarCharHolder ipaddress;
@Output
BaseWriter.ListWriter out;
@Inject
DrillBuf buffer;
@Override
public void setup() {
}
@Override
public void eval() {
String ipString = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(ipaddress.start, ipaddress.end, ipaddress.buffer);
String MXRecordName = "";
VarCharHolder temp = new VarCharHolder();
out.startList();
try {
org.xbill.DNS.Record[] records = new org.xbill.DNS.Lookup("gmail.com", Type.MX).run();
for (int i = 0; i < records.length; i++) {
org.xbill.DNS.MXRecord mx = (org.xbill.DNS.MXRecord) records[i];
System.out.println("Nameserver " + mx.getTarget());
MXRecordName = mx.getTarget().toString();
temp = new VarCharHolder();
temp.buffer = buffer;
temp.start = 0;
temp.end = MXRecordName.getBytes().length;
buffer.setBytes(0, MXRecordName.getBytes());
out.varChar().write(temp);
}
} catch(Exception e){
MXRecordName = "Unknown";
temp = new VarCharHolder();
temp.buffer = buffer;
temp.start = 0;
temp.end = MXRecordName.getBytes().length;
buffer.setBytes(0, MXRecordName.getBytes());
out.varChar();
}
out.endList();
}
}