add documentation for indexOfAssumeSorted

This commit is contained in:
erickurbanov 2024-11-27 21:24:32 +03:00
parent 94d77d74a6
commit 349668be96
2 changed files with 16 additions and 1 deletions

View File

@ -1,6 +1,7 @@
#include "arrayIndex.h" #include "arrayIndex.h"
#include <Functions/FunctionFactory.h> #include <Functions/FunctionFactory.h>
#include <Functions/IFunctionAdaptors.h> #include <Functions/IFunctionAdaptors.h>
#include "Common/FunctionDocumentation.h"
namespace DB namespace DB
{ {
@ -10,5 +11,18 @@ struct NameIndexOfAssumeSorted { static constexpr auto name = "indexOfAssumeSort
/// should be used when the array is sorted (applies binary search to array) /// should be used when the array is sorted (applies binary search to array)
using FunctionIndexOfAssumeSorted = FunctionArrayIndex<IndexOfAssumeSorted, NameIndexOfAssumeSorted>; using FunctionIndexOfAssumeSorted = FunctionArrayIndex<IndexOfAssumeSorted, NameIndexOfAssumeSorted>;
REGISTER_FUNCTION(IndexOfAssumeSorted) { factory.registerFunction<FunctionIndexOfAssumeSorted>(); } REGISTER_FUNCTION(IndexOfAssumeSorted)
{
factory.registerFunction<FunctionIndexOfAssumeSorted>(FunctionDocumentation{
.description = R"(
The function finds the position of the first occurrence of element X in the array.
Indexing from one.
The function can be used when the internal array type is not Nullable and the array is sorted in non-decreasing order.
If the array type is Nullable, the 'indexOf' function will be used.
The binary search algorithm is used for the search.
For more details, see [https://en.wikipedia.org/wiki/Binary_search]
For an unsorted array, the behavior is undefined.
)",
.examples = {{.name = "", .query = "SELECT indexOfAssumeSorted([1, 2, 2, 2, 3, 3, 3, 4], 3) FROM test_table;"}}});
}
} }

View File

@ -364,6 +364,7 @@ in
inIgnoreSet inIgnoreSet
indexHint indexHint
indexOf indexOf
indexOfAssumeSorted
initcap initcap
initcapUTF8 initcapUTF8
initialQueryID initialQueryID