`select regexp_replace(<column>, '\s+', ' ')` wants explicit type cast, but how?

StackOverflow https://stackoverflow.com/questions/21702268

  •  09-10-2022
  •  | 
  •  

Вопрос

The query:

update enquiry_address_data  
set address_line_1 = upper(regexp_replace(btrim(address_line_1), '\s+', ' '));

returns

ERROR: function regexp_replace(text, "unknown", "unknown") does not exist
Hint: No function matches the given name and argument types. You may need to add explicit type casts.

I added explicit type casts like so:

update enquiry_address_data  
set address_line_1 = upper(regexp_replace(btrim(address_line_1), '\s+' :: text, ' ' :: text));

still I get

ERROR: function regexp_replace(text, character varying, character varying) does not exist
Hint: No function matches the given name and argument types. You may need to add explicit type casts.

I'm using PostgreSql 9.3 JDBC driver connected to an Amazon RedShift instance

Это было полезно?

Решение

Redshift doesn't have regexp_replace, it's cut down fork of an old PostgreSQL version with a bunch of added stuff.

See the Redshift documentation. See also \df pg_catalog.* or \df pg_catalog.*regexp*.

Другие советы

regexp_replace is one of many unsupported PostgreSQL functions in redshift.

One by one, those functions are added - take a look at a documentation history.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top