Skip to content

Commit

Permalink
Fix comment
Browse files Browse the repository at this point in the history
  • Loading branch information
PHILO-HE committed Mar 29, 2024
1 parent 8dfffd7 commit 376ba0c
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions velox/docs/develop/scalar-functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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<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
Expand Down Expand Up @@ -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<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.
Expand Down Expand Up @@ -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
^^^^^^^^^^^^

Expand All @@ -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
Expand Down

0 comments on commit 376ba0c

Please sign in to comment.