From 349668be96d4966beb0491e128dddd71dd4a4880 Mon Sep 17 00:00:00 2001 From: erickurbanov Date: Wed, 27 Nov 2024 21:24:32 +0300 Subject: [PATCH] add documentation for indexOfAssumeSorted --- src/Functions/array/indexOfAssumeSorted.cpp | 16 +++++++++++++++- ...ll_new_functions_must_be_documented.reference | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Functions/array/indexOfAssumeSorted.cpp b/src/Functions/array/indexOfAssumeSorted.cpp index 0a43eca8739..c4aeec665dd 100644 --- a/src/Functions/array/indexOfAssumeSorted.cpp +++ b/src/Functions/array/indexOfAssumeSorted.cpp @@ -1,6 +1,7 @@ #include "arrayIndex.h" #include #include +#include "Common/FunctionDocumentation.h" 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) using FunctionIndexOfAssumeSorted = FunctionArrayIndex; -REGISTER_FUNCTION(IndexOfAssumeSorted) { factory.registerFunction(); } +REGISTER_FUNCTION(IndexOfAssumeSorted) +{ + factory.registerFunction(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;"}}}); +} } diff --git a/tests/queries/0_stateless/02415_all_new_functions_must_be_documented.reference b/tests/queries/0_stateless/02415_all_new_functions_must_be_documented.reference index b97394742ea..89ae668331e 100644 --- a/tests/queries/0_stateless/02415_all_new_functions_must_be_documented.reference +++ b/tests/queries/0_stateless/02415_all_new_functions_must_be_documented.reference @@ -364,6 +364,7 @@ in inIgnoreSet indexHint indexOf +indexOfAssumeSorted initcap initcapUTF8 initialQueryID