From 8d5d0ef38f9e5e3a80a53366c4f32eb22e7332dd Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Tue, 5 Dec 2023 13:45:33 +0300 Subject: [PATCH] Revert "Add `sqid()` function" --- .gitmodules | 3 - contrib/CMakeLists.txt | 1 - contrib/sqids-cpp | 1 - contrib/sqids-cpp-cmake/CMakeLists.txt | 14 --- .../sql-reference/functions/hash-functions.md | 31 ------ src/Common/config.h.in | 1 - src/Functions/CMakeLists.txt | 4 - src/Functions/FunctionSqid.cpp | 97 ------------------- src/configure_config.cmake | 3 - ...5_all_new_functions_must_be_documented.sql | 2 +- .../queries/0_stateless/02933_sqid.reference | 13 --- tests/queries/0_stateless/02933_sqid.sql | 22 ----- .../aspell-ignore/en/aspell-dict.txt | 2 - 13 files changed, 1 insertion(+), 193 deletions(-) delete mode 160000 contrib/sqids-cpp delete mode 100644 contrib/sqids-cpp-cmake/CMakeLists.txt delete mode 100644 src/Functions/FunctionSqid.cpp delete mode 100644 tests/queries/0_stateless/02933_sqid.reference delete mode 100644 tests/queries/0_stateless/02933_sqid.sql diff --git a/.gitmodules b/.gitmodules index 53ef899dd99..af90c788012 100644 --- a/.gitmodules +++ b/.gitmodules @@ -357,6 +357,3 @@ [submodule "contrib/pocketfft"] path = contrib/pocketfft url = https://github.com/mreineck/pocketfft.git -[submodule "contrib/sqids-cpp"] - path = contrib/sqids-cpp - url = https://github.com/sqids/sqids-cpp.git diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 3d3b9b72faf..a8f0705df88 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -156,7 +156,6 @@ add_contrib (nuraft-cmake NuRaft) add_contrib (fast_float-cmake fast_float) add_contrib (datasketches-cpp-cmake datasketches-cpp) add_contrib (incbin-cmake incbin) -add_contrib (sqids-cpp-cmake sqids-cpp) option(ENABLE_NLP "Enable NLP functions support" ${ENABLE_LIBRARIES}) if (ENABLE_NLP) diff --git a/contrib/sqids-cpp b/contrib/sqids-cpp deleted file mode 160000 index 3756e537d4d..00000000000 --- a/contrib/sqids-cpp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3756e537d4d48cc0dd4176801fe19f99601439b0 diff --git a/contrib/sqids-cpp-cmake/CMakeLists.txt b/contrib/sqids-cpp-cmake/CMakeLists.txt deleted file mode 100644 index 7eb77c92437..00000000000 --- a/contrib/sqids-cpp-cmake/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -option(ENABLE_SQIDS "Enable sqids support" ${ENABLE_LIBRARIES}) -if ((NOT ENABLE_SQIDS)) - message (STATUS "Not using sqids") - return() -endif() - -set (SQIDS_SOURCE_DIR "${ClickHouse_SOURCE_DIR}/contrib/sqids-cpp") -set (SQIDS_INCLUDE_DIR "${SQIDS_SOURCE_DIR}/include") - -add_library(_sqids INTERFACE) -target_include_directories(_sqids SYSTEM INTERFACE ${SQIDS_INCLUDE_DIR}) - -add_library(ch_contrib::sqids ALIAS _sqids) -target_compile_definitions(_sqids INTERFACE ENABLE_SQIDS) diff --git a/docs/en/sql-reference/functions/hash-functions.md b/docs/en/sql-reference/functions/hash-functions.md index 4816a6f0032..7276437ec82 100644 --- a/docs/en/sql-reference/functions/hash-functions.md +++ b/docs/en/sql-reference/functions/hash-functions.md @@ -1776,34 +1776,3 @@ Result: │ (('queries','database','analytical'),('oriented','processing','DBMS')) │ └────────────────────────────────────────────────────────────────────────┘ ``` - -## sqid - -Transforms numbers into YouTube-like short URL hash called [Sqid](https://sqids.org/). -To use this function, set setting `allow_experimental_hash_functions = 1`. - -**Syntax** - -```sql -sqid(number1,...) -``` - -**Arguments** - -- A variable number of UInt8, UInt16, UInt32 or UInt64 numbers. - -**Returned Value** - -A hash id [String](/docs/en/sql-reference/data-types/string.md). - -**Example** - -```sql -SELECT sqid(1, 2, 3, 4, 5); -``` - -```response -┌─sqid(1, 2, 3, 4, 5)─┐ -│ gXHfJ1C6dN │ -└─────────────────────┘ -``` diff --git a/src/Common/config.h.in b/src/Common/config.h.in index f84e28942c5..ea77e2fed2d 100644 --- a/src/Common/config.h.in +++ b/src/Common/config.h.in @@ -27,7 +27,6 @@ #cmakedefine01 USE_H3 #cmakedefine01 USE_S2_GEOMETRY #cmakedefine01 USE_FASTOPS -#cmakedefine01 USE_SQIDS #cmakedefine01 USE_NLP #cmakedefine01 USE_VECTORSCAN #cmakedefine01 USE_LIBURING diff --git a/src/Functions/CMakeLists.txt b/src/Functions/CMakeLists.txt index 89676594581..4b0d9335198 100644 --- a/src/Functions/CMakeLists.txt +++ b/src/Functions/CMakeLists.txt @@ -79,10 +79,6 @@ if (ENABLE_NLP) list (APPEND PRIVATE_LIBS ch_contrib::cld2) endif() -if (TARGET ch_contrib::sqids) - list (APPEND PRIVATE_LIBS ch_contrib::sqids) -endif() - if (TARGET ch_contrib::h3) list (APPEND PRIVATE_LIBS ch_contrib::h3) endif() diff --git a/src/Functions/FunctionSqid.cpp b/src/Functions/FunctionSqid.cpp deleted file mode 100644 index 24868d9a13e..00000000000 --- a/src/Functions/FunctionSqid.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#include "config.h" - -#ifdef ENABLE_SQIDS - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace DB -{ - -namespace ErrorCodes -{ - extern const int ILLEGAL_TYPE_OF_ARGUMENT; - extern const int SUPPORT_IS_DISABLED; - extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH; -} - -// sqid(number1, ...) -class FunctionSqid : public IFunction -{ -public: - static constexpr auto name = "sqid"; - - 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 false; } - - static FunctionPtr create(ContextPtr context) - { - if (!context->getSettingsRef().allow_experimental_hash_functions) - throw Exception( - ErrorCodes::SUPPORT_IS_DISABLED, - "Hashing function '{}' is experimental. Set `allow_experimental_hash_functions` setting to enable it", - name); - - return std::make_shared(); - } - - DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override - { - if (arguments.empty()) - throw Exception(ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH, "Function {} requires at least one argument.", getName()); - - for (size_t i = 0; i < arguments.size(); ++i) - { - if (!checkDataTypes< - DataTypeUInt8, - DataTypeUInt16, - DataTypeUInt32, - DataTypeUInt64>(arguments[i].get())) - throw Exception( - ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, - "Argument {} for function {} must have datatype UInt*, given type: {}.", - i, getName(), arguments[i]->getName()); - } - - return std::make_shared(); - } - - ColumnPtr executeImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr &, size_t input_rows_count) const override - { - size_t num_args = arguments.size(); - auto col_res = ColumnString::create(); - - sqidscxx::Sqids<> sqids; - std::vector numbers(num_args); - for (size_t i = 0; i < input_rows_count; ++i) - { - for (size_t j = 0; j < num_args; ++j) - { - const ColumnWithTypeAndName & arg = arguments[j]; - ColumnPtr current_column = arg.column; - numbers[j] = current_column->getUInt(i); - } - auto id = sqids.encode(numbers); - col_res->insert(id); - } - return col_res; - } -}; - -REGISTER_FUNCTION(Sqid) -{ - factory.registerFunction(); -} -} - -#endif diff --git a/src/configure_config.cmake b/src/configure_config.cmake index c3c6d9be6da..2980fde4851 100644 --- a/src/configure_config.cmake +++ b/src/configure_config.cmake @@ -128,9 +128,6 @@ endif() if (TARGET ch_contrib::fastops) set(USE_FASTOPS 1) endif() -if (TARGET ch_contrib::sqids) - set(USE_SQIDS 1) -endif() if (TARGET ch_contrib::vectorscan) set(USE_VECTORSCAN 1) endif() diff --git a/tests/queries/0_stateless/02415_all_new_functions_must_be_documented.sql b/tests/queries/0_stateless/02415_all_new_functions_must_be_documented.sql index 729a0b3995c..148ad303bd4 100644 --- a/tests/queries/0_stateless/02415_all_new_functions_must_be_documented.sql +++ b/tests/queries/0_stateless/02415_all_new_functions_must_be_documented.sql @@ -2,7 +2,7 @@ -- Please help shorten this list down to zero elements. SELECT name FROM system.functions WHERE NOT is_aggregate AND origin = 'System' AND alias_to = '' AND length(description) < 10 AND name NOT IN ( - 'MD4', 'MD5', 'SHA1', 'SHA224', 'SHA256', 'SHA384', 'SHA512', 'halfMD5', 'sqid', + 'MD4', 'MD5', 'SHA1', 'SHA224', 'SHA256', 'SHA384', 'SHA512', 'halfMD5', 'aes_decrypt_mysql', 'aes_encrypt_mysql', 'decrypt', 'encrypt', 'base64Decode', 'base64Encode', 'tryBase64Decode', 'convertCharset', diff --git a/tests/queries/0_stateless/02933_sqid.reference b/tests/queries/0_stateless/02933_sqid.reference deleted file mode 100644 index 4506cc4d01a..00000000000 --- a/tests/queries/0_stateless/02933_sqid.reference +++ /dev/null @@ -1,13 +0,0 @@ --- negative tests --- const UInt* -Uk -XMbT -86Rf07 -Td1EnWQo -XMbT --- non-const UInt* -Uk -XMbT -86Rf07 -Td1EnWQo -XMbT diff --git a/tests/queries/0_stateless/02933_sqid.sql b/tests/queries/0_stateless/02933_sqid.sql deleted file mode 100644 index db8b2f29ee8..00000000000 --- a/tests/queries/0_stateless/02933_sqid.sql +++ /dev/null @@ -1,22 +0,0 @@ --- Tags: no-fasttest - -SET allow_experimental_hash_functions = 1; -SET allow_suspicious_low_cardinality_types = 1; - -SELECT '-- negative tests'; -SELECT sqid(); -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH } -SELECT sqid('1'); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT } - -SELECT '-- const UInt*'; -SELECT sqid(1); -SELECT sqid(1, 2); -SELECT sqid(1, 2, 3); -SELECT sqid(1::UInt8, 2::UInt16, 3::UInt32, 4::UInt64); -SELECT sqid(toNullable(1), toLowCardinality(2)); - -SELECT '-- non-const UInt*'; -SELECT sqid(materialize(1)); -SELECT sqid(materialize(1), materialize(2)); -SELECT sqid(materialize(1), materialize(2), materialize(3)); -SELECT sqid(materialize(1::UInt8), materialize(2::UInt16), materialize(3::UInt32), materialize(4::UInt64)); -SELECT sqid(toNullable(materialize(1)), toLowCardinality(materialize(2))); diff --git a/utils/check-style/aspell-ignore/en/aspell-dict.txt b/utils/check-style/aspell-ignore/en/aspell-dict.txt index becd6271b95..9f7eed82dde 100644 --- a/utils/check-style/aspell-ignore/en/aspell-dict.txt +++ b/utils/check-style/aspell-ignore/en/aspell-dict.txt @@ -1791,7 +1791,6 @@ logTrace logagent loghouse london -lookups lowcardinality lowerUTF lowercased @@ -2278,7 +2277,6 @@ splitByRegexp splitByString splitByWhitespace splitby -sqid sql sqlalchemy sqlinsert