Incorporate feedback

This commit is contained in:
Robert Schulze 2023-09-20 10:00:00 +00:00
parent 652b5e0649
commit f3bf8388b6
No known key found for this signature in database
GPG Key ID: 26703B55FB13728A
2 changed files with 40 additions and 18 deletions

View File

@ -7,28 +7,34 @@ Contains information about normal and aggregate functions.
Columns: Columns:
- `name`(`String`) The name of the function. - `name` ([String](../../sql-reference/datatypes/string.md)) The name of the function.
- `is_aggregate`(`UInt8`) — Whether the function is aggregate. - `is_aggregate` ([UInt8](../../sql-reference/datatypes/int-uint.md)) — Whether the function is an aggregate function.
- `is_deterministic` ([Nullable](../../sql-reference/data-types/nullable.md)([UInt8](../../sql-reference/data-types/int-uint.md))) - Whether the function is deterministic.
- `case_insensitive`, ([UInt8](../../sql-reference/datatypes/int-uint.md)) - Whether the function name can be used case-insensitively.
- `alias_to`, ([String](../../sql-reference/datatypes/string.md)) - The original function name, if the function name is an alias.
- `create_query`, ([String](../../sql-reference/datatypes/enum.md)) - Unused.
- `origin`, ([Enum8](../../sql-reference/datatypes/string.md)) - Unused.
- `description`, ([String](../../sql-reference/datatypes/string.md)) - A high-level description what the function does.
- `syntax`, ([String](../../sql-reference/datatypes/string.md)) - Signature of the function.
- `arguments`, ([String](../../sql-reference/datatypes/string.md)) - What arguments does the function take.
- `returned_value`, ([String](../../sql-reference/datatypes/string.md)) - What does the function return.
- `examples`, ([String](../../sql-reference/datatypes/string.md)) - Example usage of the function.
- `categories`, ([String](../../sql-reference/datatypes/string.md)) - The category of the function.
**Example** **Example**
```sql ```sql
SELECT * FROM system.functions LIMIT 10; SELECT name, is_aggregate, is_deterministic, case_insensitive, alias_to FROM system.functions LIMIT 5;
``` ```
```text ```text
┌─name──────────────────┬─is_aggregate─┬─case_insensitive─┬─alias_to─┬─create_query─┬─origin─┐ ┌─name─────────────────────┬─is_aggregate─┬─is_deterministic─┬─case_insensitive─┬─alias_to─┐
│ logTrace │ 0 │ 0 │ │ │ System │ │ BLAKE3 │ 0 │ 1 │ 0 │ │
│ aes_decrypt_mysql │ 0 │ 0 │ │ │ System │ │ sipHash128Reference │ 0 │ 1 │ 0 │ │
│ aes_encrypt_mysql │ 0 │ 0 │ │ │ System │ │ mapExtractKeyLike │ 0 │ 1 │ 0 │ │
│ decrypt │ 0 │ 0 │ │ │ System │ │ sipHash128ReferenceKeyed │ 0 │ 1 │ 0 │ │
│ encrypt │ 0 │ 0 │ │ │ System │ │ mapPartialSort │ 0 │ 1 │ 0 │ │
│ toBool │ 0 │ 0 │ │ │ System │ └──────────────────────────┴──────────────┴──────────────────┴──────────────────┴──────────┘
│ windowID │ 0 │ 0 │ │ │ System │
│ hopStart │ 0 │ 0 │ │ │ System │
│ hop │ 0 │ 0 │ │ │ System │
│ snowflakeToDateTime64 │ 0 │ 0 │ │ │ System │
└───────────────────────┴──────────────┴──────────────────┴──────────┴──────────────┴────────┘
10 rows in set. Elapsed: 0.002 sec. 5 rows in set. Elapsed: 0.002 sec.
``` ```

View File

@ -16,6 +16,14 @@
namespace DB namespace DB
{ {
namespace ErrorCodes
{
extern const int DICTIONARIES_WAS_NOT_LOADED;
extern const int FUNCTION_NOT_ALLOWED;
extern const int NOT_IMPLEMENTED;
extern const int SUPPORT_IS_DISABLED;
};
enum class FunctionOrigin : Int8 enum class FunctionOrigin : Int8
{ {
SYSTEM = 0, SYSTEM = 0,
@ -134,10 +142,18 @@ void StorageSystemFunctions::fillData(MutableColumns & res_columns, ContextPtr c
{ {
is_deterministic = functions_factory.tryGet(function_name, context)->isDeterministic(); is_deterministic = functions_factory.tryGet(function_name, context)->isDeterministic();
} }
catch (...) catch (const Exception & e)
{ {
/// Some functions throw because they need special configuration or setup before use. /// Some functions throw because they need special configuration or setup before use.
/// Ignore the exception and simply show is_deterministic = NULL. if (e.code() == ErrorCodes::DICTIONARIES_WAS_NOT_LOADED
|| e.code() == ErrorCodes::FUNCTION_NOT_ALLOWED
|| e.code() == ErrorCodes::NOT_IMPLEMENTED
|| e.code() == ErrorCodes::SUPPORT_IS_DISABLED)
{
/// Ignore exception, show is_deterministic = NULL.
}
else
throw;
} }
fillRow(res_columns, function_name, 0, is_deterministic, "", FunctionOrigin::SYSTEM, functions_factory); fillRow(res_columns, function_name, 0, is_deterministic, "", FunctionOrigin::SYSTEM, functions_factory);