Improve wording in docs

This commit is contained in:
Robert Schulze 2024-01-07 08:01:01 +00:00
parent 1e5f7ff80d
commit adebc372d7
No known key found for this signature in database
GPG Key ID: 26703B55FB13728A
4 changed files with 12 additions and 6 deletions

View File

@ -1781,7 +1781,7 @@ Result:
Encodes numbers as a [Sqid](https://sqids.org/) which is a YouTube-like ID string.
The output alphabet is `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`.
Do not use this function for hashing - the generated IDs can be decoded back into numbers.
Do not use this function for hashing - the generated IDs can be decoded back into the original numbers.
**Syntax**
@ -1813,7 +1813,8 @@ SELECT sqidEncode(1, 2, 3, 4, 5);
## sqidDecode
Decodes a [Sqid](https://sqids.org/) into numbers.
Decodes a [Sqid](https://sqids.org/) back into its original numbers.
Returns an empty array in case the input string is not a valid sqid.
**Syntax**

View File

@ -110,14 +110,14 @@ public:
auto col_res_offsets = ColumnArray::ColumnOffsets::create();
auto & res_offsets_data = col_res_offsets->getData();
res_offsets_data.reserve(input_rows_count);
std::vector<UInt64> integers;
for (size_t i = 0; i < input_rows_count; ++i)
{
const ColumnWithTypeAndName & arg = arguments[0];
ColumnPtr current_column = arg.column;
std::string_view sqid = current_column->getDataAt(i).toView();
integers = sqids.decode(sqid);
std::vector<UInt64> integers = sqids.decode(sqid);
res_nested_data.insert(integers.begin(), integers.end());
res_offsets_data.push_back(integers.size());
}
@ -151,10 +151,10 @@ Transforms numbers into a [Sqid](https://sqids.org/) which is a Youtube-like ID
factory.registerFunction<FunctionSqidDecode>(FunctionDocumentation{
.description=R"(
Transforms a [Sqid](https://sqids.org/) back into a tuple of numbers.)",
Transforms a [Sqid](https://sqids.org/) back into an array of numbers.)",
.syntax="sqidDecode(number1, ...)",
.arguments={{"sqid", "A sqid"}},
.returned_value="A tuple of [UInt64](/docs/en/sql-reference/data-types/int-uint.md).",
.returned_value="An array of [UInt64](/docs/en/sql-reference/data-types/int-uint.md).",
.examples={
{"simple",
"SELECT sqidDecode('gXHfJ1C6dN');",

View File

@ -11,5 +11,7 @@ XMbT [1,2]
86Rf07 [1,2,3]
Td1EnWQo [1,2,3,4]
XMbT
-- invalid sqid
[]
-- alias
XMbT

View File

@ -22,5 +22,8 @@ SELECT sqidEncode(materialize(1), materialize(2), materialize(3)) AS sqid, sqidD
SELECT sqidEncode(materialize(1::UInt8), materialize(2::UInt16), materialize(3::UInt32), materialize(4::UInt64)) AS sqid, sqidDecode(sqid);
SELECT sqidEncode(toNullable(materialize(1)), toLowCardinality(materialize(2)));
SELECT '-- invalid sqid';
SELECT sqidDecode('invalid sqid');
SELECT '-- alias';
SELECT sqid(1, 2);