Using try_convert in Yandex MPP Analytics for PostgreSQL
Warning
Apache Cloudberry™ does not support this extension.
try_convert is a Yandex Cloud extension which works in the same way as the TRY_CONVERTtry_convert, such conversions are performed in pl/pgsql, resulting in increased CPU consumption.
The extension only supports the standard Greenplum® data types. To use other data types, add them using the add_type_for_try_convert function.
Here is an example:
SELECT add_type_for_try_convert('hstore'::regtype);
For more information about this extension, see this try_convert guide
To install the extension, contact support
Use cases
-
Convert text that is convertible to a number:
SELECT TRY_CONVERT('42'::text, 0::int2);The returned result is
42. -
Convert text that is not convertible to a number:
SELECT TRY_CONVERT('42d'::text, 1234::int2);The returned result is
1234.
Greenplum® and Greenplum Database® are registered trademarks or trademarks of Broadcom Inc. in the United States and/or other countries.
Apache® and Apache Cloudberry™ are registered trademarks or trademarks of the Apache Software Foundation in the United States and/or other countries.