Github user jihoonson commented on a diff in the pull request:

    https://github.com/apache/tajo/pull/772#discussion_r39943983
  
    --- Diff: 
tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/CatalogServer.java
 ---
    @@ -1043,6 +1043,90 @@ public GetTablePartitionsResponse 
getAllPartitions(RpcController controller, Nul
         }
     
         @Override
    +    public GetPartitionsResponse getPartitionsByAlgebra(RpcController 
controller,
    +      PartitionsByAlgebraProto request) throws ServiceException {
    +      String dbName = request.getDatabaseName();
    +      String tbName = request.getTableName();
    +
    +      try {
    +        // linked meta data do not support partition.
    +        // So, the request that wants to get partitions in this db will be 
failed.
    +        if (linkedMetadataManager.existsDatabase(dbName)) {
    +          return 
GetPartitionsResponse.newBuilder().setState(errUndefinedPartitionMethod(tbName)).build();
    +        }
    +      } catch (Throwable t) {
    +        printStackTraceIfError(LOG, t);
    +        return GetPartitionsResponse.newBuilder()
    +          .setState(returnError(t))
    +          .build();
    +      }
    +
    +      if (metaDictionary.isSystemDatabase(dbName)) {
    +        return 
GetPartitionsResponse.newBuilder().setState(errUndefinedPartitionMethod(tbName)).build();
    +      }
    +
    +      rlock.lock();
    +      try {
    +        GetPartitionsResponse.Builder builder = 
GetPartitionsResponse.newBuilder();
    +        List<PartitionDescProto> partitions = 
store.getPartitionsByAlgebra(request);
    +        builder.addAllPartition(partitions);
    +        builder.setState(OK);
    +        return builder.build();
    +      } catch (Throwable t) {
    +        printStackTraceIfError(LOG, t);
    +
    +        return GetPartitionsResponse.newBuilder()
    +          .setState(returnError(t))
    +          .build();
    +
    +      } finally {
    +        rlock.unlock();
    +      }
    +    }
    +
    +    @Override
    +    public GetPartitionsResponse getPartitionsByFilter(RpcController 
controller,
    +                                                 PartitionsByFilterProto 
request) throws ServiceException {
    +      String dbName = request.getDatabaseName();
    +      String tbName = request.getTableName();
    +
    +      try {
    +        // linked meta data do not support partition.
    +        // So, the request that wants to get partitions in this db will be 
failed.
    +        if (linkedMetadataManager.existsDatabase(dbName)) {
    --- End diff --
    
    These codes can be much simplified. Please refer to the ```existsTable()``` 
method of this class.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to