嗨,我正在开发钻头用户定义的函数。我写了这个UDF。
package somepackage.udfs;
import io.netty.buffer.DrillBuf;
import org.apache.drill.exec.expr.DrillSimpleFunc;
import org.apache.drill.exec.expr.annotations.FunctionTemplate;
import org.apache.drill.exec.expr.annotations.Output;
import org.apache.drill.exec.expr.annotations.Param;
import org.apache.drill.exec.expr.holders.Float8Holder;
import org.apache.drill.exec.expr.holders.NullableVarCharHolder;
import org.apache.drill.exec.expr.holders.VarCharHolder;
import javax.inject.Inject;
@FunctionTemplate(
name = "split_sample",
scope = FunctionTemplate.FunctionScope.SIMPLE,
nulls = FunctionTemplate.NullHandling.NULL_IF_NULL
)
public class SplitTrainTestSample implements DrillSimpleFunc {
@Param
NullableVarCharHolder targetIn;
@Param(constant = true)
Float8Holder train_test_rate;
@Output
VarCharHolder label;
@Inject
DrillBuf buffer;
public SplitTrainTestSample() {
}
@Override
public void setup() {
}
@Override
public void eval() {
double r = Math.random();
String l;
assert 0 < train_test_rate.value && train_test_rate.value < 1;
if (r < train_test_rate.value) {
l = "train";
}
else {
l = "test";
}
byte[] bytes = l.getBytes();
label.buffer = buffer;
label.start = 0;
label.end = bytes.length;
label.buffer.setBytes(0, bytes);
}
}
但是当我运行这个查询时
Apache Drill> select split_sample(cast(full_name as char), 0.5) from cp.`employee.json`;
Drill 返回一个错误信息。
Error: VALIDATION ERROR: From line 1, column 8 to line 1, column 49: No match found for function signature split_sample(<CHARACTER>, <NUMERIC>)
请帮我找出问题所在。我在同一个包下编写了另一个 UDF,它工作得很好。因此,它不太可能是 UDF 注册表错误。
有没有一种方法可以探测 UDF 的函数签名?