Repository: tajo
Updated Branches:
  refs/heads/master 773c3eb94 -> fec596185


TAJO-1657: Tajo Rest API /database/{database-name]/tables should return table 
names only without invalid external table info.

Closes #619

Signed-off-by: Jihoon Son <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/tajo/repo
Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/fec59618
Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/fec59618
Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/fec59618

Branch: refs/heads/master
Commit: fec596185e5471c73f77af8dbe7cc8f7a1ab1a96
Parents: 773c3eb
Author: DaeMyung Kang <[email protected]>
Authored: Wed Jul 1 13:57:48 2015 +0900
Committer: Jihoon Son <[email protected]>
Committed: Wed Jul 1 13:57:48 2015 +0900

----------------------------------------------------------------------
 CHANGES                                         |  4 ++++
 .../tajo/ws/rs/resources/TablesResource.java    | 19 +++++++----------
 .../ws/rs/resources/TestTablesResource.java     | 22 +++++++++++---------
 3 files changed, 23 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/fec59618/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 90ef54a..63499b5 100644
--- a/CHANGES
+++ b/CHANGES
@@ -166,6 +166,10 @@ Release 0.11.0 - unreleased
 
   BUG FIXES
 
+    TAJO-1657: Tajo Rest API /database/{database-name]/tables should return 
table 
+    names only without invalid external table info. 
+    (Contributed by  DaeMyung Kang, Committed by jihoon)
+
     TAJO-1644: When inserting empty data into a partitioned table,
     existing data would be removed. (jaehwa)
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/fec59618/tajo-core/src/main/java/org/apache/tajo/ws/rs/resources/TablesResource.java
----------------------------------------------------------------------
diff --git 
a/tajo-core/src/main/java/org/apache/tajo/ws/rs/resources/TablesResource.java 
b/tajo-core/src/main/java/org/apache/tajo/ws/rs/resources/TablesResource.java
index 3e638d6..f85d25f 100644
--- 
a/tajo-core/src/main/java/org/apache/tajo/ws/rs/resources/TablesResource.java
+++ 
b/tajo-core/src/main/java/org/apache/tajo/ws/rs/resources/TablesResource.java
@@ -19,9 +19,7 @@
 package org.apache.tajo.ws.rs.resources;
 
 import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
+import java.util.*;
 
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
@@ -64,7 +62,8 @@ public class TablesResource {
   String databaseName;
   
   JerseyResourceDelegateContext context;
-  
+
+  private static final String tablesKeyName = "tables";
   private static final String databaseNameKeyName = "databaseName";
   private static final String tableNameKeyName = "tableName";
   private static final String tableDescKeyName = "tableDesc";
@@ -206,15 +205,11 @@ public class TablesResource {
       if (!catalogService.existDatabase(databaseName)) {
         return Response.status(Status.NOT_FOUND).build();
       }
-      
+
       Collection<String> tableNames = 
catalogService.getAllTableNames(databaseName);
-      List<TableDesc> tables = new ArrayList<TableDesc>();
-      
-      for (String tableName: tableNames) {
-        tables.add(new TableDesc(tableName, null, null, null));
-      }
-      
-      return Response.ok(tables).build();
+      Map<String, Collection<String>> tableNamesMap = new HashMap<String, 
Collection<String>>();
+      tableNamesMap.put(tablesKeyName, tableNames);
+      return Response.ok(tableNamesMap).build();
     }
     
   }

http://git-wip-us.apache.org/repos/asf/tajo/blob/fec59618/tajo-core/src/test/java/org/apache/tajo/ws/rs/resources/TestTablesResource.java
----------------------------------------------------------------------
diff --git 
a/tajo-core/src/test/java/org/apache/tajo/ws/rs/resources/TestTablesResource.java
 
b/tajo-core/src/test/java/org/apache/tajo/ws/rs/resources/TestTablesResource.java
index 8b1ca14..3f2bd50 100644
--- 
a/tajo-core/src/test/java/org/apache/tajo/ws/rs/resources/TestTablesResource.java
+++ 
b/tajo-core/src/test/java/org/apache/tajo/ws/rs/resources/TestTablesResource.java
@@ -17,7 +17,6 @@
  */
 package org.apache.tajo.ws.rs.resources;
 
-import com.google.gson.internal.StringMap;
 import org.apache.tajo.QueryTestCaseBase;
 import org.apache.tajo.catalog.*;
 import org.apache.tajo.common.TajoDataTypes;
@@ -39,7 +38,9 @@ import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.Status;
 import java.net.URI;
+import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 
 import static org.junit.Assert.*;
 
@@ -103,16 +104,17 @@ public class TestTablesResource extends QueryTestCaseBase 
{
     
     assertNotNull(response);
     assertEquals(Status.CREATED.getStatusCode(), response.getStatus());
-    
-    List<StringMap<String>> tables = restClient.target(tablesURI)
-        .request().get(new GenericType<List<StringMap<String>>>(List.class));
-    
-    assertNotNull(tables);
-    assertTrue(!tables.isEmpty());
-    
+
+    Map<String, Collection<String>> tables = restClient.target(tablesURI)
+        .request().get(new GenericType<Map<String, 
Collection<String>>>(Map.class));
+
+    List<String> tableNames = (List<String>)tables.get("tables");
+    assertNotNull(tableNames);
+    assertTrue(!tableNames.isEmpty());
+
     boolean tableFound = false;
-    for (StringMap<String> table: tables) {
-      if 
(tableName.equals(CatalogUtil.extractSimpleName(table.get("tableName")))) {
+    for (String table: tableNames) {
+      if (tableName.equals(CatalogUtil.extractSimpleName(table))) {
         tableFound = true;
         break;
       }

Reply via email to