From 96b68459c95e098dfb17588b48137c6701510d82 Mon Sep 17 00:00:00 2001 From: PHILO-HE Date: Wed, 27 Mar 2024 21:27:37 +0800 Subject: [PATCH] Refine the statement --- velox/docs/develop/scalar-functions.rst | 29 +++++++++++----------- velox/functions/prestosql/ArrayShuffle.cpp | 3 +++ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/velox/docs/develop/scalar-functions.rst b/velox/docs/develop/scalar-functions.rst index 47df5dde1a70c..9a5accbc6600c 100644 --- a/velox/docs/develop/scalar-functions.rst +++ b/velox/docs/develop/scalar-functions.rst @@ -582,9 +582,14 @@ 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, VectorFunctionMetadata's -defaultNullBehavior must be set to false when it is registered. See the below +defaultNullBehavior must be set to false during registration. See the below "Registration" section. +.. code-block:: c++ + + auto metadata = + exec::VectorFunctionMetadataBuilder().defaultNullBehavior(false).build(); + 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 all inputs are not null for all “rows". @@ -637,8 +642,12 @@ 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, VectorFunctionMetadata's deterministic -must be set to false when such function is registered. See the below "Registration" -section. +must be set to false during registration. See the below "Registration" section. + +.. code-block:: c++ + + auto metadata = + exec::VectorFunctionMetadataBuilder().deterministic(false).build(); 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. @@ -865,17 +874,9 @@ Use exec::registerVectorFunction to register a stateless vector function. 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. - -.. code-block:: c++ - - auto metadata = exec::VectorFunctionMetadataBuilder() - .deterministic(false) - .defaultNullBehavior(false) - .build(); - -An optional “overwrite” flag specifies whether to overwrite a function if a -function with the specified name already exists. +metadata flag to set deterministic or defaultNullBehavior. 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 function. diff --git a/velox/functions/prestosql/ArrayShuffle.cpp b/velox/functions/prestosql/ArrayShuffle.cpp index b39084c5622f4..2f396422a499d 100644 --- a/velox/functions/prestosql/ArrayShuffle.cpp +++ b/velox/functions/prestosql/ArrayShuffle.cpp @@ -110,6 +110,9 @@ std::vector> signatures() { .returnType("array(T)") .argumentType("array(T)") .build()}; + auto metadata = exec::VectorFunctionMetadataBuilder() + .deterministic(false) + .build(); } } // namespace