Skip to content

Commit

Permalink
Refine the statement
Browse files Browse the repository at this point in the history
  • Loading branch information
PHILO-HE committed Mar 27, 2024
1 parent 8615942 commit 8dfffd7
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions velox/docs/develop/scalar-functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -580,10 +580,15 @@ The “rows” parameter specifies the set of rows in the incoming batch to
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, VectorFunctionMetadata's
defaultNullBehavior must be set to false when it is registered. See the below
"Registration" section.
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();

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
Expand Down Expand Up @@ -636,10 +641,15 @@ 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, VectorFunctionMetadata's deterministic
must be set to false when such function is registered. See the below "Registration"
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();

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.

Expand Down Expand Up @@ -865,17 +875,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.
Expand Down

0 comments on commit 8dfffd7

Please sign in to comment.