impala按条件删除数据不支持delete,而是重写覆盖的形式来达成删除的目的。
具体语法:insert overwrite table 表名 select * from 表名 where 需要保留的数据;
注:where 后可以使用<>或者 not in 来筛选需要删除的数据。
如果按照时间批量删除数据,时间字段不是分区字段的情况按照以上方式可以删除,如时间字段是分区字段,则需要使用以下语法:
alter table 表名 drop if exists partition(时间=' ');
例:
alter table 表名 drop if exists partition(etl_dt=cast('2023-12-31' as varchar(90)));