diff --git a/velox/docs/develop/scalar-functions.rst b/velox/docs/develop/scalar-functions.rst index 81df2a6dcb8a..b667d6a0eadc 100644 --- a/velox/docs/develop/scalar-functions.rst +++ b/velox/docs/develop/scalar-functions.rst @@ -581,14 +581,8 @@ process. This set may not include all the rows. By default, a vector function is assumed to have the default null behavior, e.g. null in any input produces a null result. In this case, the expression evaluation engine will exclude rows with nulls from the “rows” specified in the call to “apply”. If a function -has a different behavior for null inputs, metadata flag must be provided with -defaultNullBehavior set to false during registration. See the below "Registration" -section. - -.. code-block:: c++ - - VectorFunctionMetadata metadata = - exec::VectorFunctionMetadataBuilder().defaultNullBehavior(false).build(); +has a different behavior for null inputs, it must specify that during registration. +See :ref:`vector function registration` for more details. In this case, the “rows” parameter will include rows with null inputs and the function will need to handle these. By default, the function can assume that @@ -641,14 +635,9 @@ of the function arguments. These vectors are not necessarily flat and may be dictionary or constant encoded. However, a deterministic function that takes a single argument and has default null behavior is guaranteed to receive its only input as a flat or constant vector. By default, a function is assumed to -be deterministic. If that’s not the case, metadata flag must be provided with -deterministic set to false during registration. See the below "Registration" -section. - -.. code-block:: c++ - - VectorFunctionMetadata metadata = - exec::VectorFunctionMetadataBuilder().deterministic(false).build(); +be deterministic. If that’s not the case, it must specify the non-deterministic +behavior during registration. See :ref:`vector function registration` +for more details. Note that :ref:`decoded-vector` can be used to get a flat vector-like interface to any vector. A helper class exec::DecodedArgs can be used to decode multiple arguments. @@ -859,6 +848,7 @@ Simple functions are compatible with the TRY expression by default. The framewor wraps the “call” and “callNullable” methods in a try-catch and reports errors using context.setError. +.. _Registration: Registration ^^^^^^^^^^^^ @@ -874,9 +864,17 @@ Use exec::registerVectorFunction to register a stateless vector function. bool overwrite = true) exec::registerVectorFunction takes a name, a list of supported signatures -and unique_ptr to an instance of the function. It is optional to provide -metadata flag to set deterministic or defaultNullBehavior. An optional -“overwrite” flag specifies whether to overwrite a function if a function +and unique_ptr to an instance of the function. It takes an optional 'metadata' +parameter that specifies whether a function is deterministic, has default null +behavior, and other properties. A helper VectorFunctionMetadataBuilder class +allows to easily construct 'metadata'. For example, + +.. code-block:: c++ + + VectorFunctionMetadataBuilder().defaultNullBehavior(false).build(); + + +An optional “overwrite” flag specifies whether to overwrite a function if a function with the specified name already exists. Use exec::registerStatefulVectorFunction to register a stateful vector