From 931d5ea47c012d2f58501838f1364b4220f3bd1a Mon Sep 17 00:00:00 2001 From: Jihoon Son Date: Wed, 24 Jun 2015 18:05:50 +0900 Subject: [PATCH 1/5] TAJO-1302 --- .../org/apache/tajo/catalog/DDLBuilder.java | 22 +++++++++++ .../org/apache/tajo/cli/tools/TajoDump.java | 11 ++++-- .../tajo/client/CatalogAdminClient.java | 39 +++++++++---------- .../apache/tajo/cli/tools/TestTajoDump.java | 22 +++++++++++ .../results/TestTajoDump/testDump3.result | 0 5 files changed, 70 insertions(+), 24 deletions(-) create mode 100644 tajo-core/src/test/resources/results/TestTajoDump/testDump3.result diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/DDLBuilder.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/DDLBuilder.java index 65640b9ca7..7a403f983b 100644 --- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/DDLBuilder.java +++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/DDLBuilder.java @@ -69,6 +69,28 @@ public static String buildDDLForBaseTable(TableDesc desc) { return sb.toString(); } + public static String buildDDLForIndex(IndexDesc desc) { + StringBuilder sb = new StringBuilder(); + + sb.append("--\n") + .append("-- Name: ").append(CatalogUtil.denormalizeIdentifier(desc.getName())).append("; Type: INDEX;") + .append(" Index Method: ").append(desc.getIndexMethod()); + sb.append("\n--\n"); + sb.append("CREATE INDEX ").append(CatalogUtil.denormalizeIdentifier(desc.getName())); + sb.append(" on ").append(CatalogUtil.denormalizeIdentifier(desc.getTableName())).append(" ( "); + + for (SortSpec sortSpec : desc.getKeySortSpecs()) { + sb.append(sortSpec.getSortKey().getQualifiedName()).append(" "); + sb.append(sortSpec.isAscending() ? "asc" : "desc").append(" "); + sb.append(sortSpec.isNullFirst() ? "null first" : "null last").append(", "); + } + sb.replace(sb.length()-2, sb.length()-1, " )"); + + sb.append(" location '").append(desc.getIndexPath()).append("';"); + + return sb.toString(); + } + public static void buildSchema(StringBuilder sb, Schema schema) { boolean first = true; diff --git a/tajo-cli/src/main/java/org/apache/tajo/cli/tools/TajoDump.java b/tajo-cli/src/main/java/org/apache/tajo/cli/tools/TajoDump.java index 7fefc5a453..20665e81f7 100644 --- a/tajo-cli/src/main/java/org/apache/tajo/cli/tools/TajoDump.java +++ b/tajo-cli/src/main/java/org/apache/tajo/cli/tools/TajoDump.java @@ -22,10 +22,8 @@ import org.apache.commons.cli.*; import org.apache.tajo.auth.UserRoleInfo; -import org.apache.tajo.catalog.CatalogConstants; -import org.apache.tajo.catalog.CatalogUtil; -import org.apache.tajo.catalog.DDLBuilder; -import org.apache.tajo.catalog.TableDesc; +import org.apache.tajo.catalog.*; +import org.apache.tajo.catalog.proto.CatalogProtos; import org.apache.tajo.catalog.proto.CatalogProtos.StoreType; import org.apache.tajo.client.TajoClient; import org.apache.tajo.client.TajoClientImpl; @@ -186,6 +184,11 @@ private static void dumpDatabase(TajoClient client, String databaseName, PrintWr } else { writer.write(DDLBuilder.buildDDLForBaseTable(table)); } + + List indexeProtos = client.getIndexes(tableName); + for (CatalogProtos.IndexDescProto eachIndexProto : indexeProtos) { + writer.write(DDLBuilder.buildDDLForIndex(new IndexDesc(eachIndexProto))); + } writer.write("\n\n"); } catch (Exception e) { // dump for each table can throw any exception. We need to skip the exception case. diff --git a/tajo-client/src/main/java/org/apache/tajo/client/CatalogAdminClient.java b/tajo-client/src/main/java/org/apache/tajo/client/CatalogAdminClient.java index 86d1622dcf..20cdfee466 100644 --- a/tajo-client/src/main/java/org/apache/tajo/client/CatalogAdminClient.java +++ b/tajo-client/src/main/java/org/apache/tajo/client/CatalogAdminClient.java @@ -20,7 +20,6 @@ import com.google.protobuf.ServiceException; import org.apache.tajo.annotation.Nullable; -import org.apache.tajo.catalog.IndexMeta; import org.apache.tajo.catalog.Schema; import org.apache.tajo.catalog.TableDesc; import org.apache.tajo.catalog.TableMeta; @@ -41,7 +40,7 @@ public interface CatalogAdminClient extends Closeable { * @return True if created successfully. * @throws com.google.protobuf.ServiceException */ - public boolean createDatabase(final String databaseName) throws ServiceException; + boolean createDatabase(final String databaseName) throws ServiceException; /** * Does the database exist? * @@ -49,7 +48,7 @@ public interface CatalogAdminClient extends Closeable { * @return True if so. * @throws ServiceException */ - public boolean existDatabase(final String databaseName) throws ServiceException; + boolean existDatabase(final String databaseName) throws ServiceException; /** * Drop the database * @@ -57,9 +56,9 @@ public interface CatalogAdminClient extends Closeable { * @return True if the database is dropped successfully. * @throws ServiceException */ - public boolean dropDatabase(final String databaseName) throws ServiceException; + boolean dropDatabase(final String databaseName) throws ServiceException; - public List getAllDatabaseNames() throws ServiceException; + List getAllDatabaseNames() throws ServiceException; /** * Does the table exist? @@ -67,7 +66,7 @@ public interface CatalogAdminClient extends Closeable { * @param tableName The table name to be checked. This name is case sensitive. * @return True if so. */ - public boolean existTable(final String tableName) throws ServiceException; + boolean existTable(final String tableName) throws ServiceException; /** * Create an external table. @@ -81,7 +80,7 @@ public interface CatalogAdminClient extends Closeable { * @throws java.sql.SQLException * @throws ServiceException */ - public TableDesc createExternalTable(final String tableName, final Schema schema, final URI path, + TableDesc createExternalTable(final String tableName, final Schema schema, final URI path, final TableMeta meta) throws SQLException, ServiceException; /** @@ -97,7 +96,7 @@ public TableDesc createExternalTable(final String tableName, final Schema schema * @throws SQLException * @throws ServiceException */ - public TableDesc createExternalTable(final String tableName, final Schema schema, final URI path, + TableDesc createExternalTable(final String tableName, final Schema schema, final URI path, final TableMeta meta, final PartitionMethodDesc partitionMethodDesc) throws SQLException, ServiceException; @@ -107,7 +106,7 @@ public TableDesc createExternalTable(final String tableName, final Schema schema * @param tableName The table name to be dropped. This name is case sensitive. * @return True if the table is dropped successfully. */ - public boolean dropTable(final String tableName) throws ServiceException; + boolean dropTable(final String tableName) throws ServiceException; /** * Drop a table. @@ -116,7 +115,7 @@ public TableDesc createExternalTable(final String tableName, final Schema schema * @param purge If purge is true, this call will remove the entry in catalog as well as the table contents. * @return True if the table is dropped successfully. */ - public boolean dropTable(final String tableName, final boolean purge) throws ServiceException; + boolean dropTable(final String tableName, final boolean purge) throws ServiceException; /** * Get a list of table names. @@ -125,7 +124,7 @@ public TableDesc createExternalTable(final String tableName, final Schema schema * If it is null, this method will show all tables * in the current database of this session. */ - public List getTableList(@Nullable final String databaseName) throws ServiceException; + List getTableList(@Nullable final String databaseName) throws ServiceException; /** * Get a table description @@ -133,21 +132,21 @@ public TableDesc createExternalTable(final String tableName, final Schema schema * @param tableName The table name to get. This name is case sensitive. * @return Table description */ - public TableDesc getTableDesc(final String tableName) throws ServiceException; + TableDesc getTableDesc(final String tableName) throws ServiceException; - public List getFunctions(final String functionName) throws ServiceException; + List getFunctions(final String functionName) throws ServiceException; - public IndexDescProto getIndex(final String indexName) throws ServiceException; + IndexDescProto getIndex(final String indexName) throws ServiceException; - public boolean existIndex(final String indexName) throws ServiceException; + boolean existIndex(final String indexName) throws ServiceException; - public List getIndexes(final String tableName) throws ServiceException; + List getIndexes(final String tableName) throws ServiceException; - public boolean hasIndexes(final String tableName) throws ServiceException; + boolean hasIndexes(final String tableName) throws ServiceException; - public IndexDescProto getIndex(final String tableName, final String[] columnNames) throws ServiceException; + IndexDescProto getIndex(final String tableName, final String[] columnNames) throws ServiceException; - public boolean existIndex(final String tableName, final String[] columnName) throws ServiceException; + boolean existIndex(final String tableName, final String[] columnName) throws ServiceException; - public boolean dropIndex(final String indexName) throws ServiceException; + boolean dropIndex(final String indexName) throws ServiceException; } diff --git a/tajo-core/src/test/java/org/apache/tajo/cli/tools/TestTajoDump.java b/tajo-core/src/test/java/org/apache/tajo/cli/tools/TestTajoDump.java index b371be29e8..69b3dd25d5 100644 --- a/tajo-core/src/test/java/org/apache/tajo/cli/tools/TestTajoDump.java +++ b/tajo-core/src/test/java/org/apache/tajo/cli/tools/TestTajoDump.java @@ -64,4 +64,26 @@ public void testDump2() throws Exception { executeString("DROP TABLE \"" + getCurrentDatabase() + "\".\"TableName2\""); } } + + @Test + public void testDump3() throws Exception { + if (!testingCluster.isHiveCatalogStoreRunning()) { + executeString("CREATE TABLE \"" + getCurrentDatabase() + + "\".\"TableName1\" (\"Age\" int, \"FirstName\" TEXT, lastname TEXT)"); + + executeString("CREATE INDEX test_idx on \"" + getCurrentDatabase() + "\".\"TableName1\" ( \"Age\" asc null first, \"FirstName\" desc null last )"); + + UserRoleInfo userInfo = UserRoleInfo.getCurrentUser(); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + PrintWriter printWriter = new PrintWriter(bos); + TajoDump.dump(client, userInfo, getCurrentDatabase(), false, false, false, printWriter); + printWriter.flush(); + printWriter.close(); + assertStrings(new String(bos.toByteArray())); + bos.close(); + + + executeString("DROP TABLE \"" + getCurrentDatabase() + "\".\"TableName1\""); + } + } } diff --git a/tajo-core/src/test/resources/results/TestTajoDump/testDump3.result b/tajo-core/src/test/resources/results/TestTajoDump/testDump3.result new file mode 100644 index 0000000000..e69de29bb2 From 179c79e6cb2b97f418310a1b2b2a08a0af345e7b Mon Sep 17 00:00:00 2001 From: Jihoon Son Date: Fri, 26 Jun 2015 13:53:50 +0900 Subject: [PATCH 2/5] TAJO-1302 --- .../apache/tajo/catalog/store/MemStore.java | 25 ------------- .../apache/tajo/master/exec/DDLExecutor.java | 2 +- .../org/apache/tajo/querymaster/Query.java | 2 +- .../apache/tajo/cli/tools/TestTajoDump.java | 35 +++++++++++++++++-- .../results/TestTajoDump/testDump3.result | 19 ++++++++++ 5 files changed, 53 insertions(+), 30 deletions(-) diff --git a/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/MemStore.java b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/MemStore.java index f2fc2cb208..672bf4d48c 100644 --- a/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/MemStore.java +++ b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/MemStore.java @@ -724,31 +724,6 @@ public boolean existIndexesByTable(String databaseName, String tableName) throws return false; } -// public List getAllIndexes() throws CatalogException { -// List indexList = new ArrayList(); -// Set databases = indexes.keySet(); -// -// for (String databaseName: databases) { -// Map indexMap = indexes.get(databaseName); -// -// for (Map.Entry entry: indexMap.entrySet()) { -// IndexDescProto indexDesc = entry.getValue(); -// IndexProto.Builder builder = IndexProto.newBuilder(); -// -// builder.setColumnName(indexDesc.getColumn().getName()); -// builder.setDataType(indexDesc.getColumn().getDataType().getType().toString()); -// builder.setIndexName(entry.getKey()); -// builder.setIndexType(indexDesc.getIndexMethod().toString()); -// builder.setIsAscending(indexDesc.hasIsAscending() && indexDesc.getIsAscending()); -// builder.setIsClustered(indexDesc.hasIsClustered() && indexDesc.getIsClustered()); -// builder.setIsUnique(indexDesc.hasIsUnique() && indexDesc.getIsUnique()); -// -// indexList.add(builder.build()); -// } -// } -// return false; -// } - @Override public List getAllIndexes() throws CatalogException { List indexDescProtos = TUtil.newList(); diff --git a/tajo-core/src/main/java/org/apache/tajo/master/exec/DDLExecutor.java b/tajo-core/src/main/java/org/apache/tajo/master/exec/DDLExecutor.java index b28aa34a82..1b372f7372 100644 --- a/tajo-core/src/main/java/org/apache/tajo/master/exec/DDLExecutor.java +++ b/tajo-core/src/main/java/org/apache/tajo/master/exec/DDLExecutor.java @@ -137,7 +137,7 @@ public void createIndex(final QueryContext queryContext, final CreateIndexNode c throw new InternalError("Cannot find the table of the relation"); } - IndexDesc indexDesc = new IndexDesc(databaseName, scanNode.getTableName(), + IndexDesc indexDesc = new IndexDesc(databaseName, CatalogUtil.extractSimpleName(scanNode.getTableName()), simpleIndexName, createIndexNode.getIndexPath(), createIndexNode.getKeySortSpecs(), createIndexNode.getIndexMethod(), createIndexNode.isUnique(), false, scanNode.getLogicalSchema()); diff --git a/tajo-core/src/main/java/org/apache/tajo/querymaster/Query.java b/tajo-core/src/main/java/org/apache/tajo/querymaster/Query.java index 23fa497d14..39df9c84e7 100644 --- a/tajo-core/src/main/java/org/apache/tajo/querymaster/Query.java +++ b/tajo-core/src/main/java/org/apache/tajo/querymaster/Query.java @@ -550,7 +550,7 @@ public void execute(QueryMaster.QueryMasterContext context, QueryContext queryCo if (scanNode == null) { throw new IOException("Cannot find the table of the relation"); } - IndexDesc indexDesc = new IndexDesc(databaseName, scanNode.getTableName(), + IndexDesc indexDesc = new IndexDesc(databaseName, CatalogUtil.extractSimpleName(scanNode.getTableName()), simpleIndexName, createIndexNode.getIndexPath(), createIndexNode.getKeySortSpecs(), createIndexNode.getIndexMethod(), createIndexNode.isUnique(), false, scanNode.getLogicalSchema()); diff --git a/tajo-core/src/test/java/org/apache/tajo/cli/tools/TestTajoDump.java b/tajo-core/src/test/java/org/apache/tajo/cli/tools/TestTajoDump.java index 69b3dd25d5..5972497aaf 100644 --- a/tajo-core/src/test/java/org/apache/tajo/cli/tools/TestTajoDump.java +++ b/tajo-core/src/test/java/org/apache/tajo/cli/tools/TestTajoDump.java @@ -18,13 +18,22 @@ package org.apache.tajo.cli.tools; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; import org.apache.tajo.QueryTestCaseBase; import org.apache.tajo.auth.UserRoleInfo; +import org.apache.tajo.storage.StorageUtil; +import org.apache.tajo.storage.TablespaceManager; +import org.apache.tajo.util.FileUtil; import org.junit.Test; import java.io.ByteArrayOutputStream; +import java.io.File; import java.io.PrintWriter; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + public class TestTajoDump extends QueryTestCaseBase { @Test @@ -71,7 +80,8 @@ public void testDump3() throws Exception { executeString("CREATE TABLE \"" + getCurrentDatabase() + "\".\"TableName1\" (\"Age\" int, \"FirstName\" TEXT, lastname TEXT)"); - executeString("CREATE INDEX test_idx on \"" + getCurrentDatabase() + "\".\"TableName1\" ( \"Age\" asc null first, \"FirstName\" desc null last )"); + executeString("CREATE INDEX test_idx on \"" + getCurrentDatabase() + + "\".\"TableName1\" ( \"Age\" asc null first, \"FirstName\" desc null last )"); UserRoleInfo userInfo = UserRoleInfo.getCurrentUser(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); @@ -79,11 +89,30 @@ public void testDump3() throws Exception { TajoDump.dump(client, userInfo, getCurrentDatabase(), false, false, false, printWriter); printWriter.flush(); printWriter.close(); - assertStrings(new String(bos.toByteArray())); + assertOutputResult("testDump3.result", new String(bos.toByteArray()), new String[]{"${index.path}"}, + new String[]{TablespaceManager.getDefault().getTableUri(getCurrentDatabase(), "test_idx").toString()}); bos.close(); - + executeString("DROP INDEX test_idx"); executeString("DROP TABLE \"" + getCurrentDatabase() + "\".\"TableName1\""); } } + + private void assertOutputResult(String expectedResultFile, String actual, String[] paramKeys, String[] paramValues) + throws Exception { + FileSystem fs = currentResultPath.getFileSystem(testBase.getTestingCluster().getConfiguration()); + Path resultFile = StorageUtil.concatPath(currentResultPath, expectedResultFile); + assertTrue(resultFile.toString() + " existence check", fs.exists(resultFile)); + + String expectedResult = FileUtil.readTextFile(new File(resultFile.toUri())); + + if (paramKeys != null) { + for (int i = 0; i < paramKeys.length; i++) { + if (i < paramValues.length) { + expectedResult = expectedResult.replace(paramKeys[i], paramValues[i]); + } + } + } + assertEquals(expectedResult.trim(), actual.trim()); + } } diff --git a/tajo-core/src/test/resources/results/TestTajoDump/testDump3.result b/tajo-core/src/test/resources/results/TestTajoDump/testDump3.result index e69de29bb2..5278ef0ef0 100644 --- a/tajo-core/src/test/resources/results/TestTajoDump/testDump3.result +++ b/tajo-core/src/test/resources/results/TestTajoDump/testDump3.result @@ -0,0 +1,19 @@ +-- +-- Tajo database dump +-- + + +-- +-- Database name: "TestTajoDump" +-- + +CREATE DATABASE IF NOT EXISTS "TestTajoDump"; + +-- +-- Name: "TestTajoDump"."TableName1"; Type: TABLE; Storage: CSV +-- +CREATE TABLE "TestTajoDump"."TableName1" ("Age" INT4, "FirstName" TEXT, lastname TEXT) USING CSV WITH ('text.delimiter'='|');-- +-- Name: test_idx; Type: INDEX; Index Method: TWO_LEVEL_BIN_TREE +-- +CREATE INDEX test_idx on "TableName1" ( TestTajoDump.TableName1.Age asc null first, TestTajoDump.TableName1.FirstName desc null last ) location '${index.path}'; + From 39cc9e320d3cc445170937fef4b4e114b755d6f9 Mon Sep 17 00:00:00 2001 From: Jihoon Son Date: Tue, 30 Jun 2015 13:44:44 +0900 Subject: [PATCH 3/5] Trigger travis --- CHANGES | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES b/CHANGES index 746ed9259c..080b7eb07f 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,6 @@ Tajo Change Log + Release 0.11.0 - unreleased NEW FEATURES From b37b7c3f1efe2179603e4d0f49fd0ebfbb8fa520 Mon Sep 17 00:00:00 2001 From: Jihoon Son Date: Tue, 30 Jun 2015 16:51:01 +0900 Subject: [PATCH 4/5] Trigger travis --- CHANGES | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGES b/CHANGES index 080b7eb07f..746ed9259c 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,5 @@ Tajo Change Log - Release 0.11.0 - unreleased NEW FEATURES From 4a0d9b2e5ed2cc8002a48767f6586888e0c0ce8c Mon Sep 17 00:00:00 2001 From: Jihoon Son Date: Wed, 22 Jul 2015 22:51:35 +0900 Subject: [PATCH 5/5] Fix test failure --- .../apache/tajo/cli/tools/TestTajoDump.java | 70 ++++++++++--------- .../results/TestTajoDump/testDump1.result | 3 +- .../results/TestTajoDump/testDump2.result | 3 +- .../results/TestTajoDump/testDump3.result | 2 +- 4 files changed, 41 insertions(+), 37 deletions(-) diff --git a/tajo-core/src/test/java/org/apache/tajo/cli/tools/TestTajoDump.java b/tajo-core/src/test/java/org/apache/tajo/cli/tools/TestTajoDump.java index 5972497aaf..aa8070e71b 100644 --- a/tajo-core/src/test/java/org/apache/tajo/cli/tools/TestTajoDump.java +++ b/tajo-core/src/test/java/org/apache/tajo/cli/tools/TestTajoDump.java @@ -42,16 +42,18 @@ public void testDump1() throws Exception { executeString("CREATE TABLE \"" + getCurrentDatabase() + "\".\"TableName1\" (\"Age\" int, \"FirstName\" TEXT, lastname TEXT)"); - UserRoleInfo userInfo = UserRoleInfo.getCurrentUser(); - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - PrintWriter printWriter = new PrintWriter(bos); - TajoDump.dump(client, userInfo, getCurrentDatabase(), false, false, false, printWriter); - printWriter.flush(); - printWriter.close(); - assertStrings(new String(bos.toByteArray())); - bos.close(); - - executeString("DROP TABLE \"" + getCurrentDatabase() + "\".\"TableName1\""); + try { + UserRoleInfo userInfo = UserRoleInfo.getCurrentUser(); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + PrintWriter printWriter = new PrintWriter(bos); + TajoDump.dump(client, userInfo, getCurrentDatabase(), false, false, false, printWriter); + printWriter.flush(); + printWriter.close(); + assertStrings(new String(bos.toByteArray())); + bos.close(); + } finally { + executeString("DROP TABLE \"" + getCurrentDatabase() + "\".\"TableName1\""); + } } } @@ -61,16 +63,18 @@ public void testDump2() throws Exception { executeString("CREATE TABLE \"" + getCurrentDatabase() + "\".\"TableName2\" (\"Age\" int, \"Name\" Record (\"FirstName\" TEXT, lastname TEXT))"); - UserRoleInfo userInfo = UserRoleInfo.getCurrentUser(); - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - PrintWriter printWriter = new PrintWriter(bos); - TajoDump.dump(client, userInfo, getCurrentDatabase(), false, false, false, printWriter); - printWriter.flush(); - printWriter.close(); - assertStrings(new String(bos.toByteArray())); - bos.close(); - - executeString("DROP TABLE \"" + getCurrentDatabase() + "\".\"TableName2\""); + try { + UserRoleInfo userInfo = UserRoleInfo.getCurrentUser(); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + PrintWriter printWriter = new PrintWriter(bos); + TajoDump.dump(client, userInfo, getCurrentDatabase(), false, false, false, printWriter); + printWriter.flush(); + printWriter.close(); + assertStrings(new String(bos.toByteArray())); + bos.close(); + } finally { + executeString("DROP TABLE \"" + getCurrentDatabase() + "\".\"TableName2\""); + } } } @@ -83,18 +87,20 @@ public void testDump3() throws Exception { executeString("CREATE INDEX test_idx on \"" + getCurrentDatabase() + "\".\"TableName1\" ( \"Age\" asc null first, \"FirstName\" desc null last )"); - UserRoleInfo userInfo = UserRoleInfo.getCurrentUser(); - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - PrintWriter printWriter = new PrintWriter(bos); - TajoDump.dump(client, userInfo, getCurrentDatabase(), false, false, false, printWriter); - printWriter.flush(); - printWriter.close(); - assertOutputResult("testDump3.result", new String(bos.toByteArray()), new String[]{"${index.path}"}, - new String[]{TablespaceManager.getDefault().getTableUri(getCurrentDatabase(), "test_idx").toString()}); - bos.close(); - - executeString("DROP INDEX test_idx"); - executeString("DROP TABLE \"" + getCurrentDatabase() + "\".\"TableName1\""); + try { + UserRoleInfo userInfo = UserRoleInfo.getCurrentUser(); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + PrintWriter printWriter = new PrintWriter(bos); + TajoDump.dump(client, userInfo, getCurrentDatabase(), false, false, false, printWriter); + printWriter.flush(); + printWriter.close(); + assertOutputResult("testDump3.result", new String(bos.toByteArray()), new String[]{"${index.path}"}, + new String[]{TablespaceManager.getDefault().getTableUri(getCurrentDatabase(), "test_idx").toString()}); + bos.close(); + } finally { + executeString("DROP INDEX test_idx"); + executeString("DROP TABLE \"" + getCurrentDatabase() + "\".\"TableName1\""); + } } } diff --git a/tajo-core/src/test/resources/results/TestTajoDump/testDump1.result b/tajo-core/src/test/resources/results/TestTajoDump/testDump1.result index 8accecede1..613093b741 100644 --- a/tajo-core/src/test/resources/results/TestTajoDump/testDump1.result +++ b/tajo-core/src/test/resources/results/TestTajoDump/testDump1.result @@ -12,5 +12,4 @@ CREATE DATABASE IF NOT EXISTS "TestTajoDump"; -- -- Name: "TestTajoDump"."TableName1"; Type: TABLE; Storage: TEXT -- -CREATE TABLE "TestTajoDump"."TableName1" ("Age" INT4, "FirstName" TEXT, lastname TEXT) USING TEXT WITH ('text.delimiter'='|'); - +CREATE TABLE "TestTajoDump"."TableName1" ("Age" INT4, "FirstName" TEXT, lastname TEXT) USING TEXT WITH ('text.delimiter'='|'); \ No newline at end of file diff --git a/tajo-core/src/test/resources/results/TestTajoDump/testDump2.result b/tajo-core/src/test/resources/results/TestTajoDump/testDump2.result index 787562e6c8..4c962337fa 100644 --- a/tajo-core/src/test/resources/results/TestTajoDump/testDump2.result +++ b/tajo-core/src/test/resources/results/TestTajoDump/testDump2.result @@ -12,5 +12,4 @@ CREATE DATABASE IF NOT EXISTS "TestTajoDump"; -- -- Name: "TestTajoDump"."TableName2"; Type: TABLE; Storage: TEXT -- -CREATE TABLE "TestTajoDump"."TableName2" ("Age" INT4, "Name" RECORD ("FirstName" TEXT, lastname TEXT)) USING TEXT WITH ('text.delimiter'='|'); - +CREATE TABLE "TestTajoDump"."TableName2" ("Age" INT4, "Name" RECORD ("FirstName" TEXT, lastname TEXT)) USING TEXT WITH ('text.delimiter'='|'); \ No newline at end of file diff --git a/tajo-core/src/test/resources/results/TestTajoDump/testDump3.result b/tajo-core/src/test/resources/results/TestTajoDump/testDump3.result index 697c0d7d46..72a42c7f5d 100644 --- a/tajo-core/src/test/resources/results/TestTajoDump/testDump3.result +++ b/tajo-core/src/test/resources/results/TestTajoDump/testDump3.result @@ -15,4 +15,4 @@ CREATE DATABASE IF NOT EXISTS "TestTajoDump"; CREATE TABLE "TestTajoDump"."TableName1" ("Age" INT4, "FirstName" TEXT, lastname TEXT) USING TEXT WITH ('text.delimiter'='|');-- -- Name: test_idx; Type: INDEX; Index Method: TWO_LEVEL_BIN_TREE -- -CREATE INDEX test_idx on "TableName1" ( TestTajoDump.TableName1.Age asc null first, TestTajoDump.TableName1.FirstName desc null last ) location 'hdfs://localhost:63592/tajo/warehouse/TestTajoDump/test_idx'; \ No newline at end of file +CREATE INDEX test_idx on "TableName1" ( TestTajoDump.TableName1.Age asc null first, TestTajoDump.TableName1.FirstName desc null last ) location '${index.path}'; \ No newline at end of file