A framework for writing performant user-defined functions (UDFs) that are portable across a variety of engines including Apache Spark, Apache Hive, and Presto.
Simplify the use of ChoicesSpecializedSqlScalarFunction to only using Trino SPI. StdUDFWrapper uses this class in the following manner to get the ScalarFunctionImplementation
ScalarFunctionImplementation res = new ChoicesSpecializedSqlScalarFunction(
boundSignature,
NULLABLE_RETURN,
getNullConventionForArguments(nullableArguments),
getMethodHandle(stdUDF, boundSignature, nullableArguments, requiredFilesNextRefreshTime)).getScalarFunctionImplementation(invocationConvention);
which is equivalent to a ChoicesSpecializedSqlScalarFunction with only one ScalarImplementationChoice, also lambdaInterfaces and instanceFactory are always empty/absent.
Then look at its getScalarFunctionImplementation (code). Since there is only one choice and the given constraints on instanceFactory and lambdaInterfaces, this method is equivalent to
Summary
Reflection#methodHandle
upstreamTrinoFactory#getOperatorHandle
does not throwOperatorNotFoundException
anymore; previously it does because of Metadata#resolveOperator; ref in TrinoFactoryChoicesSpecializedSqlScalarFunction
to only using Trino SPI.StdUDFWrapper
uses this class in the following manner to get theScalarFunctionImplementation
which is equivalent to a
ChoicesSpecializedSqlScalarFunction
with only oneScalarImplementationChoice
, alsolambdaInterfaces
andinstanceFactory
are always empty/absent.Then look at its
getScalarFunctionImplementation
(code). Since there is only one choice and the given constraints oninstanceFactory
andlambdaInterfaces
, this method is equivalent toThen look at how the only
ScalarImplementationChoice
is constructed ref, wherecan be simplified to the following since Transport does not support session functions.