VenuReddy2103 opened a new pull request, #4536:
URL: https://github.com/apache/hive/pull/4536

   ### What changes were proposed in this pull request?
   Update the `PART_COL_STATS` HMS table during rename hive external table so 
that partition column statistics are usable after rename and also drop table is 
successful.
   
   ### Why are the changes needed?
   With hive.metastore.try.direct.sql.ddl property set to false, drop of 
external partitioned table fails after renaming it. It fails with exception - 
`Caused by: java.sql.SQLIntegrityConstraintViolationException: Cannot delete or 
update a parent row: a foreign key constraint fails 
("metastore"."part_col_stats", CONSTRAINT "PART_COL_STATS_FK" FOREIGN KEY 
("PART_ID") REFERENCES "partitions" ("PART_ID"))`
   `PART_COL_STATS` HMS table has `TABLE_NAME` column to store the hive table 
name and `PART_ID` column to represent the corresponding partition in the hive 
table. `PART_ID` has foreign key constraint with `PART_ID` column on 
PARTITIONS` HMS table.  `PART_COL_STATS` table is not updated during the rename 
hive table operation for external table. It stil holds the old table name for 
the rows belonging to the hive table. So, upon delete table operation of 
renamed hive external table, rows corresponding to the hive table in 
`PART_COL_STATS` are not deleted. Thus, delete partition from `PARTITION` HMS 
table, throws `SQLIntegrityConstraintViolationException` as the `PART_ID` is 
still being referenced in `PART_COL_STATS`.
   
   ### Does this PR introduce _any_ user-facing change?
   No
   
   ### Is the change a dependency upgrade?
   No
   
   ### How was this patch tested?
   Tested manually
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to