Skip to content

Commit

Permalink
Add test for Faker connector renameTable
Browse files Browse the repository at this point in the history
  • Loading branch information
sthandassery authored and ebyhr committed Jan 29, 2025
1 parent aa8f839 commit 0f7a10a
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -457,4 +457,27 @@ void testSetTableProperties()
.contains("default_limit = 100");
}
}

@Test
void testRenameTable()
{
assertUpdate("CREATE TABLE original_table(id INTEGER, name VARCHAR)");
assertUpdate("ALTER TABLE original_table RENAME TO renamed_table");
// original_table should not exist anymore after renaming.
assertQueryFails("DESC original_table", "line 1:1: Table 'faker.default.original_table' does not exist");
// should not allow renaming to an already existing table.
assertQueryFails("ALTER TABLE renamed_table RENAME TO renamed_table", "line 1:1: Target table 'faker.default.renamed_table' already exists");
assertUpdate("DROP TABLE renamed_table");
}

@Test
void testRenameTableAcrossSchema()
{
assertUpdate("CREATE SCHEMA new_schema");
assertUpdate("CREATE TABLE original_table_schema(id INTEGER, name VARCHAR)");
assertUpdate("ALTER TABLE original_table_schema RENAME TO new_schema.renamed_table");
assertQueryFails("DESC original_table_schema", "line 1:1: Table 'faker.default.original_table_schema' does not exist");
assertUpdate("DROP TABLE new_schema.renamed_table");
assertUpdate("DROP SCHEMA new_schema");
}
}

0 comments on commit 0f7a10a

Please sign in to comment.