Sam
Sam

Reputation: 155

Updating a SQL table in presto

So I'm trying to update the values of a column of a table in Presto SQL; however, it seems there is no UPDATE query in the Presto documentation as noted in here: https://prestodb.github.io/docs/current/sql.html

So basically my script involves a series of queries which merges a bunch of tables and then at the very end I want to update the values of one of the columns of the table

WITH tableA AS (
   do stuff here
),
tableB AS ( 
   do stuff here
),
.
.
.
.
finalTable AS (
   do final merge of tables from above
)
UPDATE
    finalTable
SET
    colD = REPLACE( REPLACE( REPLACE(UPPER(colD), '[', ''), ']', ''), ':', '')
WHERE
    colD IS NOT NULL
SELECT *
FROM
   finalTable

I've tried using ALTER TABLE (https://prestodb.github.io/docs/current/sql/alter-table.html) which seemed close enough to UPDATE but didn't have any luck with that either and would give the following error mismatched input 'ALTER'. Expecting: '(', 'SELECT', 'TABLE', 'VALUES' Does anyone know the proper way to do a column update in Presot?

Upvotes: 2

Views: 17291

Answers (1)

Ashish
Ashish

Reputation: 5791

Update is not possible in Presto. I think some work is going on in PrestoSQL repo to utilize Hive ACID in Presto to make it working for update/delete. And alter command is gonna be very specific for DDL requirements and won't be applicable when you want to update some values in a table.

Upvotes: 1

Related Questions