This command is used to update the CarbonData table based on the column expression and optional filtering conditions.
UPDATE <CARBON TABLE> SET (column_name1, column_name2, ... column_name n) = (column1_expression , column2_expression , column3_expression ... column n_expression ) [ WHERE { <filter_condition> } ];
UPDATE <CARBON TABLE> SET (column_name1, column_name2,) = (select sourceColumn1, sourceColumn2 from sourceTable [ WHERE { <filter_condition> } ] ) [ WHERE { <filter_condition> } ];
Parameter |
Description |
---|---|
CARBON TABLE |
Name of the CarbonData table to be updated |
column_name |
Target column to be updated |
sourceColumn |
Column value of the source table that needs to be updated in the target table |
sourceTable |
Table from which the records are updated to the target table |
Note the following before running this command:
For example, update t_carbn01 a set (a.item_type_code, a.profit) = ( select b.item_type_cd, sum(b.profit) from t_carbn01b b where item_type_cd =2 group by item_type_code);.
In the preceding example, aggregate function sum(b.profit) and GROUP BY clause are used in the subquery. As a result, the UPDATE operation will fail.
Syntax:
SET carbon.input.segments. <database_name>. <table_name>=*;
update carbonTable1 d set (d.column3,d.column5 ) = (select s.c33 ,s.c55 from sourceTable1 s where d.column1 = s.c11) where d.column1 = 'country' exists( select * from table3 o where o.c2 > 1);
update carbonTable1 d set (c3) = (select s.c33 from sourceTable1 s where d.column1 = s.c11) where exists( select * from iud.other o where o.c2 > 1);
update carbonTable1 set (c2, c5 ) = (c2 + 1, concat(c5 , "y" ));
update carbonTable1 d set (c2, c5 ) = (c2 + 1, "xyx") where d.column1 = 'india';
update carbonTable1 d set (c2, c5 ) = (c2 + 1, "xyx") where d.column1 = 'india' and exists( select * from table3 o where o.column2 > 1);
Success or failure will be recorded in the driver log and on the client.