ashish-kumar-sharma commented on a change in pull request #1528: URL: https://github.com/apache/hive/pull/1528#discussion_r498900535
########## File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreServerUtils.java ########## @@ -1554,4 +1555,32 @@ public static Partition createMetaPartitionObject(Table tbl, Map<String, String> } return tpart; } + + /** + * Validate bucket columns should belong to table columns. + * @param sd StorageDescriptor of given table + * @return true if bucket columns are empty or belong to table columns else false + */ + public static boolean validateBucketColumns(StorageDescriptor sd) { + List<String> columnNames = getColumnNames(sd.getCols()); + if(CollectionUtils.isNotEmpty(sd.getBucketCols()) && CollectionUtils.isNotEmpty(columnNames)){ + return columnNames.containsAll(sd.getBucketCols().stream().map(String::toLowerCase).collect(Collectors.toList())); + } else if (CollectionUtils.isNotEmpty(sd.getBucketCols()) && CollectionUtils.isEmpty(columnNames)) { + return false; + } else { + return true; + } + } + + /** + * Generate column name list from the fieldSchema list + * @param cols fieldSchema list + * @return column name list + */ + public static List<String> getColumnNames(List<FieldSchema> cols) { + if (CollectionUtils.isNotEmpty(cols)) { + return cols.stream().map(FieldSchema::getName).collect(Collectors.toList()); Review comment: Expected column name in lower case. But in order to be fail safe added toLowerCase() here also. ---------------------------------------------------------------- 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. 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