Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to cast varbinary to varchar in presto

Tags:

presto

I have the following query where shopname is stored as varbinary instead of varchar type.

select shopname, itemname
from shop_profile
where cast(shopname as varchar) = 'Starbucks';

This query returns an error "line 4:7: Cannot cast varbinary to varchar"

May I know if anyone knows what is the correct syntax to convert varbinary to varchar?

like image 211
adelle Avatar asked Mar 03 '23 16:03

adelle


1 Answers

You can use from_utf8 function.

Also, to_utf8 can cast the literal 'Starbucks' to varbinary type.

like image 120
ebyhr Avatar answered Mar 05 '23 04:03

ebyhr