{"record":{"id":"81603d96908531c6","repo":"apache/beam","slug":"cannot-create-udf-from-method-method-s-s-not-found","errorCode":null,"errorMessage":"Cannot create UDF from method: method %s.%s not found","messagePattern":"Cannot create UDF from method: method (.+?)\\.(.+?) not found","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/UdfImpl.java","lineNumber":47,"sourceCode":"class UdfImpl {\n\n  private UdfImpl() {}\n\n  /**\n   * Creates {@link org.apache.beam.vendor.calcite.v1_40_0.org.apache.calcite.schema.Function} from\n   * given class.\n   *\n   * <p>If a method of the given name is not found or it does not suit, returns {@code null}.\n   *\n   * @param clazz class that is used to implement the function\n   * @param methodName Method name (typically \"eval\")\n   * @return created {@link Function}\n   */\n  public static Function create(Class<?> clazz, String methodName) {\n    final @Nullable Method method = findMethod(clazz, methodName);\n\n    if (method == null) {\n      throw new RuntimeException(\n          String.format(\n              \"Cannot create UDF from method: method %s.%s not found\",\n              clazz.getCanonicalName(), methodName));\n    }\n\n    return create(method);\n  }\n\n  /**\n   * Creates {@link org.apache.beam.vendor.calcite.v1_40_0.org.apache.calcite.schema.Function} from\n   * given method.\n   *\n   * @param method method that is used to implement the function\n   * @return created {@link Function} or null\n   */\n  public static Function create(Method method) {\n    if (TranslatableTable.class.isAssignableFrom(method.getReturnType())) {\n      return checkArgumentNotNull(","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/UdfImpl.java#L29-L65","documentation":"UdfImpl.create(Class, String) resolves a UDF by reflective method lookup (findMethod) in the given class; when no method with that name exists it throws a RuntimeException wrapping the class canonical name and method name. The library cannot build a Calcite Function without an actual Method handle.","triggerScenarios":"registerUdf(...) called with a method name that does not exist on the supplied class, is misspelled, is not public/static in the way findMethod expects, or the wrong Class object was passed.","commonSituations":"Typos in the UDF method name in configuration or registration code; renaming/refactoring the Java method without updating UDF registration; loading the class via a different classloader or version of the jar than expected.","solutions":["Verify the method exists on the class and matches the expected name/visibility: check with clazz.getMethods() before registering","Correct the method name string in the registerUdf call","Confirm you are loading the intended class/jar version (print clazz.getCanonicalName() and list its methods)"],"exampleFix":"// before\nsqlEnv.registerUdf(\"MY_FN\", MyUdfs.class, \"my_fnn\"); // typo\n// after\nsqlEnv.registerUdf(\"MY_FN\", MyUdfs.class, \"myFn\");","handlingStrategy":"try-catch","validationCode":"boolean ok = Arrays.stream(MyUdfs.class.getMethods())\n    .anyMatch(m -> m.getName().equals(\"myFn\"));\nif (!ok) throw new IllegalArgumentException(\"myFn not found on MyUdfs\");","typeGuard":null,"tryCatchPattern":"try {\n  Function f = UdfImpl.create(MyUdfs.class, methodName);\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Cannot create UDF from method\")) {\n    throw new IllegalStateException(\"Check UDF method name: \" + e.getMessage(), e);\n  } else throw e;\n}","preventionTips":["Cross-check UDF method names in registration against the class's public static methods","Add a startup smoke test that resolves every registered UDF name","Avoid renaming public UDF methods without grepping registration strings"],"tags":["java","beam-sql","udf","reflection","method-not-found"],"backgroundTag":"method-not-implemented","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}