infoverload commented on a change in pull request #18813:
URL: https://github.com/apache/flink/pull/18813#discussion_r810103499
##########
File path: docs/content/docs/dev/table/types.md
##########
@@ -1487,6 +1481,88 @@ Not supported.
{{< /tab >}}
{{< /tabs >}}
+Casting
+-------
+
+Flink SQL can perform casting between a defined pair `from` type and `target`
type. While some
+casting operations can always succeed no matter the input value, others can
fail at runtime, that
+is, for some input values there is no way to create a value for the target
type. For example, it's
+always possible to convert `INT` to `STRING`, but viceversa is not true, as
you can provide an
+input `STRING` which cannot be converted to `INT`, like `'abc'`.
+
+Flink SQL, during planning, rejects queries which cast pairs are invalid with
+a `ValidationException`, e.g. when trying to cast a `TIMESTAMP` to an
`INTERVAL`, but the user needs
+to handle manually cases where a cast pair is valid, but can fail at runtime.
+
+In Flink SQL casting can be performed using one of the two following built-in
functions:
+
+* `CAST`: The regular cast function defined by the SQL standard. It can fail
the job if the cast operation is fallible and the provided input is not valid.
The type inference will preserve the nullability of the input type.
+* `TRY_CAST`: An extension to the regular cast function which returns `NULL`
in case the cast operation fails. Its return type is always nullable.
Review comment:
```suggestion
In Flink SQL, casting can be performed by using one of the two following
built-in functions:
* `CAST`: The regular cast function defined by the SQL standard. It can fail
the job if the cast operation is fallible and the provided input is not valid.
The type inference will preserve the nullability of the input type.
* `TRY_CAST`: An extension to the regular cast function which returns `NULL`
in case the cast operation fails. Its return type is always nullable.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]