You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2021/01/14 03:58:59 UTC

[GitHub] [hive] vnhive opened a new pull request #1694: HIVE-24386 : Add builder methods for GetTablesRequest and GetPartitionsRequest to HiveMetaStoreClient

vnhive opened a new pull request #1694:
URL: https://github.com/apache/hive/pull/1694


   HIVE-24386 : Add builder methods for GetTablesRequest and GetPartitionsRequest to HiveMetaStoreClient
   
   This patch builds over the patch for HIVE-24397 and adds builder methods for the request and the projection
   specification classes of Tables and Partitions. The relevant unit tests have also been updated.


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] nrg4878 commented on a change in pull request #1694: HIVE-24386 : Add builder methods for GetTablesRequest and GetPartitionsRequest to HiveMetaStoreClient

Posted by GitBox <gi...@apache.org>.
nrg4878 commented on a change in pull request #1694:
URL: https://github.com/apache/hive/pull/1694#discussion_r552082468



##########
File path: standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesGetExists.java
##########
@@ -555,6 +546,74 @@ public void testGetTableObjectsWithProjectionOfMultiValuedFields() throws Except
     }
   }
 
+  @Test
+  public void testGetTableProjectionSpecification() throws Exception {
+    List<String> tableNames = new ArrayList<>();
+    tableNames.add(testTables[0].getTableName());
+    tableNames.add(testTables[1].getTableName());
+
+    GetProjectionsSpec projectSpec = (new GetTableProjectionsSpecBuilder())
+            .includeTableName()
+            .includeDatabase()
+            .includeSdCdColsName()
+            .includeSdCdColsType()
+            .includeSdCdColsComment()
+            .includeSdLocation()
+            .includeSdInputFormat()
+            .includeSdOutputFormat()
+            .includeSdIsCompressed()
+            .includeSdNumBuckets()
+            .includeSdSerDeInfoName()
+            .includeSdSerDeInfoSerializationLib()
+            .includeSdSerDeInfoParameters()
+            .includeSdSerDeInfoDescription()
+            .includeSdSerDeInfoSerializerClass()
+            .includeSdSerDeInfoDeserializerClass()
+            .includeSdSerDeInfoSerdeType()
+            .includeSdBucketCols()
+            .includeSdSortColsCol()
+            .includeSdSortColsOrder()
+            .includeSdparameters()
+            .includeSdSkewedColNames()
+            .includeSdSkewedColValues()
+            .includeSdSkewedColValueLocationMaps()
+            .includeSdIsStoredAsSubDirectories()
+            .includeOwner()
+            .includeOwnerType()
+            .includeCreateTime()
+            .includeLastAccessTime()
+            .includeRetention()
+            .includePartitionKeysName()
+            .includePartitionKeysType()
+            .includePartitionKeysComment()
+            .includeParameters()
+            .includeViewOriginalText()
+            .includeRewriteEnabled()
+            .includeTableType()
+            .build();
+
+    List<Table> tables = client.getTables(null, DEFAULT_DATABASE, tableNames, projectSpec);
+
+    Assert.assertEquals("Found tables", 2, tables.size());
+
+    for(Table table : tables) {
+      Assert.assertTrue(table.isSetDbName());
+      Assert.assertTrue(table.isSetCatName());
+      Assert.assertTrue(table.isSetTableName());
+      Assert.assertTrue(table.isSetLastAccessTime());
+      Assert.assertTrue(table.isSetSd());
+      StorageDescriptor sd = table.getSd();
+      Assert.assertTrue(sd.isSetCols());
+      Assert.assertTrue(sd.isSetSerdeInfo());
+      Assert.assertTrue(sd.isSetBucketCols());
+      Assert.assertTrue(sd.isSetCompressed());
+      Assert.assertTrue(sd.isSetInputFormat());
+      Assert.assertTrue(sd.isSetSerdeInfo());
+      SerDeInfo serDeInfo = sd.getSerdeInfo();
+      Assert.assertTrue(serDeInfo.isSetSerializationLib());
+    }
+  }
+

Review comment:
       Could you please add a negative test here as well? Include only a couple of fields on the projection spec and test to ensure that some of the other fields are not set on the returned Table objects? Thanks




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] nrg4878 commented on a change in pull request #1694: HIVE-24386 : Add builder methods for GetTablesRequest and GetPartitionsRequest to HiveMetaStoreClient

Posted by GitBox <gi...@apache.org>.
nrg4878 commented on a change in pull request #1694:
URL: https://github.com/apache/hive/pull/1694#discussion_r552081081



##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/client/builder/GetPartitionsRequestBuilder.java
##########
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.metastore.client.builder;
+
+import org.apache.hadoop.hive.metastore.api.GetPartitionsFilterSpec;
+import org.apache.hadoop.hive.metastore.api.GetPartitionsRequest;
+import org.apache.hadoop.hive.metastore.api.GetProjectionsSpec;
+
+import java.util.List;
+
+public class GetPartitionsRequestBuilder {
+    private String catName = null;
+    private String dbName = null;
+    private String tblName = null;
+    private boolean withAuth = true;
+    private String user = null;
+    private List<String> groupNames = null;
+    private GetProjectionsSpec projectionSpec = null;
+    private GetPartitionsFilterSpec filterSpec = null;
+    private List<java.lang.String> processorCapabilities = null;
+    private String processorIdentifier = null;
+    private String validWriteIdList = null;
+
+    public GetPartitionsRequestBuilder(String catName, String dbName, String tblName, boolean withAuth, String user,
+                                       List<String> groupNames, GetProjectionsSpec projectionSpec,
+                                       GetPartitionsFilterSpec filterSpec, List<String> processorCapabilities,
+                                       String processorIdentifier, String validWriteIdList) {
+        this.catName = catName;
+        this.dbName = dbName;
+        this.tblName = tblName;
+        this.withAuth = withAuth;
+        this.user = user;
+        this.groupNames = groupNames;
+        this.projectionSpec = projectionSpec;
+        this.filterSpec = filterSpec;
+        this.processorCapabilities = processorCapabilities;

Review comment:
       the processorCapabilities and the processorIdentifier are meant to be static values for a given instance of HMSClient object. They are not meant to change between different calls. So having it on builder class might be confusing. Should we remove it? 




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] vnhive commented on a change in pull request #1694: HIVE-24386 : Add builder methods for GetTablesRequest and GetPartitionsRequest to HiveMetaStoreClient

Posted by GitBox <gi...@apache.org>.
vnhive commented on a change in pull request #1694:
URL: https://github.com/apache/hive/pull/1694#discussion_r553750841



##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/client/builder/GetPartitionsRequestBuilder.java
##########
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.metastore.client.builder;
+
+import org.apache.hadoop.hive.metastore.api.GetPartitionsFilterSpec;
+import org.apache.hadoop.hive.metastore.api.GetPartitionsRequest;
+import org.apache.hadoop.hive.metastore.api.GetProjectionsSpec;
+
+import java.util.List;
+
+public class GetPartitionsRequestBuilder {
+    private String catName = null;
+    private String dbName = null;
+    private String tblName = null;
+    private boolean withAuth = true;
+    private String user = null;
+    private List<String> groupNames = null;
+    private GetProjectionsSpec projectionSpec = null;
+    private GetPartitionsFilterSpec filterSpec = null;
+    private List<java.lang.String> processorCapabilities = null;
+    private String processorIdentifier = null;
+    private String validWriteIdList = null;
+
+    public GetPartitionsRequestBuilder(String catName, String dbName, String tblName, boolean withAuth, String user,
+                                       List<String> groupNames, GetProjectionsSpec projectionSpec,
+                                       GetPartitionsFilterSpec filterSpec, List<String> processorCapabilities,
+                                       String processorIdentifier, String validWriteIdList) {
+        this.catName = catName;
+        this.dbName = dbName;
+        this.tblName = tblName;
+        this.withAuth = withAuth;
+        this.user = user;
+        this.groupNames = groupNames;
+        this.projectionSpec = projectionSpec;
+        this.filterSpec = filterSpec;
+        this.processorCapabilities = processorCapabilities;

Review comment:
       These seems harmless to me. I agree they are static, but then they are also public attributes that can be set. Having them in the builder methods is not very different from them being accessed through an object. I have retained them for now. However if you feel strongly about it, I will change it.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] vnhive closed pull request #1694: HIVE-24386 : Add builder methods for GetTablesRequest and GetPartitionsRequest to HiveMetaStoreClient

Posted by GitBox <gi...@apache.org>.
vnhive closed pull request #1694:
URL: https://github.com/apache/hive/pull/1694


   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] vnhive closed pull request #1694: HIVE-24386 : Add builder methods for GetTablesRequest and GetPartitionsRequest to HiveMetaStoreClient

Posted by GitBox <gi...@apache.org>.
vnhive closed pull request #1694:
URL: https://github.com/apache/hive/pull/1694


   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] vnhive commented on a change in pull request #1694: HIVE-24386 : Add builder methods for GetTablesRequest and GetPartitionsRequest to HiveMetaStoreClient

Posted by GitBox <gi...@apache.org>.
vnhive commented on a change in pull request #1694:
URL: https://github.com/apache/hive/pull/1694#discussion_r553750571



##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/TableFields.java
##########
@@ -58,9 +60,9 @@
 
     private static final ImmutableSet<String> allMultiValuedFields = new ImmutableSet.Builder<String>()
             .add("values")
-            .add("sd.cols.name")
-            .add("sd.cols.type")
-            .add("sd.cols.comment")
+            .add("sd.cd.cols.name")

Review comment:
       Sorry about the confusion naveen. I have reverted these back to the StorageDescriptor attributes. Thank you for the comment.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] vnhive commented on a change in pull request #1694: HIVE-24386 : Add builder methods for GetTablesRequest and GetPartitionsRequest to HiveMetaStoreClient

Posted by GitBox <gi...@apache.org>.
vnhive commented on a change in pull request #1694:
URL: https://github.com/apache/hive/pull/1694#discussion_r553751705



##########
File path: standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesGetExists.java
##########
@@ -555,6 +546,74 @@ public void testGetTableObjectsWithProjectionOfMultiValuedFields() throws Except
     }
   }
 
+  @Test
+  public void testGetTableProjectionSpecification() throws Exception {
+    List<String> tableNames = new ArrayList<>();
+    tableNames.add(testTables[0].getTableName());
+    tableNames.add(testTables[1].getTableName());
+
+    GetProjectionsSpec projectSpec = (new GetTableProjectionsSpecBuilder())
+            .includeTableName()
+            .includeDatabase()
+            .includeSdCdColsName()
+            .includeSdCdColsType()
+            .includeSdCdColsComment()
+            .includeSdLocation()
+            .includeSdInputFormat()
+            .includeSdOutputFormat()
+            .includeSdIsCompressed()
+            .includeSdNumBuckets()
+            .includeSdSerDeInfoName()
+            .includeSdSerDeInfoSerializationLib()
+            .includeSdSerDeInfoParameters()
+            .includeSdSerDeInfoDescription()
+            .includeSdSerDeInfoSerializerClass()
+            .includeSdSerDeInfoDeserializerClass()
+            .includeSdSerDeInfoSerdeType()
+            .includeSdBucketCols()
+            .includeSdSortColsCol()
+            .includeSdSortColsOrder()
+            .includeSdparameters()
+            .includeSdSkewedColNames()
+            .includeSdSkewedColValues()
+            .includeSdSkewedColValueLocationMaps()
+            .includeSdIsStoredAsSubDirectories()
+            .includeOwner()
+            .includeOwnerType()
+            .includeCreateTime()
+            .includeLastAccessTime()
+            .includeRetention()
+            .includePartitionKeysName()
+            .includePartitionKeysType()
+            .includePartitionKeysComment()
+            .includeParameters()
+            .includeViewOriginalText()
+            .includeRewriteEnabled()
+            .includeTableType()
+            .build();
+
+    List<Table> tables = client.getTables(null, DEFAULT_DATABASE, tableNames, projectSpec);
+
+    Assert.assertEquals("Found tables", 2, tables.size());
+
+    for(Table table : tables) {
+      Assert.assertTrue(table.isSetDbName());
+      Assert.assertTrue(table.isSetCatName());
+      Assert.assertTrue(table.isSetTableName());
+      Assert.assertTrue(table.isSetLastAccessTime());
+      Assert.assertTrue(table.isSetSd());
+      StorageDescriptor sd = table.getSd();
+      Assert.assertTrue(sd.isSetCols());
+      Assert.assertTrue(sd.isSetSerdeInfo());
+      Assert.assertTrue(sd.isSetBucketCols());
+      Assert.assertTrue(sd.isSetCompressed());
+      Assert.assertTrue(sd.isSetInputFormat());
+      Assert.assertTrue(sd.isSetSerdeInfo());
+      SerDeInfo serDeInfo = sd.getSerdeInfo();
+      Assert.assertTrue(serDeInfo.isSetSerializationLib());
+    }
+  }
+

Review comment:
       Done. I had changed all the test cases to use the builder methods these test negations 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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] vnhive closed pull request #1694: HIVE-24386 : Add builder methods for GetTablesRequest and GetPartitionsRequest to HiveMetaStoreClient

Posted by GitBox <gi...@apache.org>.
vnhive closed pull request #1694:
URL: https://github.com/apache/hive/pull/1694


   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] nrg4878 commented on a change in pull request #1694: HIVE-24386 : Add builder methods for GetTablesRequest and GetPartitionsRequest to HiveMetaStoreClient

Posted by GitBox <gi...@apache.org>.
nrg4878 commented on a change in pull request #1694:
URL: https://github.com/apache/hive/pull/1694#discussion_r552074646



##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/TableFields.java
##########
@@ -58,9 +60,9 @@
 
     private static final ImmutableSet<String> allMultiValuedFields = new ImmutableSet.Builder<String>()
             .add("values")
-            .add("sd.cols.name")
-            .add("sd.cols.type")
-            .add("sd.cols.comment")
+            .add("sd.cd.cols.name")

Review comment:
       @vnhive StorageDescriptor seems to have a variable "cols" but not the actual ColumnDescriptor "cd". How does this work? 




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] vnhive commented on pull request #1694: HIVE-24386 : Add builder methods for GetTablesRequest and GetPartitionsRequest to HiveMetaStoreClient

Posted by GitBox <gi...@apache.org>.
vnhive commented on pull request #1694:
URL: https://github.com/apache/hive/pull/1694#issuecomment-759909797


   > Added some comments. Requesting changes.
   
   I have addressed all your requests. Can you please check if you are happy or you want me to change anything more ?


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org