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

    https://github.com/apache/tajo/pull/624#discussion_r38731587
  
    --- Diff: 
tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/CatalogServer.java
 ---
    @@ -1027,6 +1081,136 @@ 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 {
    +        boolean contain;
    +
    +        contain = store.existDatabase(dbName);
    +        if (contain) {
    +          contain = store.existTable(dbName, tbName);
    +          if (contain) {
    +
    +            if (store.existPartitionMethod(dbName, tbName)) {
    +              GetPartitionsResponse.Builder builder = 
GetPartitionsResponse.newBuilder();
    +              List<PartitionDescProto> partitions = 
store.getPartitionsByAlgebra(request);
    +              builder.addAllPartition(partitions);
    +              builder.setState(OK);
    +              return builder.build();
    +            } else {
    +              return GetPartitionsResponse.newBuilder()
    +                .setState(errUndefinedPartitionMethod(tbName))
    +                .build();
    +            }
    +          } else {
    +            return GetPartitionsResponse.newBuilder()
    +              .setState(errUndefinedTable(tbName))
    +              .build();
    +          }
    +        } else {
    +          return GetPartitionsResponse.newBuilder()
    +            .setState(errUndefinedDatabase(dbName))
    +            .build();
    +        }
    +      } catch (Throwable t) {
    +        printStackTraceIfError(LOG, t);
    +
    +        return GetPartitionsResponse.newBuilder()
    +            .setState(returnError(t))
    +            .build();
    +
    +      } finally {
    +        rlock.unlock();
    +      }
    +    }
    +
    +    @Override
    +    public GetPartitionsResponse getPartitionsByDirectSql(RpcController 
controller,
    +                                                 
PartitionsByDirectSqlProto 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 {
    +        boolean contain;
    +
    +        contain = store.existDatabase(dbName);
    +        if (contain) {
    --- End diff --
    
    These tests can be improved like other methods. Please refer to 
existsDatabase() method.


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