mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-29 02:52:13 +00:00
Rename decode/encodeSqid() to sqidDecode/Encode()
This commit is contained in:
parent
f6ecf2b617
commit
44b9547fba
@ -1777,7 +1777,7 @@ Result:
|
||||
└────────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
## encodeSqid
|
||||
## sqidEncode
|
||||
|
||||
Encodes numbers as a [Sqid](https://sqids.org/) which is a YouTube-like ID string.
|
||||
The output alphabet is `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`.
|
||||
@ -1786,7 +1786,7 @@ Do not use this function for hashing - the generated IDs can be decoded back int
|
||||
**Syntax**
|
||||
|
||||
```sql
|
||||
encodeSqid(number1, ...)
|
||||
sqidEncode(number1, ...)
|
||||
```
|
||||
|
||||
Alias: `sqid`
|
||||
@ -1802,23 +1802,23 @@ A sqid [String](/docs/en/sql-reference/data-types/string.md).
|
||||
**Example**
|
||||
|
||||
```sql
|
||||
SELECT encodeSqid(1, 2, 3, 4, 5);
|
||||
SELECT sqidEncode(1, 2, 3, 4, 5);
|
||||
```
|
||||
|
||||
```response
|
||||
┌─encodeSqid(1, 2, 3, 4, 5)─┐
|
||||
┌─sqidEncode(1, 2, 3, 4, 5)─┐
|
||||
│ gXHfJ1C6dN │
|
||||
└───────────────────────────┘
|
||||
```
|
||||
|
||||
## decodeSqid
|
||||
## sqidDecode
|
||||
|
||||
Decodes a [Sqid](https://sqids.org/) into numbers.
|
||||
|
||||
**Syntax**
|
||||
|
||||
```sql
|
||||
decodeSqid(number1, ...)
|
||||
sqidDecode(sqid)
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
@ -1827,16 +1827,16 @@ decodeSqid(number1, ...)
|
||||
|
||||
**Returned Value**
|
||||
|
||||
The sqid transformed to numbers [Tuple(UInt64)](/docs/en/sql-reference/data-types/tuple.md).
|
||||
The sqid transformed to numbers [Array(UInt64)](/docs/en/sql-reference/data-types/array.md).
|
||||
|
||||
**Example**
|
||||
|
||||
```sql
|
||||
SELECT decodeSqid('gXHfJ1C6dN');
|
||||
SELECT sqidDecode('gXHfJ1C6dN');
|
||||
```
|
||||
|
||||
```response
|
||||
┌─decodeSqid('gXHfJ1C6dN')─┐
|
||||
┌─sqidDecode('gXHfJ1C6dN')─┐
|
||||
│ [1,2,3,4,5] │
|
||||
└──────────────────────────┘
|
||||
```
|
||||
|
@ -24,17 +24,17 @@ namespace ErrorCodes
|
||||
extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
|
||||
}
|
||||
|
||||
/// encodeSqid(number1, ...)
|
||||
class FunctionEncodeSqid : public IFunction
|
||||
/// sqidEncode(number1, ...)
|
||||
class FunctionSqidEncode : public IFunction
|
||||
{
|
||||
public:
|
||||
static constexpr auto name = "encodeSqid";
|
||||
static constexpr auto name = "sqidEncode";
|
||||
|
||||
String getName() const override { return name; }
|
||||
size_t getNumberOfArguments() const override { return 0; }
|
||||
bool isVariadic() const override { return true; }
|
||||
bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return true; }
|
||||
static FunctionPtr create(ContextPtr) { return std::make_shared<FunctionEncodeSqid>(); }
|
||||
static FunctionPtr create(ContextPtr) { return std::make_shared<FunctionSqidEncode>(); }
|
||||
|
||||
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override
|
||||
{
|
||||
@ -82,16 +82,16 @@ private:
|
||||
sqidscxx::Sqids<> sqids;
|
||||
};
|
||||
|
||||
/// decodeSqid(number1, ...)
|
||||
class FunctionDecodeSqid : public IFunction
|
||||
/// sqidDecode(number1, ...)
|
||||
class FunctionSqidDecode : public IFunction
|
||||
{
|
||||
public:
|
||||
static constexpr auto name = "decodeSqid";
|
||||
static constexpr auto name = "sqidDecode";
|
||||
|
||||
String getName() const override { return name; }
|
||||
size_t getNumberOfArguments() const override { return 1; }
|
||||
bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return true; }
|
||||
static FunctionPtr create(ContextPtr) { return std::make_shared<FunctionDecodeSqid>(); }
|
||||
static FunctionPtr create(ContextPtr) { return std::make_shared<FunctionSqidDecode>(); }
|
||||
|
||||
DataTypePtr getReturnTypeImpl(const ColumnsWithTypeAndName & arguments) const override
|
||||
{
|
||||
@ -131,35 +131,35 @@ private:
|
||||
|
||||
REGISTER_FUNCTION(Sqid)
|
||||
{
|
||||
factory.registerFunction<FunctionEncodeSqid>(FunctionDocumentation{
|
||||
factory.registerFunction<FunctionSqidEncode>(FunctionDocumentation{
|
||||
.description=R"(
|
||||
Transforms numbers into a [Sqid](https://sqids.org/) which is a Youtube-like ID string.)",
|
||||
.syntax="encodeSqid(number1, ...)",
|
||||
.syntax="sqidEncode(number1, ...)",
|
||||
.arguments={{"number1, ...", "Arbitrarily many UInt8, UInt16, UInt32 or UInt64 arguments"}},
|
||||
.returned_value="A hash id [String](/docs/en/sql-reference/data-types/string.md).",
|
||||
.examples={
|
||||
{"simple",
|
||||
"SELECT encodeSqid(1, 2, 3, 4, 5);",
|
||||
"SELECT sqidEncode(1, 2, 3, 4, 5);",
|
||||
R"(
|
||||
┌─encodeSqid(1, 2, 3, 4, 5)─┐
|
||||
┌─sqidEncode(1, 2, 3, 4, 5)─┐
|
||||
│ gXHfJ1C6dN │
|
||||
└───────────────────────────┘
|
||||
)"
|
||||
}}
|
||||
});
|
||||
factory.registerAlias("sqid", FunctionEncodeSqid::name);
|
||||
factory.registerAlias("sqid", FunctionSqidEncode::name);
|
||||
|
||||
factory.registerFunction<FunctionDecodeSqid>(FunctionDocumentation{
|
||||
factory.registerFunction<FunctionSqidDecode>(FunctionDocumentation{
|
||||
.description=R"(
|
||||
Transforms a [Sqid](https://sqids.org/) back into a tuple of numbers.)",
|
||||
.syntax="decodeSqid(number1, ...)",
|
||||
.syntax="sqidDecode(number1, ...)",
|
||||
.arguments={{"sqid", "A sqid"}},
|
||||
.returned_value="A tuple of [UInt64](/docs/en/sql-reference/data-types/int-uint.md).",
|
||||
.examples={
|
||||
{"simple",
|
||||
"SELECT decodeSqid('gXHfJ1C6dN');",
|
||||
"SELECT sqidDecode('gXHfJ1C6dN');",
|
||||
R"(
|
||||
┌─decodeSqid('gXHfJ1C6dN')─┐
|
||||
┌─sqidDecode('gXHfJ1C6dN')─┐
|
||||
│ [1,2,3,4,5] │
|
||||
└──────────────────────────┘
|
||||
)"
|
||||
|
@ -3,24 +3,24 @@
|
||||
SET allow_suspicious_low_cardinality_types = 1;
|
||||
|
||||
SELECT '-- negative tests';
|
||||
SELECT encodeSqid(); -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
|
||||
SELECT decodeSqid(); -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
|
||||
SELECT encodeSqid('1'); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
|
||||
SELECT decodeSqid(1); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
|
||||
SELECT sqidEncode(); -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
|
||||
SELECT sqidDecode(); -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
|
||||
SELECT sqidEncode('1'); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
|
||||
SELECT sqidDecode(1); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
|
||||
|
||||
SELECT '-- const UInt*';
|
||||
SELECT encodeSqid(1) AS sqid, decodeSqid(sqid);
|
||||
SELECT encodeSqid(1, 2) AS sqid, decodeSqid(sqid);
|
||||
SELECT encodeSqid(1, 2, 3) AS sqid, decodeSqid(sqid);
|
||||
SELECT encodeSqid(1::UInt8, 2::UInt16, 3::UInt32, 4::UInt64) AS sqid, decodeSqid(sqid);
|
||||
SELECT encodeSqid(toNullable(1), toLowCardinality(2)) AS sqid;
|
||||
SELECT sqidEncode(1) AS sqid, sqidDecode(sqid);
|
||||
SELECT sqidEncode(1, 2) AS sqid, sqidDecode(sqid);
|
||||
SELECT sqidEncode(1, 2, 3) AS sqid, sqidDecode(sqid);
|
||||
SELECT sqidEncode(1::UInt8, 2::UInt16, 3::UInt32, 4::UInt64) AS sqid, sqidDecode(sqid);
|
||||
SELECT sqidEncode(toNullable(1), toLowCardinality(2)) AS sqid;
|
||||
|
||||
SELECT '-- non-const UInt*';
|
||||
SELECT encodeSqid(materialize(1)) AS sqid, decodeSqid(sqid);
|
||||
SELECT encodeSqid(materialize(1), materialize(2)) AS sqid, decodeSqid(sqid);
|
||||
SELECT encodeSqid(materialize(1), materialize(2), materialize(3)) AS sqid, decodeSqid(sqid);
|
||||
SELECT encodeSqid(materialize(1::UInt8), materialize(2::UInt16), materialize(3::UInt32), materialize(4::UInt64)) AS sqid, decodeSqid(sqid);
|
||||
SELECT encodeSqid(toNullable(materialize(1)), toLowCardinality(materialize(2)));
|
||||
SELECT sqidEncode(materialize(1)) AS sqid, sqidDecode(sqid);
|
||||
SELECT sqidEncode(materialize(1), materialize(2)) AS sqid, sqidDecode(sqid);
|
||||
SELECT sqidEncode(materialize(1), materialize(2), materialize(3)) AS sqid, sqidDecode(sqid);
|
||||
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 '-- alias';
|
||||
SELECT sqid(1, 2);
|
||||
|
@ -701,8 +701,6 @@ PrettySpaceMonoBlock
|
||||
PrettySpaceNoEscapes
|
||||
PrettySpaceNoEscapesMonoBlock
|
||||
Prewhere
|
||||
TotalPrimaryKeyBytesInMemory
|
||||
TotalPrimaryKeyBytesInMemoryAllocated
|
||||
PrivateKeyPassphraseHandler
|
||||
ProfileEvents
|
||||
Profiler
|
||||
@ -924,6 +922,8 @@ Toolset
|
||||
TopK
|
||||
TotalBytesOfMergeTreeTables
|
||||
TotalPartsOfMergeTreeTables
|
||||
TotalPrimaryKeyBytesInMemory
|
||||
TotalPrimaryKeyBytesInMemoryAllocated
|
||||
TotalRowsOfMergeTreeTables
|
||||
TotalTemporaryFiles
|
||||
Tradeoff
|
||||
@ -1848,14 +1848,14 @@ metrica
|
||||
metroHash
|
||||
mfedotov
|
||||
minMap
|
||||
minSampleSizeContinuous
|
||||
minSampleSizeConversion
|
||||
mindsdb
|
||||
minimalistic
|
||||
mininum
|
||||
miniselect
|
||||
minmap
|
||||
minmax
|
||||
minSampleSizeContinuous
|
||||
minSampleSizeConversion
|
||||
mins
|
||||
misconfiguration
|
||||
mispredictions
|
||||
@ -2283,6 +2283,8 @@ splitByString
|
||||
splitByWhitespace
|
||||
splitby
|
||||
sqid
|
||||
sqidDecode
|
||||
sqidEncode
|
||||
sql
|
||||
sqlalchemy
|
||||
sqlinsert
|
||||
|
Loading…
Reference in New Issue
Block a user