@@ -240,6 +240,26 @@ public void delete(final QualifiedName tableName) {
240
240
new SqlParameterValue (Types .BIGINT , ids .getSdsId ()));
241
241
jdbcTemplate .update (SQL .UPDATE_SDS_SERDE , new SqlParameterValue (Types .BIGINT , null ),
242
242
new SqlParameterValue (Types .BIGINT , ids .getSdsId ()));
243
+ //
244
+ // Ignore the error. We should be ignoring the error when table does not exist.
245
+ // In certain hive metastore versions, these tables might not be present.
246
+ // TODO: Better handle this non-existing tables.
247
+ //
248
+ try {
249
+ jdbcTemplate .update (SQL .DELETE_COLUMNS_OLD , new SqlParameterValue (Types .BIGINT , ids .getSdsId ()));
250
+ } catch (DataAccessException ignored ) {
251
+ log .debug ("Ignore. Probably table COLUMNS_OLD does not exist." );
252
+ }
253
+ try {
254
+ jdbcTemplate .update (SQL .DELETE_TBL_PRIVS , new SqlParameterValue (Types .BIGINT , ids .getTableId ()));
255
+ } catch (DataAccessException ignored ) {
256
+ log .debug ("Ignore. Probably table TBL_PRIVS does not exist." );
257
+ }
258
+ try {
259
+ jdbcTemplate .update (SQL .DELETE_TBL_COL_PRIVS , new SqlParameterValue (Types .BIGINT , ids .getTableId ()));
260
+ } catch (DataAccessException ignored ) {
261
+ log .debug ("Ignore. Probably table TBL_COL_PRIVS does not exist." );
262
+ }
243
263
jdbcTemplate .update (SQL .DELETE_COLUMNS_V2 , new SqlParameterValue (Types .BIGINT , ids .getCdId ()));
244
264
jdbcTemplate .update (SQL .DELETE_CDS , new SqlParameterValue (Types .BIGINT , ids .getCdId ()));
245
265
jdbcTemplate .update (SQL .DELETE_PARTITION_KEYS , new SqlParameterValue (Types .BIGINT , ids .getTableId ()));
@@ -292,6 +312,7 @@ private static class SQL {
292
312
static final String INSERT_TABLE_PARAMS =
293
313
"insert into TABLE_PARAMS(tbl_id,param_key,param_value) values (?,?,?)" ;
294
314
static final String UPDATE_SDS_CD = "UPDATE SDS SET CD_ID=? WHERE SD_ID=?" ;
315
+ static final String DELETE_COLUMNS_OLD = "DELETE FROM COLUMNS_OLD WHERE SD_ID=?" ;
295
316
static final String DELETE_COLUMNS_V2 = "DELETE FROM COLUMNS_V2 WHERE CD_ID=?" ;
296
317
static final String DELETE_CDS = "DELETE FROM CDS WHERE CD_ID=?" ;
297
318
static final String DELETE_PARTITION_KEYS = "DELETE FROM PARTITION_KEYS WHERE TBL_ID=?" ;
@@ -308,6 +329,8 @@ private static class SQL {
308
329
static final String DELETE_SERDE_PARAMS = "DELETE FROM SERDE_PARAMS WHERE SERDE_ID=?" ;
309
330
static final String DELETE_SERDES = "DELETE FROM SERDES WHERE SERDE_ID=?" ;
310
331
static final String DELETE_SDS = "DELETE FROM SDS WHERE SD_ID=?" ;
332
+ static final String DELETE_TBL_PRIVS = "DELETE FROM TBL_PRIVS WHERE TBL_ID=?" ;
333
+ static final String DELETE_TBL_COL_PRIVS = "DELETE FROM TBL_COL_PRIVS WHERE TBL_ID=?" ;
311
334
static final String DELETE_TBLS = "DELETE FROM TBLS WHERE TBL_ID=?" ;
312
335
static final String TABLE_SEQUENCE_IDS = "select t.tbl_id, s.sd_id, s.cd_id, s.serde_id"
313
336
+ " from DBS d join TBLS t on d.db_id=t.db_id join SDS s on t.sd_id=s.sd_id"
0 commit comments