private CatalogTable validatePartitionSpec ( ObjectPath tablePath , CatalogPartitionSpec partitionSpec ) throws TableNotExistException , TableNotPartitionedException , PartitionSpecInvalidException { CatalogTable table = validatePartitionedTable ( tablePath ) ; List < String > partitionKeys = table . getPartitionKeys ( ) ; Map < String , String > spec = partitionSpec . getPartitionSpec ( ) ; // The size of partition spec should not exceed the size of partition keys if ( partitionKeys . size ( ) < spec . size ( ) ) { throw new PartitionSpecInvalidException ( catalogName , partitionKeys , tablePath , partitionSpec ) ; } else { int size = spec . size ( ) ; // PartitionSpec should contain the first 'size' number of keys in partition key list for ( int i = 0 ; i < size ; i ++ ) { if ( ! spec . containsKey ( partitionKeys . get ( i ) ) ) { throw new PartitionSpecInvalidException ( catalogName , partitionKeys , tablePath , partitionSpec ) ; } } } return table ; }
Validate the partitioned table and partitionSpec .