adesh-rao commented on a change in pull request #1528:
URL: https://github.com/apache/hive/pull/1528#discussion_r497652090



##########
File path: 
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/column/change/AlterTableChangeColumnOperation.java
##########
@@ -33,6 +35,7 @@
 import org.apache.hadoop.hive.ql.metadata.Partition;
 import org.apache.hadoop.hive.ql.metadata.Table;
 import org.apache.hadoop.hive.serde2.avro.AvroSerdeUtils;
+import org.apache.spark.util.CollectionsUtils;

Review comment:
       required?

##########
File path: 
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java
##########
@@ -63,6 +64,8 @@
 import org.datanucleus.api.jdo.JDOPersistenceManagerFactory;
 import org.junit.Assert;
 import org.junit.Before;
+import org.junit.experimental.categories.Category;

Review comment:
       required?

##########
File path: 
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreServerUtils.java
##########
@@ -1554,4 +1555,30 @@ 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) {
+    if (CollectionUtils.isNotEmpty(sd.getBucketCols())) {
+      List<String> columnNames =
+          
getColumnNames(sd.getCols()).stream().map(String::toLowerCase).collect(Collectors.toList());
+      return 
columnNames.containsAll(sd.getBucketCols().stream().map(String::toLowerCase).collect(Collectors.toList()));

Review comment:
       add a null check for columnNames? getColumnNames returns null too.

##########
File path: 
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java
##########
@@ -3428,4 +3432,44 @@ public void testUpdatePartitionStat_doesNotUpdateStats() 
throws Exception {
     m.invoke(hms, tbl, part, false, null);
     verify(wh, never()).getFileStatusesForLocation(part.getSd().getLocation());
   }
+
+  @Test(expected = InvalidOperationException.class)

Review comment:
       Also, Is it a positive test case or negative? I see that there is an 
expected error but we are doing the positive validations too. We should break 
this into two, right?

##########
File path: 
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java
##########
@@ -3428,4 +3432,44 @@ public void testUpdatePartitionStat_doesNotUpdateStats() 
throws Exception {
     m.invoke(hms, tbl, part, false, null);
     verify(wh, never()).getFileStatusesForLocation(part.getSd().getLocation());
   }
+
+  @Test(expected = InvalidOperationException.class)

Review comment:
       Won't adding a qtest be better?
   
   You are explicitly doing `tblUpdated.getSd().getBucketCols()` and updating 
them in the test. qtest will check end to end flow and you don't need to bother 
about getting Sd and updating the cols explicitly (Just a single alter table 
will do the trick). 




----------------------------------------------------------------
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

Reply via email to