Github user arina-ielchiieva commented on a diff in the pull request:
https://github.com/apache/drill/pull/1225#discussion_r185456183
--- Diff: exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestCTTAS.java ---
@@ -164,121 +166,113 @@ public void testResolveTemporaryTableWithPartialSchema() throws
Exception {
@Test
public void testPartitionByWithTemporaryTables() throws Exception {
String temporaryTableName = "temporary_table_with_partitions";
- mockRandomUUID(UUID.nameUUIDFromBytes(temporaryTableName.getBytes()));
+ cleanSessionDirectory();
test("create TEMPORARY table %s partition by (c1) as select * from (" +
"select 'A' as c1 from (values(1)) union all select 'B' as c1 from (values(1)))
t", temporaryTableName);
- checkPermission(temporaryTableName);
+ checkPermission();
}
- @Test(expected = UserRemoteException.class)
+ @Test
public void testCreationOutsideOfDefaultTemporaryWorkspace() throws Exception {
- try {
- String temporaryTableName = "temporary_table_outside_of_default_workspace";
- test("create TEMPORARY table %s.%s as select 'A' as c1 from (values(1))", temp2_schema,
temporaryTableName);
- } 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].", DFS_TMP_SCHEMA)));
- throw e;
- }
+ String temporaryTableName = "temporary_table_outside_of_default_workspace";
+
+ thrown.expect(UserRemoteException.class);
+ thrown.expectMessage(containsString(String.format(
+ "VALIDATION ERROR: Temporary tables are not allowed to be created / dropped "
+
+ "outside of default temporary workspace [%s].", DFS_TMP_SCHEMA)));
+
+ test("create TEMPORARY table %s.%s as select 'A' as c1 from (values(1))", temp2_schema,
temporaryTableName);
}
- @Test(expected = UserRemoteException.class)
+ @Test
public void testCreateWhenTemporaryTableExistsWithoutSchema() throws Exception {
String temporaryTableName = "temporary_table_exists_without_schema";
- try {
- test("create TEMPORARY table %s as select 'A' as c1 from (values(1))", temporaryTableName);
- test("create TEMPORARY table %s as select 'A' as c1 from (values(1))", 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, DFS_TMP_SCHEMA)));
- throw e;
- }
+
+ thrown.expect(UserRemoteException.class);
+ thrown.expectMessage(containsString(String.format(
+ "VALIDATION ERROR: A table or view with given name [%s]" +
+ " already exists in schema [%s]", temporaryTableName, DFS_TMP_SCHEMA)));
+
+ test("create TEMPORARY table %s as select 'A' as c1 from (values(1))", temporaryTableName);
+ test("create TEMPORARY table %s as select 'A' as c1 from (values(1))", temporaryTableName);
}
- @Test(expected = UserRemoteException.class)
+ @Test
public void testCreateWhenTemporaryTableExistsCaseInsensitive() throws Exception {
String temporaryTableName = "temporary_table_exists_without_schema";
- try {
- test("create TEMPORARY table %s as select 'A' as c1 from (values(1))", temporaryTableName);
- test("create TEMPORARY table %s as select 'A' as c1 from (values(1))", temporaryTableName.toUpperCase());
- } 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(), DFS_TMP_SCHEMA)));
- throw e;
- }
+
+ thrown.expect(UserRemoteException.class);
+ thrown.expectMessage(containsString(String.format(
+ "VALIDATION ERROR: A table or view with given name [%s]" +
--- End diff --
Done.
---
|