We currently support external UDF written in LLVM IR. This kind of UDF always requires codegen and ignores the query option DISABLE_CODEGEN (which is being fixed as part of
IMPALA-3638). This indirectly leads to the need to codegen in ScalarFnCall::Prepare() ( IMPALA-4233) to support cases in which the plan fragment doesn't have any codegen enabled operators. In addition, this path is not well tested and we haven't spent much effort for ensuring compatibility across different LLVM versions which we may upgrade from time to time.
It's unclear if any major customer use cases rely on it and it's unclear if it's well publicized. If not, we should consider discontinuing support for this kind of UDF in future versions. FWIW, our codegen infrastructure already handles native UDF so it's not a necessity to write UDF in LLVM IR to enjoy the benefit of codegen.