mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 16:50:48 +00:00
Update type-conversion-functions.md
This commit is contained in:
parent
46a7b73608
commit
12801f736b
@ -13,7 +13,7 @@ incompatible datatypes (for example from `String` to `Int`). Make sure to check
|
|||||||
|
|
||||||
ClickHouse generally uses the [same behavior as C++ programs](https://en.cppreference.com/w/cpp/language/implicit_conversion).
|
ClickHouse generally uses the [same behavior as C++ programs](https://en.cppreference.com/w/cpp/language/implicit_conversion).
|
||||||
|
|
||||||
`to<type>` functions and [cast](#castx-t) have different behaviour in some cases, for example in case of [LowCardinality](../data-types/lowcardinality.md): [cast](#castx-t) removes [LowCardinality](../data-types/lowcardinality.md) trait `to<type>` functions don't.
|
`to<type>` functions and [cast](#castx-t) have different behaviour in some cases, for example in case of [LowCardinality](../data-types/lowcardinality.md): [cast](#castx-t) removes [LowCardinality](../data-types/lowcardinality.md) trait `to<type>` functions don't. The same with [Nullable](../data-types/nullable).
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
@ -26,6 +26,15 @@ SELECT
|
|||||||
┌─source_type────────────┬─to_type_result_type────┬─cast_result_type─┐
|
┌─source_type────────────┬─to_type_result_type────┬─cast_result_type─┐
|
||||||
│ LowCardinality(String) │ LowCardinality(String) │ String │
|
│ LowCardinality(String) │ LowCardinality(String) │ String │
|
||||||
└────────────────────────┴────────────────────────┴──────────────────┘
|
└────────────────────────┴────────────────────────┴──────────────────┘
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
toTypeName(toNullable('') AS val) AS source_type,
|
||||||
|
toTypeName(toString(val)) AS to_type_result_type,
|
||||||
|
toTypeName(CAST(val, 'String')) AS cast_result_type
|
||||||
|
|
||||||
|
┌─source_type──────┬─to_type_result_type─┬─cast_result_type─┐
|
||||||
|
│ Nullable(String) │ Nullable(String) │ String │
|
||||||
|
└──────────────────┴─────────────────────┴──────────────────┘
|
||||||
```
|
```
|
||||||
|
|
||||||
## toInt(8\|16\|32\|64\|128\|256)
|
## toInt(8\|16\|32\|64\|128\|256)
|
||||||
|
Loading…
Reference in New Issue
Block a user