diff --git a/docs/en/sql-reference/functions/string-functions.md b/docs/en/sql-reference/functions/string-functions.md index 045b3cd1520998fb80fb03cb337a04cac4042ff0..a31237ecfb577cf83b8b5aa0415131792672d33c 100644 --- a/docs/en/sql-reference/functions/string-functions.md +++ b/docs/en/sql-reference/functions/string-functions.md @@ -500,7 +500,7 @@ normalizeQuery(x) - `x` — Sequence of characters. [String](../../sql-reference/data-types/string.md). -**Returned value(s)** +**Returned value** - Sequence of characters with placeholders. diff --git a/docs/en/sql-reference/functions/url-functions.md b/docs/en/sql-reference/functions/url-functions.md index fe072531aa460db4c21b36e8ecab8bca3750671d..89154ac3d025806213309fdb699781504f265247 100644 --- a/docs/en/sql-reference/functions/url-functions.md +++ b/docs/en/sql-reference/functions/url-functions.md @@ -244,79 +244,4 @@ Removes the query string and fragment identifier. The question mark and number s Removes the ‘name’ URL parameter, if present. This function works under the assumption that the parameter name is encoded in the URL exactly the same way as in the passed argument. -## normalizeQuery {#normalized-query} - -Replaces literals, sequences of literals and complex aliases with placeholders. - -**Syntax** -``` sql -normalizeQuery(x) -``` -!!! note "Note" -SELECT count(*) FROM table WHERE date = '2020-01-02' AND id IN (1, 2, 3) LIMIT 10, 10 -should be replaced to -SELECT count(*) FROM table WHERE date = ? AND id IN (?) LIMIT ? - -**Parameters** - -- `x` — Sequence of characters. [String](../../sql-reference/data-types/string.md). - -**Returned value(s)** - -- Sequence of characters with placeholders. - -Type: [String](../../sql-reference/data-types/string.md). - -**Example** - -Query: - -``` sql -SELECT normalizeQuery('[1, 2, 3, x]') AS query; -``` - -Result: - -``` text -┌─query────┐ -│ [?.., x] │ -└──────────┘ -``` - -## normalizedQueryHash {#normalized-query-hash} - -Returns identical 64bit hash values without the values of literals for similar queries. It helps to analyze query log. - -**Syntax** - -``` sql -normalizedQueryHash(x) -``` - -**Parameters** - -- `x` — Sequence of characters. [String](../../sql-reference/data-types/string.md). - -**Returned value** - -- Hash value. - -Type: [UInt64](../../sql-reference/data-types/int-uint.md#uint-ranges). - -**Example** - -Query: - -``` sql -SELECT normalizedQueryHash('SELECT 1 AS `xyz`') != normalizedQueryHash('SELECT 1 AS `abc`') AS res; -``` - -Result: - -``` text -┌─res─┐ -│ 1 │ -└─────┘ -``` - [Original article](https://clickhouse.tech/docs/en/query_language/functions/url_functions/) diff --git a/docs/ru/sql-reference/functions/string-functions.md b/docs/ru/sql-reference/functions/string-functions.md index a9e254f215bf9e36c15e43120b8d06943dd92b90..134c096de84ebfe6e16136a8c8dff8ba905269a3 100644 --- a/docs/ru/sql-reference/functions/string-functions.md +++ b/docs/ru/sql-reference/functions/string-functions.md @@ -479,4 +479,75 @@ SELECT trimBoth(' Hello, world! ') Тип результата — UInt64. +## normalizeQuery {#normalized-query} + +Заменяет литералы, последовательности литералов и сложные псевдонимы заполнителями. + +**Синтаксис** +``` sql +normalizeQuery(x) +``` + +**Параметры** + +- `x` — Последовательность символов. [String](../../sql-reference/data-types/string.md). + +**Возвращаемое значение** + +- Последовательность символов с заполнителями. + +Тип: [String](../../sql-reference/data-types/string.md). + +**Пример** + +Запрос: + +``` sql +SELECT normalizeQuery('[1, 2, 3, x]') AS query; +``` + +Результат: + +``` text +┌─query────┐ +│ [?.., x] │ +└──────────┘ +``` + +## normalizedQueryHash {#normalized-query-hash} + +Возвращает идентичные 64-битные хэш - суммы без значений литералов для аналогичных запросов. Это помогает анализировать журнал запросов. + +**Синтаксис** + +``` sql +normalizedQueryHash(x) +``` + +**Параметры** + +- `x` — Последовательность символов. [String](../../sql-reference/data-types/string.md). + +**Возвращаемое значение** + +- Хэш-сумма. + +Тип: [UInt64](../../sql-reference/data-types/int-uint.md#uint-ranges). + +**Пример** + +Запрос: + +``` sql +SELECT normalizedQueryHash('SELECT 1 AS `xyz`') != normalizedQueryHash('SELECT 1 AS `abc`') AS res; +``` + +Результат: + +``` text +┌─res─┐ +│ 1 │ +└─────┘ +``` + [Оригинальная статья](https://clickhouse.tech/docs/ru/query_language/functions/string_functions/)