77 */
88
99#include " column.h"
10+ #include < boost/algorithm/string.hpp>
1011#include < memory>
1112#include " VariantToVector.h"
1213#include " bindings.h"
@@ -435,6 +436,30 @@ std::unique_ptr<OperatorHandle> OperatorHandle::fromCall(
435436 std::move (callTypedExprs), &TorchArrowGlobalStatic::execContext ()));
436437}
437438
439+ std::string udfSignaturesToString (
440+ const std::vector<const velox::exec::FunctionSignature*>& signatures) {
441+ std::stringstream out;
442+ for (auto i = 0 ; i < signatures.size (); ++i) {
443+ if (i > 0 ) {
444+ out << " , " ;
445+ }
446+ out << signatures[i]->toString ();
447+ }
448+ return out.str ();
449+ }
450+
451+ std::string udfSignaturesToString (velox::RowTypePtr inputRowType) {
452+ auto children = inputRowType->children ();
453+ std::stringstream out;
454+ for (auto i = 0 ; i < children.size (); ++i) {
455+ if (i > 0 ) {
456+ out << " ," ;
457+ }
458+ out << children[i]->toString ();
459+ }
460+ return " (" + boost::algorithm::to_lower_copy (out.str ()) + " )" ;
461+ }
462+
438463std::unique_ptr<OperatorHandle> OperatorHandle::fromUDF (
439464 velox::RowTypePtr inputRowType,
440465 const std::string& udfName) {
@@ -445,8 +470,22 @@ std::unique_ptr<OperatorHandle> OperatorHandle::fromUDF(
445470
446471 velox::TypePtr outputType =
447472 velox::resolveFunction (udfName, inputRowType->children ());
473+
448474 if (outputType == nullptr ) {
449- throw std::runtime_error (" Request for unknown Velox UDF: " + udfName);
475+ std::string signature = udfSignaturesToString (inputRowType);
476+
477+ auto allSignatures = velox::getFunctionSignatures ();
478+ auto it = allSignatures.find (udfName);
479+ if (it == allSignatures.end ()) {
480+ throw std::runtime_error (
481+ " Request for unknown Velox UDF: " + udfName + signature);
482+ } else {
483+ const auto & functionSignatures = it->second ;
484+ throw std::runtime_error (
485+ " Velox UDF signature is not supported: " + signature +
486+ " . Supported signatures: " +
487+ udfSignaturesToString (functionSignatures));
488+ }
450489 }
451490 return OperatorHandle::fromCall (inputRowType, outputType, udfName);
452491}
0 commit comments