I'm just trying to get the basics of User Defined Functions working: What I have so far. The following was copied from
https://www.snip2code.com/Snippet/572287/Phoenix-User-Defined-Function-Test---Add My main concern was that I was screwing up package definitions and jar creation hence the difference. package Prefix_A; import java.sql.SQLException; import java.util.List; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.phoenix.expression.Expression; import org.apache.phoenix.parse.FunctionParseNode.Argument; import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction; import org.apache.phoenix.schema.SortOrder; import org.apache.phoenix.schema.tuple.Tuple; import org.apache.phoenix.schema.types.PDataType; import org.apache.phoenix.schema.types.PVarchar; import org.apache.phoenix.util.StringUtil; import org.apache.phoenix.expression.function.*; @BuiltInFunction(name = Prefix_A.NAME, args = { @Argument(allowedTypes = {PVarchar.class})}) public class Prefix_A extends ScalarFunction { public static final String NAME = "Prefix_A"; public Prefix_A() { } public Prefix_A(List<Expression> children) throws SQLException { super(children); } @Override public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { Expression arg = getChildren().get(0); if (!arg.evaluate(tuple, ptr)) { return false; } int targetOffset = ptr.getLength(); if (targetOffset == 0) { return true; } byte[] source = ptr.get(); // prefix A is one byte byte[] target = new byte[targetOffset + 1]; int sourceOffset = ptr.getOffset(); int endOffset = sourceOffset + ptr.getLength(); SortOrder sortOrder = arg.getSortOrder(); int tmp = 1; // needed while (sourceOffset < endOffset) { int nBytes = StringUtil.getBytesInChar(source[sourceOffset], sortOrder); System.arraycopy(source, sourceOffset, target, tmp, nBytes); sourceOffset += nBytes; tmp += nBytes; } // add prefix A target[0] = (byte) 0x41; ptr.set(target); return true; } @Override public SortOrder getSortOrder() { return getChildren().get(0).getSortOrder(); } @Override public PDataType getDataType() { return PVarchar.INSTANCE; } @Override public String getName() { return NAME; } } In any case the file was created under Prefix_A/Prefix_A.java. All relevant jars were included in the Prefix_A directory. compiles successfully. I make a jar from the Prefix_A directory ________________________________ Confidentiality Notice: In accordance with Covance's Data Classification Policy, this email, including attachment(s), is classified as Confidential or Highly Confidential. This e-mail transmission may contain confidential or legally privileged information that is intended only for the individual or entity named in the e-mail address. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or dissemination of the content of this e-mail is strictly prohibited. If you have received this e-mail transmission in error or this email is not intended for you, please delete or destroy all copies of this message in your possession and inform the sender. Thank you.