ramitg254 commented on code in PR #6413:
URL: https://github.com/apache/hive/pull/6413#discussion_r3491574495
##########
ql/src/java/org/apache/hadoop/hive/ql/metadata/Table.java:
##########
@@ -916,6 +987,9 @@ public void setDbName(String databaseName) {
}
public List<FieldSchema> getPartitionKeys() {
+ if (tTable.getPartitionKeys() == null) {
+ tTable.setPartitionKeys(new ArrayList<>());
Review Comment:
1. didn't set to immutable list is not because of a test failure but I saw
an occurrence earlier in createTable method which apart from using
setPartCols(), mutates the list directly like :
https://github.com/apache/hive/blob/9e38b8a3c58720899f413fe2531fed4138fb0a7f/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java#L872
there is possibility there could be other occurences as well similar to it
so for a safe option kept a mutable list
2. this change is introduced to ensure that no need use null check every
time at the place of usage of `getPartitionKeys()`, found out while updating
the usage of earlier `getPartCols` which used to do the same after calling
`getPartitionKeys()` and set to empty list in case it is null. So this change
is to prevent we shouldn't have to do null check every time and
`getPartitionKeys()` is used extensively so to prevent any kind of
`NullPointerException`
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]