Home > database >  Athena INSERT INTO error if string contains single quote and comma
Athena INSERT INTO error if string contains single quote and comma

Time:07-11

I have to INSERT a record into Athena, I have used below INSERT INTO query but I am getting error because of the column title which contains single quote and a comma after 35 in the string.

insert into database.product (title,description) 
values (
'Waxpol Vinyl & Leather Polish (35', Ltr.)',
'Restores with an extremely High & Durable Shine & Gloss.'
)

Error:

enter image description here FYI: The table is a parquet format

CodePudding user response:

You need to escape single quote in 'Waxpol Vinyl & Leather Polish (35', Ltr.)' otherwise it becomes 'Waxpol Vinyl & Leather Polish (35' string followed by some invalid SQL. You can do it by using extra single quote:

insert into database.product (title,description) 
values (
'Waxpol Vinyl & Leather Polish (35'', Ltr.)',
'Restores with an extremely High & Durable Shine & Gloss.'
)
  • Related