troubleshooting

How to force a column to be stored as `bytea` in a RW table in MySQL JDBC sink?

I'm having a problem with type conversion of binary(16) in the jdbc mysql sink. The issue arises when trying to store a text representation of a binary(16) column in the sink table. Is there a way to CAST the input data before it is inserted in the table or force the jdbc sink to encode the text as binary just before sending it?

Fl

Florian Klein

Asked on Mar 07, 2024

  1. You can use the convert_to function to convert text to bytea in the sink table:
declare
  v_text text := 'your_text_value';
  v_bytea bytea;
begin
  v_bytea := convert_to(v_text, 'UTF8');
end;
  1. Another approach is to use the decode function to convert the text representation to bytea:
create sink product_pim1_to_pim2 as
select decode(ltrim(uuid, '0x'), 'hex') as uuid, id, product_model_id, raw_values from product where tenant = 'pim1';
Mar 07, 2024Edited by