diff --git a/src/Functions/FunctionHashID.h b/src/Functions/FunctionHashID.h index 30f08c96eca..e469381a784 100644 --- a/src/Functions/FunctionHashID.h +++ b/src/Functions/FunctionHashID.h @@ -52,6 +52,7 @@ public: bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return false; } bool useDefaultImplementationForConstants() const override { return true; } + ColumnNumbers getArgumentsThatAreAlwaysConstant() const override { return {1, 2, 3}; } DataTypePtr getReturnTypeImpl(const ColumnsWithTypeAndName & arguments) const override { @@ -69,7 +70,7 @@ public: if (arguments.size() > 1) { const auto & hash_col = arguments[1]; - if (!isString(hash_col.type) || !isColumnConst(*hash_col.column.get())) + if (!isString(hash_col.type)) throw Exception( ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Second argument of function {} must be String, got {}", @@ -80,7 +81,7 @@ public: if (arguments.size() > 2) { const auto & min_length_col = arguments[2]; - if (!isUInt8(min_length_col.type) || !isColumnConst(*min_length_col.column.get())) + if (!isUInt8(min_length_col.type)) throw Exception( ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Third argument of function {} must be UInt8, got {}", @@ -91,7 +92,7 @@ public: if (arguments.size() > 3) { const auto & alphabet_col = arguments[3]; - if (!isString(alphabet_col.type) || !isColumnConst(*alphabet_col.column.get())) + if (!isString(alphabet_col.type)) throw Exception( ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Fourth argument of function {} must be String, got {}", diff --git a/tests/queries/0_stateless/02293_hashid.reference b/tests/queries/0_stateless/02293_hashid.reference index f36b1500288..dfc78349c05 100644 --- a/tests/queries/0_stateless/02293_hashid.reference +++ b/tests/queries/0_stateless/02293_hashid.reference @@ -8,5 +8,8 @@ 2 obmgndljgajpkeao 3 dldokmpjpgjgeanb 4 nkdlpgajngjnobme -xkOpDGxQpVB -jR +YQrvD5XGvbx +Bm3zaOq7zbp +oV +oV +6b diff --git a/tests/queries/0_stateless/02293_hashid.sql b/tests/queries/0_stateless/02293_hashid.sql index 45aaefe7356..9938154f169 100644 --- a/tests/queries/0_stateless/02293_hashid.sql +++ b/tests/queries/0_stateless/02293_hashid.sql @@ -1,7 +1,16 @@ +-- Tags: no-backward-compatibility-check SET allow_experimental_hash_functions = 1; select number, hashid(number) from system.numbers limit 5; select number, hashid(number, 's3cr3t', 16, 'abcdefghijklmnop') from system.numbers limit 5; select hashid(1234567890123456, 's3cr3t'); +select hashid(1234567890123456, 's3cr3t2'); SELECT hashid(1, hashid(2)); +SELECT hashid(1, 'k5'); +SELECT hashid(1, 'k5_othersalt'); + +-- https://github.com/ClickHouse/ClickHouse/issues/39672 +SELECT + JSONExtractRaw(257, NULL), + hashid(1024, if(rand() % 10, 'truetruetruetrue', NULL), 's3\0r3t'); -- {serverError 43}