troubleshooting

How to convert bytea column to varchar in RisingWave?

I have a bytea column that contains text in RisingWave. When I try to cast it to varchar, I get a hexadecimal output instead of the actual text. How can I convert the bytea column to varchar in RisingWave and decode it properly if it is utf-8 encoded?

Ne

Neil

Asked on Dec 15, 2023

  1. To convert a bytea column to varchar in RisingWave and decode it properly if it is utf-8 encoded, you can use the convert_from function.

  2. Example:

SELECT convert_from('\x6a6f616e6e61', 'uTF-8');
-- Output: joanna
  1. This function will decode the utf-8 encoded text from the bytea column and display it as a varchar string.
Dec 15, 2023Edited by