How to update delete table Records in hive

Опубликовано: 04 Октябрь 2024
на канале: Sreyobhilashi IT
1,607
19

create table banktab(age int, job string, marital string, education string, default1 string, balance int, housing string,
loan string, contact string, day string, month string, duration string, campaign string, pdays string, previous string,
poutcome string, y string) ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde'
WITH SERDEPROPERTIES (
"separatorChar" = ";",
"quoteChar" = "\""
) location '/hdfspath/bank/' tblproperties ("skip.header.line.count"="1")
limitations:
ur able to delete only manage table .
external table records deletion not possible.
table must be orc / parquet and must have bucketing.
updating column must be same datatype. Means i want to update age 1 to one .. its not possible.
if age 18 (int) that datatype convert to string than only u have to update.
Now ur bucketing 'age' column that bucketing column not possible to update other columns possible to update.

Please change this config to update.
SET hive.support.concurrency=true;
SET hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;
SET hive.enforce.bucketing=true;
SET hive.exec.dynamic.partition.mode=nostrict;

SET hive.compactor.initiator.on=true;
SET hive.compactor.worker.threads=1;

ALTER TABLE bankorc CLUSTERED BY (age) INTO 100 BUCKETS;
ALTER TABLE bankorc SET TBLPROPERTIES ('transactional'='true');


update bankorc set job='buzman' where job='entrepreneur';
delete from bankorc where job='management';

if u struck anywhere join in this group post ur queries I'll try to solve https://t.me/SparkTraining or call +91-8500002025