Can you move the logic of creating new partition into Partition.java (as a new constructor method)? I would like to isolate partition creation code into single class.
559:560 -> use log for printing and also throw an exception back
In semantic analysis of the query we just build up the description of the input into a temporary structure and leave the actual creation of Partition objects into DDLTask. Look at analyzeCreateTable method.
Usually hive.metastore interfaces are not exposed to hive.ql except for hive.ql.metadata. Rest of hive.ql just use hive.ql.metadata to access metadata functionality (there are couple of instances where we hive.metastore is directly used in hive.ql but they shouldn't be unless they are simple model objects without any logic). It may be cleaner if DDLTask calls Hive.addPartition(tbl, part_vals, location) and let Hive.java take care of creating partition object and making metastore call.
Also, tbl.isExternal() can be moved out of the for loop. BTB, why do we want to restrict this to external tables only? The same code can be used in cases where user creates the partition data in the location that internal tables expect but wants to add metadata right?