aboutsummaryrefslogtreecommitdiff
path: root/exec/java-exec/src/test/java/org/apache/drill/exec/sql
diff options
context:
space:
mode:
authorTimothy Farkas <timothyfarkas@apache.org>2017-11-09 14:25:53 -0800
committerPaul Rogers <progers@maprtech.com>2017-11-14 17:26:41 -0800
commitacc5ed927e1fa4011ac1c3724d15197484b9f45b (patch)
tree345a96f3c5f038a464baa2c846ae2179712efa0a /exec/java-exec/src/test/java/org/apache/drill/exec/sql
parentc56de2f13a36d673f0c5836d44817137e64b91e4 (diff)
DRILL-5783, DRILL-5841, DRILL-5894: Rationalize test temp directories
This change includes: DRILL-5783: - A unit test is created for the priority queue in the TopN operator. - The code generation classes passed around a completely unused function registry reference in some places so it is removed. - The priority queue had unused parameters for some of its methods so it is removed. DRILL-5841: - Created standardized temp directory classes DirTestWatcher, SubDirTestWatcher, and BaseDirTestWatcher. And updated all unit tests to use them. DRILL-5894: - Removed the dfs_test storage plugin for tests and replaced it with the already existing dfs storage plugin. Misc: - General code cleanup. - Removed unnecessary use of String.format in the tests. This closes #984
Diffstat (limited to 'exec/java-exec/src/test/java/org/apache/drill/exec/sql')
-rw-r--r--exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestBaseViewSupport.java16
-rw-r--r--exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestCTAS.java207
-rw-r--r--exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestCTTAS.java82
-rw-r--r--exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestInfoSchema.java66
-rw-r--r--exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestSimpleCastFunctions.java2
-rw-r--r--exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestViewSupport.java173
-rw-r--r--exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestWithClause.java2
7 files changed, 251 insertions, 297 deletions
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestBaseViewSupport.java b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestBaseViewSupport.java
index 5bf55af64..c85cbb66a 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestBaseViewSupport.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestBaseViewSupport.java
@@ -18,8 +18,8 @@
package org.apache.drill.exec.sql;
import com.google.common.base.Strings;
-import org.apache.drill.BaseTestQuery;
-import org.apache.drill.TestBuilder;
+import org.apache.drill.test.BaseTestQuery;
+import org.apache.drill.test.TestBuilder;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
@@ -34,14 +34,14 @@ public class TestBaseViewSupport extends BaseTestQuery {
/**
* Create view with given parameters.
*
- * Current default schema "dfs_test"
+ * Current default schema "dfs"
*
* CREATE VIEW tmp.viewName(f1, f2) AS SELECT * FROM cp.`region.json`
*
* For the above CREATE VIEW query, function parameters are:
* viewSchema = "tmp"
* viewName = "viewName"
- * finalSchema = "dfs_test.tmp"
+ * finalSchema = "dfs.tmp"
* viewFields = "(f1, f2)"
* viewDef = "SELECT * FROM cp.`region.json`"
*
@@ -76,13 +76,13 @@ public class TestBaseViewSupport extends BaseTestQuery {
/**
* Drop view with given parameters.
*
- * Current schema "dfs_test"
+ * Current schema "dfs"
* DROP VIEW tmp.viewName
*
* For the above DROP VIEW query, function parameters values are:
* viewSchema = "tmp"
* "viewName" = "viewName"
- * "finalSchema" = "dfs_test.tmp"
+ * "finalSchema" = "dfs.tmp"
*
* @param viewSchema
* @param viewName
@@ -107,13 +107,13 @@ public class TestBaseViewSupport extends BaseTestQuery {
/**
* Drop view if exists with given parameters.
*
- * Current schema "dfs_test"
+ * Current schema "dfs"
* DROP VIEW IF EXISTS tmp.viewName
*
* For the above DROP VIEW IF EXISTS query, function parameters values are:
* viewSchema = "tmp"
* "viewName" = "viewName"
- * "finalSchema" = "dfs_test.tmp"
+ * "finalSchema" = "dfs.tmp"
* "ifViewExists" = null
*
* @param viewSchema
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestCTAS.java b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestCTAS.java
index 2e3b7963f..764cef4fa 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestCTAS.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestCTAS.java
@@ -18,8 +18,7 @@
package org.apache.drill.exec.sql;
import com.google.common.collect.Maps;
-import org.apache.commons.io.FileUtils;
-import org.apache.drill.BaseTestQuery;
+import org.apache.drill.test.BaseTestQuery;
import org.apache.drill.categories.SqlTest;
import org.apache.drill.categories.UnlikelyTest;
import org.apache.drill.exec.ExecConstants;
@@ -31,7 +30,6 @@ import org.apache.hadoop.fs.Path;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import java.io.File;
import java.util.Map;
import static org.junit.Assert.assertEquals;
@@ -41,7 +39,7 @@ public class TestCTAS extends BaseTestQuery {
@Test // DRILL-2589
@Category(UnlikelyTest.class)
public void withDuplicateColumnsInDef1() throws Exception {
- ctasErrorTestHelper("CREATE TABLE %s.%s AS SELECT region_id, region_id FROM cp.`region.json`",
+ ctasErrorTestHelper("CREATE TABLE dfs.tmp.%s AS SELECT region_id, region_id FROM cp.`region.json`",
String.format("Duplicate column name [%s]", "region_id")
);
}
@@ -49,7 +47,7 @@ public class TestCTAS extends BaseTestQuery {
@Test // DRILL-2589
@Category(UnlikelyTest.class)
public void withDuplicateColumnsInDef2() throws Exception {
- ctasErrorTestHelper("CREATE TABLE %s.%s AS SELECT region_id, sales_city, sales_city FROM cp.`region.json`",
+ ctasErrorTestHelper("CREATE TABLE dfs.tmp.%s AS SELECT region_id, sales_city, sales_city FROM cp.`region.json`",
String.format("Duplicate column name [%s]", "sales_city")
);
}
@@ -58,7 +56,7 @@ public class TestCTAS extends BaseTestQuery {
@Category(UnlikelyTest.class)
public void withDuplicateColumnsInDef3() throws Exception {
ctasErrorTestHelper(
- "CREATE TABLE %s.%s(regionid, regionid) " +
+ "CREATE TABLE dfs.tmp.%s(regionid, regionid) " +
"AS SELECT region_id, sales_city FROM cp.`region.json`",
String.format("Duplicate column name [%s]", "regionid")
);
@@ -68,7 +66,7 @@ public class TestCTAS extends BaseTestQuery {
@Category(UnlikelyTest.class)
public void withDuplicateColumnsInDef4() throws Exception {
ctasErrorTestHelper(
- "CREATE TABLE %s.%s(regionid, salescity, salescity) " +
+ "CREATE TABLE dfs.tmp.%s(regionid, salescity, salescity) " +
"AS SELECT region_id, sales_city, sales_city FROM cp.`region.json`",
String.format("Duplicate column name [%s]", "salescity")
);
@@ -78,7 +76,7 @@ public class TestCTAS extends BaseTestQuery {
@Category(UnlikelyTest.class)
public void withDuplicateColumnsInDef5() throws Exception {
ctasErrorTestHelper(
- "CREATE TABLE %s.%s(regionid, salescity, SalesCity) " +
+ "CREATE TABLE dfs.tmp.%s(regionid, salescity, SalesCity) " +
"AS SELECT region_id, sales_city, sales_city FROM cp.`region.json`",
String.format("Duplicate column name [%s]", "SalesCity")
);
@@ -87,7 +85,7 @@ public class TestCTAS extends BaseTestQuery {
@Test // DRILL-2589
public void whenInEqualColumnCountInTableDefVsInTableQuery() throws Exception {
ctasErrorTestHelper(
- "CREATE TABLE %s.%s(regionid, salescity) " +
+ "CREATE TABLE dfs.tmp.%s(regionid, salescity) " +
"AS SELECT region_id, sales_city, sales_region FROM cp.`region.json`",
"table's field list and the table's query field list have different counts."
);
@@ -96,7 +94,7 @@ public class TestCTAS extends BaseTestQuery {
@Test // DRILL-2589
public void whenTableQueryColumnHasStarAndTableFiledListIsSpecified() throws Exception {
ctasErrorTestHelper(
- "CREATE TABLE %s.%s(regionid, salescity) " +
+ "CREATE TABLE dfs.tmp.%s(regionid, salescity) " +
"AS SELECT region_id, * FROM cp.`region.json`",
"table's query field list has a '*', which is invalid when table's field list is specified."
);
@@ -106,18 +104,10 @@ public class TestCTAS extends BaseTestQuery {
@Category(UnlikelyTest.class)
public void createTableWhenATableWithSameNameAlreadyExists() throws Exception{
final String newTblName = "createTableWhenTableAlreadyExists";
+ final String ctasQuery = String.format("CREATE TABLE dfs.tmp.%s AS SELECT * from cp.`region.json`", newTblName);
- try {
- final String ctasQuery =
- String.format("CREATE TABLE %s.%s AS SELECT * from cp.`region.json`", TEMP_SCHEMA, newTblName);
-
- test(ctasQuery);
-
- errorMsgTestHelper(ctasQuery,
- String.format("A table or view with given name [%s] already exists in schema [%s]", newTblName, TEMP_SCHEMA));
- } finally {
- FileUtils.deleteQuietly(new File(getDfsTestTmpSchemaLocation(), newTblName));
- }
+ test(ctasQuery);
+ errorMsgTestHelper(ctasQuery, String.format("A table or view with given name [%s] already exists in schema [dfs.tmp]", newTblName));
}
@Test // DRILL-2422
@@ -126,143 +116,97 @@ public class TestCTAS extends BaseTestQuery {
final String newTblName = "createTableWhenAViewWithSameNameAlreadyExists";
try {
- test(String.format("CREATE VIEW %s.%s AS SELECT * from cp.`region.json`", TEMP_SCHEMA, newTblName));
+ test("CREATE VIEW dfs.tmp.%s AS SELECT * from cp.`region.json`", newTblName);
- final String ctasQuery =
- String.format("CREATE TABLE %s.%s AS SELECT * FROM cp.`employee.json`", TEMP_SCHEMA, newTblName);
+ final String ctasQuery = String.format("CREATE TABLE dfs.tmp.%s AS SELECT * FROM cp.`employee.json`", newTblName);
errorMsgTestHelper(ctasQuery,
String.format("A table or view with given name [%s] already exists in schema [%s]",
- newTblName, "dfs_test.tmp"));
+ newTblName, "dfs.tmp"));
} finally {
- test(String.format("DROP VIEW %s.%s", TEMP_SCHEMA, newTblName));
+ test("DROP VIEW dfs.tmp.%s", newTblName);
}
}
@Test
public void ctasPartitionWithEmptyList() throws Exception {
final String newTblName = "ctasPartitionWithEmptyList";
+ final String ctasQuery = String.format("CREATE TABLE dfs.tmp.%s PARTITION BY AS SELECT * from cp.`region.json`", newTblName);
- try {
- final String ctasQuery = String.format("CREATE TABLE %s.%s PARTITION BY AS SELECT * from cp.`region.json`", TEMP_SCHEMA, newTblName);
-
- errorMsgTestHelper(ctasQuery,"PARSE ERROR: Encountered \"AS\"");
- } finally {
- FileUtils.deleteQuietly(new File(getDfsTestTmpSchemaLocation(), newTblName));
- }
+ errorMsgTestHelper(ctasQuery,"PARSE ERROR: Encountered \"AS\"");
}
@Test // DRILL-3377
public void partitionByCtasColList() throws Exception {
final String newTblName = "partitionByCtasColList";
- try {
- final String ctasQuery = String.format("CREATE TABLE %s.%s (cnt, rkey) PARTITION BY (cnt) " +
- "AS SELECT count(*), n_regionkey from cp.`tpch/nation.parquet` group by n_regionkey",
- TEMP_SCHEMA, newTblName);
-
- test(ctasQuery);
+ test("CREATE TABLE dfs.tmp.%s (cnt, rkey) PARTITION BY (cnt) " +
+ "AS SELECT count(*), n_regionkey from cp.`tpch/nation.parquet` group by n_regionkey", newTblName);
- final String selectFromCreatedTable = String.format(" select cnt, rkey from %s.%s", TEMP_SCHEMA, newTblName);
- final String baselineQuery = "select count(*) as cnt, n_regionkey as rkey from cp.`tpch/nation.parquet` group by n_regionkey";
- testBuilder()
- .sqlQuery(selectFromCreatedTable)
- .unOrdered()
- .sqlBaselineQuery(baselineQuery)
- .build()
- .run();
- } finally {
- FileUtils.deleteQuietly(new File(getDfsTestTmpSchemaLocation(), newTblName));
- }
+ testBuilder()
+ .sqlQuery("select cnt, rkey from dfs.tmp.%s", newTblName)
+ .unOrdered()
+ .sqlBaselineQuery("select count(*) as cnt, n_regionkey as rkey from cp.`tpch/nation.parquet` group by n_regionkey")
+ .build()
+ .run();
}
@Test // DRILL-3374
public void partitionByCtasFromView() throws Exception {
- final String newTblName = "partitionByCtasColList";
+ final String newTblName = "partitionByCtasFromView";
final String newView = "partitionByCtasColListView";
- try {
- final String viewCreate = String.format("create or replace view %s.%s (col_int, col_varchar) " +
- "AS select cast(n_nationkey as int), cast(n_name as varchar(30)) from cp.`tpch/nation.parquet`",
- TEMP_SCHEMA, newView);
-
- final String ctasQuery = String.format("CREATE TABLE %s.%s PARTITION BY (col_int) AS SELECT * from %s.%s",
- TEMP_SCHEMA, newTblName, TEMP_SCHEMA, newView);
- test(viewCreate);
- test(ctasQuery);
+ test("create or replace view dfs.tmp.%s (col_int, col_varchar) " +
+ "AS select cast(n_nationkey as int), cast(n_name as varchar(30)) from cp.`tpch/nation.parquet`", newView);
+ test("CREATE TABLE dfs.tmp.%s PARTITION BY (col_int) AS SELECT * from dfs.tmp.%s",
+ newTblName, newView);
- final String baselineQuery = "select cast(n_nationkey as int) as col_int, cast(n_name as varchar(30)) as col_varchar " +
- "from cp.`tpch/nation.parquet`";
- final String selectFromCreatedTable = String.format("select col_int, col_varchar from %s.%s", TEMP_SCHEMA, newTblName);
- testBuilder()
- .sqlQuery(selectFromCreatedTable)
- .unOrdered()
- .sqlBaselineQuery(baselineQuery)
- .build()
- .run();
+ testBuilder()
+ .sqlQuery("select col_int, col_varchar from dfs.tmp.%s", newTblName)
+ .unOrdered()
+ .sqlBaselineQuery("select cast(n_nationkey as int) as col_int, cast(n_name as varchar(30)) as col_varchar " +
+ "from cp.`tpch/nation.parquet`")
+ .build()
+ .run();
- final String viewDrop = String.format("DROP VIEW %s.%s", TEMP_SCHEMA, newView);
- test(viewDrop);
- } finally {
- FileUtils.deleteQuietly(new File(getDfsTestTmpSchemaLocation(), newTblName));
- }
+ test("DROP VIEW dfs.tmp.%s", newView);
}
@Test // DRILL-3382
public void ctasWithQueryOrderby() throws Exception {
final String newTblName = "ctasWithQueryOrderby";
- try {
- final String ctasQuery = String.format("CREATE TABLE %s.%s " +
- "AS SELECT n_nationkey, n_name, n_comment from cp.`tpch/nation.parquet` order by n_nationkey",
- TEMP_SCHEMA, newTblName);
-
- test(ctasQuery);
-
- final String selectFromCreatedTable = String.format(" select n_nationkey, n_name, n_comment from %s.%s", TEMP_SCHEMA, newTblName);
- final String baselineQuery = "select n_nationkey, n_name, n_comment from cp.`tpch/nation.parquet` order by n_nationkey";
+ test("CREATE TABLE dfs.tmp.%s AS SELECT n_nationkey, n_name, n_comment from " +
+ "cp.`tpch/nation.parquet` order by n_nationkey", newTblName);
- testBuilder()
- .sqlQuery(selectFromCreatedTable)
- .ordered()
- .sqlBaselineQuery(baselineQuery)
- .build()
- .run();
- } finally {
- FileUtils.deleteQuietly(new File(getDfsTestTmpSchemaLocation(), newTblName));
- }
+ testBuilder()
+ .sqlQuery("select n_nationkey, n_name, n_comment from dfs.tmp.%s", newTblName)
+ .ordered()
+ .sqlBaselineQuery("select n_nationkey, n_name, n_comment from cp.`tpch/nation.parquet` order by n_nationkey")
+ .build()
+ .run();
}
@Test // DRILL-4392
public void ctasWithPartition() throws Exception {
final String newTblName = "nation_ctas";
- try {
- final String ctasQuery = String.format("CREATE TABLE %s.%s " +
- "partition by (n_regionkey) AS SELECT n_nationkey, n_regionkey from cp.`tpch/nation.parquet` order by n_nationkey limit 1",
- TEMP_SCHEMA, newTblName);
-
- test(ctasQuery);
-
- final String selectFromCreatedTable = String.format(" select * from %s.%s", TEMP_SCHEMA, newTblName);
- final String baselineQuery = "select n_nationkey, n_regionkey from cp.`tpch/nation.parquet` order by n_nationkey limit 1";
+ test("CREATE TABLE dfs.tmp.%s partition by (n_regionkey) AS " +
+ "SELECT n_nationkey, n_regionkey from cp.`tpch/nation.parquet` order by n_nationkey limit 1", newTblName);
- testBuilder()
- .sqlQuery(selectFromCreatedTable)
- .ordered()
- .sqlBaselineQuery(baselineQuery)
- .build()
- .run();
- } finally {
- FileUtils.deleteQuietly(new File(getDfsTestTmpSchemaLocation(), newTblName));
- }
+ testBuilder()
+ .sqlQuery("select * from dfs.tmp.%s", newTblName)
+ .ordered()
+ .sqlBaselineQuery("select n_nationkey, n_regionkey from cp.`tpch/nation.parquet` order by n_nationkey limit 1")
+ .build()
+ .run();
}
@Test
public void testPartitionByForAllTypes() throws Exception {
final String location = "partitioned_tables_with_nulls";
final String ctasQuery = "create table %s partition by (%s) as %s";
- final String tablePath = "%s.`%s/%s_%s`";
+ final String tablePath = "dfs.tmp.`%s/%s_%s`";
// key - new table suffix, value - data query
final Map<String, String> variations = Maps.newHashMap();
@@ -270,39 +214,36 @@ public class TestCTAS extends BaseTestQuery {
variations.put("optional", "select * from cp.`parquet/alltypes_optional.parquet`");
variations.put("nulls_only", "select * from cp.`parquet/alltypes_optional.parquet` where %s is null");
- try {
- final QueryDataBatch result = testSqlWithResults("select * from cp.`parquet/alltypes_required.parquet` limit 0").get(0);
- for (UserBitShared.SerializedField field : result.getHeader().getDef().getFieldList()) {
- final String fieldName = field.getNamePart().getName();
-
- for (Map.Entry<String, String> variation : variations.entrySet()) {
- final String table = String.format(tablePath, TEMP_SCHEMA, location, fieldName, variation.getKey());
- final String dataQuery = String.format(variation.getValue(), fieldName);
- test(ctasQuery, table, fieldName, dataQuery, fieldName);
- testBuilder()
- .sqlQuery("select * from %s", table)
- .unOrdered()
- .sqlBaselineQuery(dataQuery)
- .build()
- .run();
- }
+ final QueryDataBatch result = testSqlWithResults("select * from cp.`parquet/alltypes_required.parquet` limit 0").get(0);
+ for (UserBitShared.SerializedField field : result.getHeader().getDef().getFieldList()) {
+ final String fieldName = field.getNamePart().getName();
+
+ for (Map.Entry<String, String> variation : variations.entrySet()) {
+ final String table = String.format(tablePath, location, fieldName, variation.getKey());
+ final String dataQuery = String.format(variation.getValue(), fieldName);
+ test(ctasQuery, table, fieldName, dataQuery, fieldName);
+ testBuilder()
+ .sqlQuery("select * from %s", table)
+ .unOrdered()
+ .sqlBaselineQuery(dataQuery)
+ .build()
+ .run();
}
- result.release();
- } finally {
- FileUtils.deleteQuietly(new File(getDfsTestTmpSchemaLocation(), location));
}
+
+ result.release();
}
@Test
public void createTableWithCustomUmask() throws Exception {
- test("use %s", TEMP_SCHEMA);
+ test("use dfs.tmp");
String tableName = "with_custom_permission";
StorageStrategy storageStrategy = new StorageStrategy("000", false);
FileSystem fs = getLocalFileSystem();
try {
test("alter session set `%s` = '%s'", ExecConstants.PERSISTENT_TABLE_UMASK, storageStrategy.getUmask());
test("create table %s as select 'A' from (values(1))", tableName);
- Path tableLocation = new Path(getDfsTestTmpSchemaLocation(), tableName);
+ Path tableLocation = new Path(dirTestWatcher.getDfsTestTmpDir().getAbsolutePath(), tableName);
assertEquals("Directory permission should match",
storageStrategy.getFolderPermission(), fs.getFileStatus(tableLocation).getPermission());
assertEquals("File permission should match",
@@ -314,7 +255,7 @@ public class TestCTAS extends BaseTestQuery {
}
private static void ctasErrorTestHelper(final String ctasSql, final String expErrorMsg) throws Exception {
- final String createTableSql = String.format(ctasSql, TEMP_SCHEMA, "testTableName");
+ final String createTableSql = String.format(ctasSql, "testTableName");
errorMsgTestHelper(createTableSql, expErrorMsg);
}
}
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestCTTAS.java b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestCTTAS.java
index 904c0fe93..bc06af3ea 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestCTTAS.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestCTTAS.java
@@ -20,17 +20,15 @@ package org.apache.drill.exec.sql;
import com.google.common.collect.Lists;
import mockit.Mock;
import mockit.MockUp;
-import mockit.integration.junit4.JMockit;
-import org.apache.drill.BaseTestQuery;
+import org.apache.drill.exec.store.StoragePluginRegistry;
+import org.apache.drill.exec.store.dfs.FileSystemConfig;
+import org.apache.drill.exec.store.dfs.WorkspaceConfig;
+import org.apache.drill.test.BaseTestQuery;
import org.apache.drill.categories.SqlTest;
import org.apache.drill.common.config.DrillConfig;
import org.apache.drill.common.exceptions.UserRemoteException;
import org.apache.drill.exec.ExecConstants;
-import org.apache.drill.exec.store.StoragePluginRegistry;
import org.apache.drill.exec.store.StorageStrategy;
-import org.apache.drill.exec.store.dfs.FileSystemConfig;
-import org.apache.drill.exec.store.dfs.WorkspaceConfig;
-import org.apache.drill.exec.util.TestUtilities;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.LocatedFileStatus;
import org.apache.hadoop.fs.Path;
@@ -39,25 +37,27 @@ import org.apache.hadoop.fs.permission.FsPermission;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
+import java.io.File;
import java.io.IOException;
+import java.nio.file.Paths;
import java.util.List;
import java.util.Properties;
import java.util.UUID;
+import static org.apache.drill.exec.util.StoragePluginTestUtils.DFS_PLUGIN_NAME;
+import static org.apache.drill.exec.util.StoragePluginTestUtils.DFS_TMP_SCHEMA;
import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
-@RunWith(JMockit.class)
@Category(SqlTest.class)
public class TestCTTAS extends BaseTestQuery {
private static final UUID session_id = UUID.nameUUIDFromBytes("sessionId".getBytes());
private static final String temp2_wk = "tmp2";
- private static final String temp2_schema = String.format("%s.%s", TEST_SCHEMA, temp2_wk);
+ private static final String temp2_schema = String.format("%s.%s", DFS_PLUGIN_NAME, temp2_wk);
private static FileSystem fs;
private static FsPermission expectedFolderPermission;
@@ -67,14 +67,16 @@ public class TestCTTAS extends BaseTestQuery {
public static void init() throws Exception {
MockUp<UUID> uuidMockUp = mockRandomUUID(session_id);
Properties testConfigurations = cloneDefaultTestConfigProperties();
- testConfigurations.put(ExecConstants.DEFAULT_TEMPORARY_WORKSPACE, TEMP_SCHEMA);
+ testConfigurations.put(ExecConstants.DEFAULT_TEMPORARY_WORKSPACE, DFS_TMP_SCHEMA);
updateTestCluster(1, DrillConfig.create(testConfigurations));
uuidMockUp.tearDown();
+ File tmp2 = dirTestWatcher.makeSubDir(Paths.get("tmp2"));
+
StoragePluginRegistry pluginRegistry = getDrillbitContext().getStorage();
- FileSystemConfig pluginConfig = (FileSystemConfig) pluginRegistry.getPlugin(TEST_SCHEMA).getConfig();
- pluginConfig.workspaces.put(temp2_wk, new WorkspaceConfig(TestUtilities.createTempDir(), true, null));
- pluginRegistry.createOrUpdate(TEST_SCHEMA, pluginConfig, true);
+ FileSystemConfig pluginConfig = (FileSystemConfig) pluginRegistry.getPlugin(DFS_PLUGIN_NAME).getConfig();
+ pluginConfig.workspaces.put(temp2_wk, new WorkspaceConfig(tmp2.getAbsolutePath(), true, null));
+ pluginRegistry.createOrUpdate(DFS_PLUGIN_NAME, pluginConfig, true);
fs = getLocalFileSystem();
expectedFolderPermission = new FsPermission(StorageStrategy.TEMPORARY.getFolderPermission());
@@ -93,7 +95,7 @@ public class TestCTTAS extends BaseTestQuery {
@Test
public void testSyntax() throws Exception {
test("create TEMPORARY table temporary_keyword as select 1 from (values(1))");
- test("create TEMPORARY table %s.temporary_keyword_with_wk as select 1 from (values(1))", TEMP_SCHEMA);
+ test("create TEMPORARY table %s.temporary_keyword_with_wk as select 1 from (values(1))", DFS_TMP_SCHEMA);
}
@Test
@@ -118,7 +120,7 @@ public class TestCTTAS extends BaseTestQuery {
testBuilder()
.sqlQuery("select * from %s", temporaryTableName)
.unOrdered()
- .sqlBaselineQuery("select * from %s.%s", TEMP_SCHEMA, temporaryTableName)
+ .sqlBaselineQuery("select * from %s.%s", DFS_TMP_SCHEMA, temporaryTableName)
.go();
}
} finally {
@@ -148,7 +150,7 @@ public class TestCTTAS extends BaseTestQuery {
@Test
public void testResolveTemporaryTableWithPartialSchema() throws Exception {
String temporaryTableName = "temporary_table_with_partial_schema";
- test("use %s", TEST_SCHEMA);
+ test("use %s", DFS_PLUGIN_NAME);
test("create temporary table tmp.%s as select 'A' as c1 from (values(1))", temporaryTableName);
testBuilder()
@@ -176,8 +178,7 @@ public class TestCTTAS extends BaseTestQuery {
} catch (UserRemoteException e) {
assertThat(e.getMessage(), containsString(String.format(
"VALIDATION ERROR: Temporary tables are not allowed to be created / dropped " +
- "outside of default temporary workspace [%s].",
- TEMP_SCHEMA)));
+ "outside of default temporary workspace [%s].", DFS_TMP_SCHEMA)));
throw e;
}
}
@@ -191,7 +192,7 @@ public class TestCTTAS extends BaseTestQuery {
} catch (UserRemoteException e) {
assertThat(e.getMessage(), containsString(String.format(
"VALIDATION ERROR: A table or view with given name [%s]" +
- " already exists in schema [%s]", temporaryTableName, TEMP_SCHEMA)));
+ " already exists in schema [%s]", temporaryTableName, DFS_TMP_SCHEMA)));
throw e;
}
}
@@ -205,7 +206,7 @@ public class TestCTTAS extends BaseTestQuery {
} catch (UserRemoteException e) {
assertThat(e.getMessage(), containsString(String.format(
"VALIDATION ERROR: A table or view with given name [%s]" +
- " already exists in schema [%s]", temporaryTableName.toUpperCase(), TEMP_SCHEMA)));
+ " already exists in schema [%s]", temporaryTableName.toUpperCase(), DFS_TMP_SCHEMA)));
throw e;
}
}
@@ -214,12 +215,12 @@ public class TestCTTAS extends BaseTestQuery {
public void testCreateWhenTemporaryTableExistsWithSchema() throws Exception {
String temporaryTableName = "temporary_table_exists_with_schema";
try {
- test("create TEMPORARY table %s.%s as select 'A' as c1 from (values(1))", TEMP_SCHEMA, temporaryTableName);
- test("create TEMPORARY table %s.%s as select 'A' as c1 from (values(1))", TEMP_SCHEMA, temporaryTableName);
+ test("create TEMPORARY table %s.%s as select 'A' as c1 from (values(1))", DFS_TMP_SCHEMA, temporaryTableName);
+ test("create TEMPORARY table %s.%s as select 'A' as c1 from (values(1))", DFS_TMP_SCHEMA, temporaryTableName);
} catch (UserRemoteException e) {
assertThat(e.getMessage(), containsString(String.format(
"VALIDATION ERROR: A table or view with given name [%s]" +
- " already exists in schema [%s]", temporaryTableName, TEMP_SCHEMA)));
+ " already exists in schema [%s]", temporaryTableName, DFS_TMP_SCHEMA)));
throw e;
}
}
@@ -228,12 +229,12 @@ public class TestCTTAS extends BaseTestQuery {
public void testCreateWhenPersistentTableExists() throws Exception {
String persistentTableName = "persistent_table_exists";
try {
- test("create table %s.%s as select 'A' as c1 from (values(1))", TEMP_SCHEMA, persistentTableName);
+ test("create table %s.%s as select 'A' as c1 from (values(1))", DFS_TMP_SCHEMA, persistentTableName);
test("create TEMPORARY table %s as select 'A' as c1 from (values(1))", persistentTableName);
} catch (UserRemoteException e) {
assertThat(e.getMessage(), containsString(String.format(
"VALIDATION ERROR: A table or view with given name [%s]" +
- " already exists in schema [%s]", persistentTableName, TEMP_SCHEMA)));
+ " already exists in schema [%s]", persistentTableName, DFS_TMP_SCHEMA)));
throw e;
}
}
@@ -242,12 +243,12 @@ public class TestCTTAS extends BaseTestQuery {
public void testCreateWhenViewExists() throws Exception {
String viewName = "view_exists";
try {
- test("create view %s.%s as select 'A' as c1 from (values(1))", TEMP_SCHEMA, viewName);
+ test("create view %s.%s as select 'A' as c1 from (values(1))", DFS_TMP_SCHEMA, viewName);
test("create TEMPORARY table %s as select 'A' as c1 from (values(1))", viewName);
} catch (UserRemoteException e) {
assertThat(e.getMessage(), containsString(String.format(
"VALIDATION ERROR: A table or view with given name [%s]" +
- " already exists in schema [%s]", viewName, TEMP_SCHEMA)));
+ " already exists in schema [%s]", viewName, DFS_TMP_SCHEMA)));
throw e;
}
}
@@ -257,11 +258,11 @@ public class TestCTTAS extends BaseTestQuery {
String temporaryTableName = "temporary_table_exists_before_persistent";
try {
test("create TEMPORARY table %s as select 'A' as c1 from (values(1))", temporaryTableName);
- test("create table %s.%s as select 'A' as c1 from (values(1))", TEMP_SCHEMA, temporaryTableName);
+ test("create table %s.%s as select 'A' as c1 from (values(1))", DFS_TMP_SCHEMA, temporaryTableName);
} catch (UserRemoteException e) {
assertThat(e.getMessage(), containsString(String.format(
"VALIDATION ERROR: A table or view with given name [%s]" +
- " already exists in schema [%s]", temporaryTableName, TEMP_SCHEMA)));
+ " already exists in schema [%s]", temporaryTableName, DFS_TMP_SCHEMA)));
throw e;
}
}
@@ -271,11 +272,11 @@ public class TestCTTAS extends BaseTestQuery {
String temporaryTableName = "temporary_table_exists_before_view";
try {
test("create TEMPORARY table %s as select 'A' as c1 from (values(1))", temporaryTableName);
- test("create view %s.%s as select 'A' as c1 from (values(1))", TEMP_SCHEMA, temporaryTableName);
+ test("create view %s.%s as select 'A' as c1 from (values(1))", DFS_TMP_SCHEMA, temporaryTableName);
} catch (UserRemoteException e) {
assertThat(e.getMessage(), containsString(String.format(
"VALIDATION ERROR: A non-view table with given name [%s] already exists in schema [%s]",
- temporaryTableName, TEMP_SCHEMA)));
+ temporaryTableName, DFS_TMP_SCHEMA)));
throw e;
}
}
@@ -348,7 +349,7 @@ public class TestCTTAS extends BaseTestQuery {
test("create TEMPORARY table %s as select 'A' as c1 from (values(1))", temporaryTableName);
try {
- test("create view %s.view_with_temp_table as select * from %s", TEMP_SCHEMA, temporaryTableName);
+ test("create view %s.view_with_temp_table as select * from %s", DFS_TMP_SCHEMA, temporaryTableName);
} catch (UserRemoteException e) {
assertThat(e.getMessage(), containsString(String.format(
"VALIDATION ERROR: Temporary tables usage is disallowed. Used temporary table name: [%s]", temporaryTableName)));
@@ -360,7 +361,7 @@ public class TestCTTAS extends BaseTestQuery {
public void testTemporaryTablesInViewExpansionLogic() throws Exception {
String tableName = "table_for_expansion_logic_test";
String viewName = "view_for_expansion_logic_test";
- test("use %s", TEMP_SCHEMA);
+ test("use %s", DFS_TMP_SCHEMA);
test("create table %s as select 'TABLE' as c1 from (values(1))", tableName);
test("create view %s as select * from %s", viewName, tableName);
@@ -398,10 +399,10 @@ public class TestCTTAS extends BaseTestQuery {
@Test
public void testManualDropWithSchema() throws Exception {
String temporaryTableName = "temporary_table_to_drop_with_schema";
- test("create TEMPORARY table %s.%s as select 'A' as c1 from (values(1))", TEMP_SCHEMA, temporaryTableName);
+ test("create TEMPORARY table %s.%s as select 'A' as c1 from (values(1))", DFS_TMP_SCHEMA, temporaryTableName);
testBuilder()
- .sqlQuery("drop table %s.%s", TEMP_SCHEMA, temporaryTableName)
+ .sqlQuery("drop table %s.%s", DFS_TMP_SCHEMA, temporaryTableName)
.unOrdered()
.baselineColumns("ok", "summary")
.baselineValues(true, String.format("Temporary table [%s] dropped", temporaryTableName))
@@ -414,11 +415,11 @@ public class TestCTTAS extends BaseTestQuery {
test("create TEMPORARY table %s as select 'A' as c1 from (values(1))", temporaryTableName);
testBuilder()
- .sqlQuery("drop view if exists %s.%s", TEMP_SCHEMA, temporaryTableName)
+ .sqlQuery("drop view if exists %s.%s", DFS_TMP_SCHEMA, temporaryTableName)
.unOrdered()
.baselineColumns("ok", "summary")
.baselineValues(false, String.format("View [%s] not found in schema [%s].",
- temporaryTableName, TEMP_SCHEMA))
+ temporaryTableName, DFS_TMP_SCHEMA))
.go();
}
@@ -428,10 +429,10 @@ public class TestCTTAS extends BaseTestQuery {
test("create TEMPORARY table %s as select 'A' as c1 from (values(1))", temporaryTableName);
try {
- test("drop view %s.%s", TEMP_SCHEMA, temporaryTableName);
+ test("drop view %s.%s", DFS_TMP_SCHEMA, temporaryTableName);
} catch (UserRemoteException e) {
assertThat(e.getMessage(), containsString(String.format(
- "VALIDATION ERROR: Unknown view [%s] in schema [%s]", temporaryTableName, TEMP_SCHEMA)));
+ "VALIDATION ERROR: Unknown view [%s] in schema [%s]", temporaryTableName, DFS_TMP_SCHEMA)));
throw e;
}
}
@@ -449,7 +450,7 @@ public class TestCTTAS extends BaseTestQuery {
}
private List<Path> findTemporaryTableLocation(String tableName) throws IOException {
- Path sessionTempLocation = new Path(getDfsTestTmpSchemaLocation(), session_id.toString());
+ Path sessionTempLocation = new Path(dirTestWatcher.getDfsTestTmpDir().getAbsolutePath(), session_id.toString());
assertTrue("Session temporary location must exist", fs.exists(sessionTempLocation));
assertEquals("Session temporary location permission should match",
expectedFolderPermission, fs.getFileStatus(sessionTempLocation).getPermission());
@@ -465,5 +466,4 @@ public class TestCTTAS extends BaseTestQuery {
}
return matchingPath;
}
-
}
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestInfoSchema.java b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestInfoSchema.java
index 00a7087c4..a8eef3c50 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestInfoSchema.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestInfoSchema.java
@@ -27,18 +27,20 @@ import static org.junit.Assert.assertTrue;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;
-import org.apache.drill.BaseTestQuery;
+import org.apache.drill.test.BaseTestQuery;
import org.apache.drill.categories.SqlTest;
-import org.apache.drill.TestBuilder;
+import org.apache.drill.test.TestBuilder;
import org.apache.drill.common.expression.SchemaPath;
import org.apache.drill.exec.record.RecordBatchLoader;
import org.apache.drill.exec.record.VectorWrapper;
import org.apache.drill.exec.rpc.user.QueryDataBatch;
import org.apache.drill.exec.store.dfs.FileSystemConfig;
import org.apache.drill.exec.vector.NullableVarCharVector;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
+import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
@@ -51,9 +53,15 @@ import java.util.Map;
*/
@Category(SqlTest.class)
public class TestInfoSchema extends BaseTestQuery {
-
+ public static final String TEST_SUB_DIR = "testSubDir";
private static final ObjectMapper mapper = new ObjectMapper().enable(INDENT_OUTPUT);
+ @BeforeClass
+ public static void setupFiles() {
+ dirTestWatcher.copyFileToRoot(Paths.get("sample-data"));
+ dirTestWatcher.makeRootSubDir(Paths.get(TEST_SUB_DIR));
+ }
+
@Test
public void selectFromAllTables() throws Exception{
test("select * from INFORMATION_SCHEMA.SCHEMATA");
@@ -133,9 +141,6 @@ public class TestInfoSchema extends BaseTestQuery {
new String[] { "dfs.tmp" },
new String[] { "cp.default" },
new String[] { "sys" },
- new String[] { "dfs_test.home" },
- new String[] { "dfs_test.default" },
- new String[] { "dfs_test.tmp" },
new String[] { "INFORMATION_SCHEMA" }
);
@@ -161,10 +166,10 @@ public class TestInfoSchema extends BaseTestQuery {
@Test
public void showDatabasesWhere() throws Exception{
testBuilder()
- .sqlQuery("SHOW DATABASES WHERE SCHEMA_NAME='dfs_test.tmp'")
+ .sqlQuery("SHOW DATABASES WHERE SCHEMA_NAME='dfs.tmp'")
.unOrdered()
.baselineColumns("SCHEMA_NAME")
- .baselineValues("dfs_test.tmp")
+ .baselineValues("dfs.tmp")
.go();
}
@@ -207,13 +212,13 @@ public class TestInfoSchema extends BaseTestQuery {
@Test
public void describeWhenSameTableNameExistsInMultipleSchemas() throws Exception{
try {
- test("USE dfs_test.tmp");
+ test("USE dfs.tmp");
test("CREATE OR REPLACE VIEW `TABLES` AS SELECT full_name FROM cp.`employee.json`");
testBuilder()
.sqlQuery("DESCRIBE `TABLES`")
.unOrdered()
- .optionSettingQueriesForTestQuery("USE dfs_test.tmp")
+ .optionSettingQueriesForTestQuery("USE dfs.tmp")
.baselineColumns("COLUMN_NAME", "DATA_TYPE", "IS_NULLABLE")
.baselineValues("full_name", "ANY", "YES")
.go();
@@ -228,7 +233,7 @@ public class TestInfoSchema extends BaseTestQuery {
.baselineValues("TABLE_TYPE", "CHARACTER VARYING", "NO")
.go();
} finally {
- test("DROP VIEW dfs_test.tmp.`TABLES`");
+ test("DROP VIEW dfs.tmp.`TABLES`");
}
}
@@ -280,9 +285,9 @@ public class TestInfoSchema extends BaseTestQuery {
@Test
public void defaultSchemaDfs() throws Exception{
testBuilder()
- .sqlQuery("SELECT R_REGIONKEY FROM `[WORKING_PATH]/../../sample-data/region.parquet` LIMIT 1")
+ .sqlQuery("SELECT R_REGIONKEY FROM `sample-data/region.parquet` LIMIT 1")
.unOrdered()
- .optionSettingQueriesForTestQuery("USE dfs_test")
+ .optionSettingQueriesForTestQuery("USE dfs")
.baselineColumns("R_REGIONKEY")
.baselineValues(0L)
.go();
@@ -305,7 +310,7 @@ public class TestInfoSchema extends BaseTestQuery {
testBuilder()
.sqlQuery("SELECT full_name FROM cp.`employee.json` LIMIT 1")
.unOrdered()
- .optionSettingQueriesForTestQuery("USE dfs_test")
+ .optionSettingQueriesForTestQuery("USE dfs")
.baselineColumns("full_name")
.baselineValues("Sheri Nowmer")
.go();
@@ -314,27 +319,27 @@ public class TestInfoSchema extends BaseTestQuery {
@Test
public void useSchema() throws Exception{
testBuilder()
- .sqlQuery("USE dfs_test.`default`")
+ .sqlQuery("USE dfs.`default`")
.unOrdered()
.baselineColumns("ok", "summary")
- .baselineValues(true, "Default schema changed to [dfs_test.default]")
+ .baselineValues(true, "Default schema changed to [dfs.default]")
.go();
}
@Test
public void useSubSchemaWithinSchema() throws Exception{
testBuilder()
- .sqlQuery("USE dfs_test")
+ .sqlQuery("USE dfs")
.unOrdered()
.baselineColumns("ok", "summary")
- .baselineValues(true, "Default schema changed to [dfs_test]")
+ .baselineValues(true, "Default schema changed to [dfs]")
.go();
testBuilder()
.sqlQuery("USE tmp")
.unOrdered()
.baselineColumns("ok", "summary")
- .baselineValues(true, "Default schema changed to [dfs_test.tmp]")
+ .baselineValues(true, "Default schema changed to [dfs.tmp]")
.go();
testBuilder()
@@ -352,7 +357,7 @@ public class TestInfoSchema extends BaseTestQuery {
}
// Tests using backticks around the complete schema path
- // select * from `dfs_test.tmp`.`/tmp/nation.parquet`;
+ // select * from `dfs.tmp`.`/tmp/nation.parquet`;
@Test
public void completeSchemaRef1() throws Exception {
test("SELECT * FROM `cp.default`.`employee.json` limit 2");
@@ -360,26 +365,26 @@ public class TestInfoSchema extends BaseTestQuery {
@Test
public void showFiles() throws Exception {
- test("show files from dfs_test.`/tmp`");
- test("show files from `dfs_test.default`.`/tmp`");
+ test("show files from dfs.`%s`", TEST_SUB_DIR);
+ test("show files from `dfs.default`.`%s`", TEST_SUB_DIR);
}
@Test
public void showFilesWithDefaultSchema() throws Exception{
- test("USE dfs_test.`default`");
- test("SHOW FILES FROM `/tmp`");
+ test("USE dfs.`default`");
+ test("SHOW FILES FROM `%s`", TEST_SUB_DIR);
}
@Test
public void describeSchemaSyntax() throws Exception {
- test("describe schema dfs_test");
- test("describe schema dfs_test.`default`");
- test("describe database dfs_test.`default`");
+ test("describe schema dfs");
+ test("describe schema dfs.`default`");
+ test("describe database dfs.`default`");
}
@Test
public void describeSchemaOutput() throws Exception {
- final List<QueryDataBatch> result = testSqlWithResults("describe schema dfs_test.tmp");
+ final List<QueryDataBatch> result = testSqlWithResults("describe schema dfs.tmp");
assertTrue(result.size() == 1);
final QueryDataBatch batch = result.get(0);
final RecordBatchLoader loader = new RecordBatchLoader(getDrillbitContext().getAllocator());
@@ -390,7 +395,7 @@ public class TestInfoSchema extends BaseTestQuery {
NullableVarCharVector.class,
loader.getValueVectorId(SchemaPath.getCompoundPath("schema")).getFieldIds());
String schema = schemaValueVector.getValueVector().getAccessor().getObject(0).toString();
- assertEquals("dfs_test.tmp", schema);
+ assertEquals("dfs.tmp", schema);
// check properties column value
final VectorWrapper propertiesValueVector = loader.getValueAccessorById(
@@ -408,7 +413,7 @@ public class TestInfoSchema extends BaseTestQuery {
// check some stable properties values
assertEquals("file", configMap.get("type"));
- final FileSystemConfig testConfig = (FileSystemConfig) bits[0].getContext().getStorage().getPlugin("dfs_test").getConfig();
+ final FileSystemConfig testConfig = (FileSystemConfig) bits[0].getContext().getStorage().getPlugin("dfs").getConfig();
final String tmpSchemaLocation = testConfig.workspaces.get("tmp").getLocation();
assertEquals(tmpSchemaLocation, configMap.get("location"));
@@ -420,5 +425,4 @@ public class TestInfoSchema extends BaseTestQuery {
public void describeSchemaInvalid() throws Exception {
errorMsgTestHelper("describe schema invalid.schema", "Invalid schema name [invalid.schema]");
}
-
}
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestSimpleCastFunctions.java b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestSimpleCastFunctions.java
index ea64c7dab..00c7af408 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestSimpleCastFunctions.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestSimpleCastFunctions.java
@@ -19,7 +19,7 @@ package org.apache.drill.exec.sql;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
-import org.apache.drill.BaseTestQuery;
+import org.apache.drill.test.BaseTestQuery;
import org.apache.drill.categories.SqlTest;
import org.apache.drill.common.exceptions.UserRemoteException;
import org.junit.Test;
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestViewSupport.java b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestViewSupport.java
index c2bd21537..d571c664d 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestViewSupport.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestViewSupport.java
@@ -21,23 +21,34 @@ import com.google.common.collect.ImmutableList;
import org.apache.commons.io.FileUtils;
import org.apache.drill.categories.SqlTest;
import org.apache.drill.categories.UnlikelyTest;
+import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import java.io.File;
+import java.nio.file.Paths;
import java.util.List;
+import static org.apache.drill.exec.util.StoragePluginTestUtils.DFS_TMP_SCHEMA;
+import static org.apache.drill.exec.util.StoragePluginTestUtils.TMP_SCHEMA;
+
@Category(SqlTest.class)
public class TestViewSupport extends TestBaseViewSupport {
+
+ @BeforeClass
+ public static void setupTestFiles() {
+ dirTestWatcher.copyResourceToRoot(Paths.get("nation"));
+ }
+
@Test
public void referToSchemaInsideAndOutsideView() throws Exception {
- String use = "use dfs_test.tmp;";
+ String use = "use dfs.tmp;";
String selectInto = "create table monkey as select c_custkey, c_nationkey from cp.`tpch/customer.parquet`";
String createView = "create or replace view myMonkeyView as select c_custkey, c_nationkey from monkey";
String selectInside = "select * from myMonkeyView;";
String use2 = "use cp;";
- String selectOutside = "select * from dfs_test.tmp.myMonkeyView;";
+ String selectOutside = "select * from dfs.tmp.myMonkeyView;";
test(use);
test(selectInto);
@@ -56,7 +67,7 @@ public class TestViewSupport extends TestBaseViewSupport {
final String viewName = "testNullabilityPropertyInViewPersistence";
try {
- test("USE dfs_test.tmp");
+ test("USE dfs.tmp");
test(String.format("CREATE OR REPLACE VIEW %s AS SELECT " +
"CAST(customer_id AS BIGINT) as cust_id, " +
"CAST(fname AS VARCHAR(25)) as fname, " +
@@ -88,7 +99,7 @@ public class TestViewSupport extends TestBaseViewSupport {
@Test
public void viewWithStarInDef_StarInQuery() throws Exception {
testViewHelper(
- TEMP_SCHEMA,
+ DFS_TMP_SCHEMA,
null,
"SELECT * FROM cp.`region.json` ORDER BY `region_id`",
"SELECT * FROM TEST_SCHEMA.TEST_VIEW_NAME LIMIT 1",
@@ -101,7 +112,7 @@ public class TestViewSupport extends TestBaseViewSupport {
@Test
public void viewWithSelectFieldsInDef_StarInQuery() throws Exception {
testViewHelper(
- TEMP_SCHEMA,
+ DFS_TMP_SCHEMA,
null,
"SELECT region_id, sales_city FROM cp.`region.json` ORDER BY `region_id`",
"SELECT * FROM TEST_SCHEMA.TEST_VIEW_NAME LIMIT 2",
@@ -116,7 +127,7 @@ public class TestViewSupport extends TestBaseViewSupport {
@Test
public void viewWithSelectFieldsInDef_SelectFieldsInView_StarInQuery() throws Exception {
testViewHelper(
- TEMP_SCHEMA,
+ DFS_TMP_SCHEMA,
"(regionid, salescity)",
"SELECT region_id, sales_city FROM cp.`region.json` ORDER BY `region_id`",
"SELECT * FROM TEST_SCHEMA.TEST_VIEW_NAME LIMIT 2",
@@ -131,7 +142,7 @@ public class TestViewSupport extends TestBaseViewSupport {
@Test
public void viewWithStarInDef_SelectFieldsInQuery() throws Exception{
testViewHelper(
- TEMP_SCHEMA,
+ DFS_TMP_SCHEMA,
null,
"SELECT * FROM cp.`region.json` ORDER BY `region_id`",
"SELECT region_id, sales_city FROM TEST_SCHEMA.TEST_VIEW_NAME LIMIT 2",
@@ -146,7 +157,7 @@ public class TestViewSupport extends TestBaseViewSupport {
@Test
public void viewWithSelectFieldsInDef_SelectFieldsInQuery1() throws Exception {
testViewHelper(
- TEMP_SCHEMA,
+ DFS_TMP_SCHEMA,
null,
"SELECT region_id, sales_city FROM cp.`region.json` ORDER BY `region_id`",
"SELECT region_id, sales_city FROM TEST_SCHEMA.TEST_VIEW_NAME LIMIT 2",
@@ -161,7 +172,7 @@ public class TestViewSupport extends TestBaseViewSupport {
@Test
public void viewWithSelectFieldsInDef_SelectFieldsInQuery2() throws Exception {
testViewHelper(
- TEMP_SCHEMA,
+ DFS_TMP_SCHEMA,
null,
"SELECT region_id, sales_city FROM cp.`region.json` ORDER BY `region_id`",
"SELECT sales_city FROM TEST_SCHEMA.TEST_VIEW_NAME LIMIT 2",
@@ -176,7 +187,7 @@ public class TestViewSupport extends TestBaseViewSupport {
@Test
public void viewWithSelectFieldsInDef_SelectFieldsInView_SelectFieldsInQuery1() throws Exception {
testViewHelper(
- TEMP_SCHEMA,
+ DFS_TMP_SCHEMA,
"(regionid, salescity)",
"SELECT region_id, sales_city FROM cp.`region.json` ORDER BY `region_id` LIMIT 2",
"SELECT regionid, salescity FROM TEST_SCHEMA.TEST_VIEW_NAME LIMIT 2",
@@ -191,7 +202,7 @@ public class TestViewSupport extends TestBaseViewSupport {
@Test
public void viewWithSelectFieldsInDef_SelectFieldsInView_SelectFieldsInQuery2() throws Exception {
testViewHelper(
- TEMP_SCHEMA,
+ DFS_TMP_SCHEMA,
"(regionid, salescity)",
"SELECT region_id, sales_city FROM cp.`region.json` ORDER BY `region_id` DESC",
"SELECT regionid FROM TEST_SCHEMA.TEST_VIEW_NAME LIMIT 2",
@@ -207,7 +218,7 @@ public class TestViewSupport extends TestBaseViewSupport {
@Ignore("DRILL-1921")
public void viewWithUnionWithSelectFieldsInDef_StarInQuery() throws Exception{
testViewHelper(
- TEMP_SCHEMA,
+ DFS_TMP_SCHEMA,
null,
"SELECT region_id FROM cp.`region.json` UNION SELECT employee_id FROM cp.`employee.json`",
"SELECT regionid FROM TEST_SCHEMA.TEST_VIEW_NAME LIMIT 2",
@@ -225,20 +236,20 @@ public class TestViewSupport extends TestBaseViewSupport {
final String outerView = generateViewName();
try {
- createViewHelper(TEMP_SCHEMA, innerView, TEMP_SCHEMA, null,
+ createViewHelper(DFS_TMP_SCHEMA, innerView, DFS_TMP_SCHEMA, null,
"SELECT region_id, sales_city FROM cp.`region.json` ORDER BY `region_id`");
- createViewHelper(TEMP_SCHEMA, outerView, TEMP_SCHEMA, null,
- String.format("SELECT region_id FROM %s.`%s`", TEMP_SCHEMA, innerView));
+ createViewHelper(DFS_TMP_SCHEMA, outerView, DFS_TMP_SCHEMA, null,
+ String.format("SELECT region_id FROM %s.`%s`", DFS_TMP_SCHEMA, innerView));
queryViewHelper(
- String.format("SELECT region_id FROM %s.`%s` LIMIT 1", TEMP_SCHEMA, outerView),
+ String.format("SELECT region_id FROM %s.`%s` LIMIT 1", DFS_TMP_SCHEMA, outerView),
new String[] { "region_id" },
ImmutableList.of(new Object[] { 0L })
);
} finally {
- dropViewHelper(TEMP_SCHEMA, outerView, TEMP_SCHEMA);
- dropViewHelper(TEMP_SCHEMA, innerView, TEMP_SCHEMA);
+ dropViewHelper(DFS_TMP_SCHEMA, outerView, DFS_TMP_SCHEMA);
+ dropViewHelper(DFS_TMP_SCHEMA, innerView, DFS_TMP_SCHEMA);
}
}
@@ -250,10 +261,10 @@ public class TestViewSupport extends TestBaseViewSupport {
"cast(columns[1] AS CHAR(25)) n_name, " +
"cast(columns[2] AS INT) n_regionkey, " +
"cast(columns[3] AS VARCHAR(152)) n_comment " +
- "FROM dfs_test.`[WORKING_PATH]/src/test/resources/nation`";
+ "FROM dfs.`nation`";
testViewHelper(
- TEMP_SCHEMA,
+ DFS_TMP_SCHEMA,
null,
viewDef,
"SELECT * FROM TEST_SCHEMA.TEST_VIEW_NAME LIMIT 1",
@@ -272,33 +283,31 @@ public class TestViewSupport extends TestBaseViewSupport {
final String viewDef1 = "SELECT region_id, sales_city FROM cp.`region.json`";
// Create the view
- createViewHelper(TEMP_SCHEMA, viewName, TEMP_SCHEMA, null, viewDef1);
+ createViewHelper(DFS_TMP_SCHEMA, viewName, DFS_TMP_SCHEMA, null, viewDef1);
// Try to create the view with same name in same schema.
- final String createViewSql = String.format("CREATE VIEW %s.`%s` AS %s", TEMP_SCHEMA, viewName, viewDef1);
+ final String createViewSql = String.format("CREATE VIEW %s.`%s` AS %s", DFS_TMP_SCHEMA, viewName, viewDef1);
errorMsgTestHelper(createViewSql,
- String.format("A view with given name [%s] already exists in schema [%s]", viewName, TEMP_SCHEMA));
+ String.format("A view with given name [%s] already exists in schema [%s]", viewName, DFS_TMP_SCHEMA));
// Try creating the view with same name in same schema, but with CREATE OR REPLACE VIEW clause
final String viewDef2 = "SELECT sales_state_province FROM cp.`region.json` ORDER BY `region_id`";
- final String createOrReplaceViewSql = String.format("CREATE OR REPLACE VIEW %s.`%s` AS %s", TEMP_SCHEMA,
- viewName, viewDef2);
testBuilder()
- .sqlQuery(createOrReplaceViewSql)
+ .sqlQuery("CREATE OR REPLACE VIEW %s.`%s` AS %s", DFS_TMP_SCHEMA, viewName, viewDef2)
.unOrdered()
.baselineColumns("ok", "summary")
.baselineValues(true,
- String.format("View '%s' replaced successfully in '%s' schema", viewName, TEMP_SCHEMA))
+ String.format("View '%s' replaced successfully in '%s' schema", viewName, DFS_TMP_SCHEMA))
.go();
// Make sure the new view created returns the data expected.
- queryViewHelper(String.format("SELECT * FROM %s.`%s` LIMIT 1", TEMP_SCHEMA, viewName),
+ queryViewHelper(String.format("SELECT * FROM %s.`%s` LIMIT 1", DFS_TMP_SCHEMA, viewName),
new String[]{"sales_state_province"},
ImmutableList.of(new Object[]{"None"})
);
} finally {
- dropViewHelper(TEMP_SCHEMA, viewName, TEMP_SCHEMA);
+ dropViewHelper(DFS_TMP_SCHEMA, viewName, DFS_TMP_SCHEMA);
}
}
@@ -310,19 +319,19 @@ public class TestViewSupport extends TestBaseViewSupport {
try {
final String tableDef1 = "SELECT region_id, sales_city FROM cp.`region.json`";
- test(String.format("CREATE TABLE %s.%s as %s", TEMP_SCHEMA, tableName, tableDef1));
+ test("CREATE TABLE %s.%s as %s", DFS_TMP_SCHEMA, tableName, tableDef1);
// Try to create the view with same name in same schema.
- final String createViewSql = String.format("CREATE VIEW %s.`%s` AS %s", TEMP_SCHEMA, tableName, tableDef1);
+ final String createViewSql = String.format("CREATE VIEW %s.`%s` AS %s", DFS_TMP_SCHEMA, tableName, tableDef1);
errorMsgTestHelper(createViewSql,
- String.format("A non-view table with given name [%s] already exists in schema [%s]", tableName, TEMP_SCHEMA));
+ String.format("A non-view table with given name [%s] already exists in schema [%s]", tableName, DFS_TMP_SCHEMA));
// Try creating the view with same name in same schema, but with CREATE OR REPLACE VIEW clause
final String viewDef2 = "SELECT sales_state_province FROM cp.`region.json` ORDER BY `region_id`";
- errorMsgTestHelper(String.format("CREATE OR REPLACE VIEW %s.`%s` AS %s", TEMP_SCHEMA, tableName, viewDef2),
- String.format("A non-view table with given name [%s] already exists in schema [%s]", tableName, TEMP_SCHEMA));
+ errorMsgTestHelper(String.format("CREATE OR REPLACE VIEW %s.`%s` AS %s", DFS_TMP_SCHEMA, tableName, viewDef2),
+ String.format("A non-view table with given name [%s] already exists in schema [%s]", tableName, DFS_TMP_SCHEMA));
} finally {
- FileUtils.deleteQuietly(new File(getDfsTestTmpSchemaLocation(), tableName));
+ FileUtils.deleteQuietly(new File(dirTestWatcher.getDfsTestTmpDir(), tableName));
}
}
@@ -331,44 +340,44 @@ public class TestViewSupport extends TestBaseViewSupport {
final String viewName = generateViewName();
try {
- test("USE " + TEMP_SCHEMA);
- createViewHelper(null /*pass no schema*/, viewName, TEMP_SCHEMA, null,
+ test("USE " + DFS_TMP_SCHEMA);
+ createViewHelper(null /*pass no schema*/, viewName, DFS_TMP_SCHEMA, null,
"SELECT cast(`employee_id` as integer) employeeid FROM cp.`employee.json`");
// Test SHOW TABLES on view
testBuilder()
- .sqlQuery(String.format("SHOW TABLES like '%s'", viewName))
+ .sqlQuery("SHOW TABLES like '%s'", viewName)
.unOrdered()
.baselineColumns("TABLE_SCHEMA", "TABLE_NAME")
- .baselineValues(TEMP_SCHEMA, viewName)
+ .baselineValues(DFS_TMP_SCHEMA, viewName)
.go();
// Test record in INFORMATION_SCHEMA.VIEWS
testBuilder()
- .sqlQuery(String.format("SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = '%s'", viewName))
+ .sqlQuery("SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = '%s'", viewName)
.unOrdered()
.baselineColumns("TABLE_CATALOG", "TABLE_SCHEMA", "TABLE_NAME", "VIEW_DEFINITION")
- .baselineValues("DRILL", TEMP_SCHEMA, viewName,
- "SELECT CAST(`employee_id` AS INTEGER) AS `employeeid`\n" + "FROM `cp`.`employee.json`")
+ .baselineValues("DRILL", DFS_TMP_SCHEMA, viewName,
+ "SELECT CAST(`employee_id` AS INTEGER) AS `employeeid`\nFROM `cp`.`employee.json`")
.go();
// Test record in INFORMATION_SCHEMA.TABLES
testBuilder()
- .sqlQuery(String.format("SELECT * FROM INFORMATION_SCHEMA.`TABLES` WHERE TABLE_NAME = '%s'", viewName))
+ .sqlQuery("SELECT * FROM INFORMATION_SCHEMA.`TABLES` WHERE TABLE_NAME = '%s'", viewName)
.unOrdered()
.baselineColumns("TABLE_CATALOG", "TABLE_SCHEMA", "TABLE_NAME", "TABLE_TYPE")
- .baselineValues("DRILL", TEMP_SCHEMA, viewName, "VIEW")
+ .baselineValues("DRILL", DFS_TMP_SCHEMA, viewName, "VIEW")
.go();
// Test DESCRIBE view
testBuilder()
- .sqlQuery(String.format("DESCRIBE `%s`", viewName))
+ .sqlQuery("DESCRIBE `%s`", viewName)
.unOrdered()
.baselineColumns("COLUMN_NAME", "DATA_TYPE", "IS_NULLABLE")
.baselineValues("employeeid", "INTEGER", "YES")
.go();
} finally {
- dropViewHelper(TEMP_SCHEMA, viewName, TEMP_SCHEMA);
+ dropViewHelper(DFS_TMP_SCHEMA, viewName, DFS_TMP_SCHEMA);
}
}
@@ -377,35 +386,35 @@ public class TestViewSupport extends TestBaseViewSupport {
final String viewName = generateViewName();
try {
- // Change default schema to just "dfs_test". View is actually created in "dfs_test.tmp" schema.
- test("USE dfs_test");
+ // Change default schema to just "dfs". View is actually created in "dfs.tmp" schema.
+ test("USE dfs");
// Create a view with with "tmp" schema identifier
- createViewHelper("tmp", viewName, TEMP_SCHEMA, null,
+ createViewHelper("tmp", viewName, DFS_TMP_SCHEMA, null,
"SELECT CAST(`employee_id` AS INTEGER) AS `employeeid`\n" + "FROM `cp`.`employee.json`");
final String[] baselineColumns = new String[] { "employeeid" };
final List<Object[]> baselineValues = ImmutableList.of(new Object[] { 1156 });
- // Query view from current schema "dfs_test" by referring to the view using "tmp.viewName"
+ // Query view from current schema "dfs" by referring to the view using "tmp.viewName"
queryViewHelper(
String.format("SELECT * FROM %s.`%s` ORDER BY `employeeid` DESC LIMIT 1", "tmp", viewName),
baselineColumns, baselineValues);
- // Change the default schema to "dfs_test.tmp" and query view by referring to it using "viewName"
- test("USE dfs_test.tmp");
+ // Change the default schema to "dfs.tmp" and query view by referring to it using "viewName"
+ test("USE dfs.tmp");
queryViewHelper(
String.format("SELECT * FROM `%s` ORDER BY `employeeid` DESC LIMIT 1", viewName),
baselineColumns, baselineValues);
- // Change the default schema to "cp" and query view by referring to it using "dfs_test.tmp.viewName";
+ // Change the default schema to "cp" and query view by referring to it using "dfs.tmp.viewName";
test("USE cp");
queryViewHelper(
- String.format("SELECT * FROM %s.`%s` ORDER BY `employeeid` DESC LIMIT 1", "dfs_test.tmp", viewName),
+ String.format("SELECT * FROM %s.`%s` ORDER BY `employeeid` DESC LIMIT 1", "dfs.tmp", viewName),
baselineColumns, baselineValues);
} finally {
- dropViewHelper(TEMP_SCHEMA, viewName, TEMP_SCHEMA);
+ dropViewHelper(DFS_TMP_SCHEMA, viewName, DFS_TMP_SCHEMA);
}
}
@@ -419,24 +428,24 @@ public class TestViewSupport extends TestBaseViewSupport {
test("USE cp");
// Create a view with full schema identifier and refer the "region.json" as without schema.
- createViewHelper(TEMP_SCHEMA, viewName, TEMP_SCHEMA, null, "SELECT region_id, sales_city FROM `region.json`");
+ createViewHelper(DFS_TMP_SCHEMA, viewName, DFS_TMP_SCHEMA, null, "SELECT region_id, sales_city FROM `region.json`");
final String[] baselineColumns = new String[] { "region_id", "sales_city" };
final List<Object[]> baselineValues = ImmutableList.of(new Object[]{109L, "Santa Fe"});
// Query the view
queryViewHelper(
- String.format("SELECT * FROM %s.`%s` ORDER BY region_id DESC LIMIT 1", "dfs_test.tmp", viewName),
+ String.format("SELECT * FROM %s.`%s` ORDER BY region_id DESC LIMIT 1", DFS_TMP_SCHEMA, viewName),
baselineColumns, baselineValues);
- // Change default schema to "dfs_test" and query by referring to the view using "tmp.viewName"
- test("USE dfs_test");
+ // Change default schema to "dfs" and query by referring to the view using "tmp.viewName"
+ test("USE dfs");
queryViewHelper(
- String.format("SELECT * FROM %s.`%s` ORDER BY region_id DESC LIMIT 1", "tmp", viewName),
+ String.format("SELECT * FROM %s.`%s` ORDER BY region_id DESC LIMIT 1", TMP_SCHEMA, viewName),
baselineColumns, baselineValues);
} finally {
- dropViewHelper(TEMP_SCHEMA, viewName, TEMP_SCHEMA);
+ dropViewHelper(DFS_TMP_SCHEMA, viewName, DFS_TMP_SCHEMA);
}
}
@@ -448,8 +457,8 @@ public class TestViewSupport extends TestBaseViewSupport {
final String viewName = generateViewName();
try {
- test("USE " + TEMP_SCHEMA);
- createViewHelper(null, viewName, TEMP_SCHEMA, "(id, name, bday)",
+ test("use %s", DFS_TMP_SCHEMA);
+ createViewHelper(null, viewName, DFS_TMP_SCHEMA, "(id, name, bday)",
"SELECT " +
"cast(`region_id` as integer), " +
"cast(`full_name` as varchar(100)), " +
@@ -458,7 +467,7 @@ public class TestViewSupport extends TestBaseViewSupport {
// Test DESCRIBE view
testBuilder()
- .sqlQuery(String.format("DESCRIBE `%s`", viewName))
+ .sqlQuery("DESCRIBE `%s`", viewName)
.unOrdered()
.baselineColumns("COLUMN_NAME", "DATA_TYPE", "IS_NULLABLE")
.baselineValues("id", "INTEGER", "YES")
@@ -466,7 +475,7 @@ public class TestViewSupport extends TestBaseViewSupport {
.baselineValues("bday", "DATE", "YES")
.go();
} finally {
- dropViewHelper(TEMP_SCHEMA, viewName, TEMP_SCHEMA);
+ dropViewHelper(DFS_TMP_SCHEMA, viewName, DFS_TMP_SCHEMA);
}
}
@@ -531,7 +540,7 @@ public class TestViewSupport extends TestBaseViewSupport {
@Category(UnlikelyTest.class)
public void createViewWithUniqueColsInFieldListDuplicateColsInQuery1() throws Exception {
testViewHelper(
- TEMP_SCHEMA,
+ DFS_TMP_SCHEMA,
"(regionid1, regionid2)",
"SELECT region_id, region_id FROM cp.`region.json` LIMIT 1",
"SELECT * FROM TEST_SCHEMA.TEST_VIEW_NAME",
@@ -546,7 +555,7 @@ public class TestViewSupport extends TestBaseViewSupport {
@Category(UnlikelyTest.class)
public void createViewWithUniqueColsInFieldListDuplicateColsInQuery2() throws Exception {
testViewHelper(
- TEMP_SCHEMA,
+ DFS_TMP_SCHEMA,
"(regionid1, regionid2)",
"SELECT t1.region_id, t2.region_id FROM cp.`region.json` t1 JOIN cp.`region.json` t2 " +
"ON t1.region_id = t2.region_id LIMIT 1",
@@ -578,15 +587,15 @@ public class TestViewSupport extends TestBaseViewSupport {
}
private static void createViewErrorTestHelper(final String viewSql, final String expErrorMsg) throws Exception {
- final String createViewSql = String.format(viewSql, TEMP_SCHEMA, "duplicateColumnsInViewDef");
+ final String createViewSql = String.format(viewSql, DFS_TMP_SCHEMA, "duplicateColumnsInViewDef");
errorMsgTestHelper(createViewSql, expErrorMsg);
}
@Test // DRILL-2423
@Category(UnlikelyTest.class)
public void showProperMsgWhenDroppingNonExistentView() throws Exception{
- errorMsgTestHelper("DROP VIEW dfs_test.tmp.nonExistentView",
- "Unknown view [nonExistentView] in schema [dfs_test.tmp].");
+ errorMsgTestHelper("DROP VIEW dfs.tmp.nonExistentView",
+ "Unknown view [nonExistentView] in schema [dfs.tmp].");
}
@Test // DRILL-2423
@@ -601,13 +610,13 @@ public class TestViewSupport extends TestBaseViewSupport {
public void showProperMsgWhenTryingToDropANonViewTable() throws Exception{
final String testTableName = "testTableShowErrorMsg";
try {
- test(String.format("CREATE TABLE %s.%s AS SELECT c_custkey, c_nationkey from cp.`tpch/customer.parquet`",
- TEMP_SCHEMA, testTableName));
+ test("CREATE TABLE %s.%s AS SELECT c_custkey, c_nationkey from cp.`tpch/customer.parquet`",
+ DFS_TMP_SCHEMA, testTableName);
- errorMsgTestHelper(String.format("DROP VIEW %s.%s", TEMP_SCHEMA, testTableName),
- "[testTableShowErrorMsg] is not a VIEW in schema [dfs_test.tmp]");
+ errorMsgTestHelper(String.format("DROP VIEW %s.%s", DFS_TMP_SCHEMA, testTableName),
+ "[testTableShowErrorMsg] is not a VIEW in schema [dfs.tmp]");
} finally {
- File tblPath = new File(getDfsTestTmpSchemaLocation(), testTableName);
+ File tblPath = new File(dirTestWatcher.getDfsTestTmpDir(), testTableName);
FileUtils.deleteQuietly(tblPath);
}
}
@@ -617,9 +626,9 @@ public class TestViewSupport extends TestBaseViewSupport {
final String existentViewName = generateViewName();
// successful dropping of existent view
- createViewHelper(TEMP_SCHEMA, existentViewName, TEMP_SCHEMA, null,
+ createViewHelper(DFS_TMP_SCHEMA, existentViewName, DFS_TMP_SCHEMA, null,
"SELECT c_custkey, c_nationkey from cp.`tpch/customer.parquet`");
- dropViewIfExistsHelper(TEMP_SCHEMA, existentViewName, TEMP_SCHEMA, true);
+ dropViewIfExistsHelper(DFS_TMP_SCHEMA, existentViewName, DFS_TMP_SCHEMA, true);
}
@Test // DRILL-4673
@@ -627,7 +636,7 @@ public class TestViewSupport extends TestBaseViewSupport {
final String nonExistentViewName = generateViewName();
// dropping of non existent view without error
- dropViewIfExistsHelper(TEMP_SCHEMA, nonExistentViewName, TEMP_SCHEMA, false);
+ dropViewIfExistsHelper(DFS_TMP_SCHEMA, nonExistentViewName, DFS_TMP_SCHEMA, false);
}
@Test // DRILL-4673
@@ -635,11 +644,11 @@ public class TestViewSupport extends TestBaseViewSupport {
final String tableName = "table_name";
try{
// dropping of non existent view without error if the table with such name is existed
- test(String.format("CREATE TABLE %s.%s as SELECT region_id, sales_city FROM cp.`region.json`",
- TEMP_SCHEMA, tableName));
- dropViewIfExistsHelper(TEMP_SCHEMA, tableName, TEMP_SCHEMA, false);
+ test("CREATE TABLE %s.%s as SELECT region_id, sales_city FROM cp.`region.json`",
+ DFS_TMP_SCHEMA, tableName);
+ dropViewIfExistsHelper(DFS_TMP_SCHEMA, tableName, DFS_TMP_SCHEMA, false);
} finally {
- test(String.format("DROP TABLE IF EXISTS %s.%s ", TEMP_SCHEMA, tableName));
+ test("DROP TABLE IF EXISTS %s.%s ", DFS_TMP_SCHEMA, tableName);
}
}
}
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestWithClause.java b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestWithClause.java
index b901120b7..51821e9a4 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestWithClause.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestWithClause.java
@@ -17,7 +17,7 @@
*/
package org.apache.drill.exec.sql;
-import org.apache.drill.BaseTestQuery;
+import org.apache.drill.test.BaseTestQuery;
import org.apache.drill.categories.SqlTest;
import org.junit.Ignore;
import org.junit.Test;