devozerov commented on a change in pull request #2371:
URL: https://github.com/apache/calcite/pull/2371#discussion_r593859186
##########
File path: server/src/test/java/org/apache/calcite/test/ServerTest.java
##########
@@ -532,4 +533,26 @@ static Connection connect() throws SQLException {
}
}
}
+
+ @Test public void testDropWithFullyQualifiedNameWhenSchemaDoesntExist()
throws Exception {
+ try (Connection c = connect();
+ Statement s = c.createStatement()) {
+ checkDropWithFullyQualifiedNameWhenSchemaDoesntExist(s, "schema",
"Schema");
+ checkDropWithFullyQualifiedNameWhenSchemaDoesntExist(s, "table",
"Table");
+ checkDropWithFullyQualifiedNameWhenSchemaDoesntExist(s, "materialized
view", "Table");
+ checkDropWithFullyQualifiedNameWhenSchemaDoesntExist(s, "view", "View");
+ checkDropWithFullyQualifiedNameWhenSchemaDoesntExist(s, "type", "Type");
+ checkDropWithFullyQualifiedNameWhenSchemaDoesntExist(s, "function",
"Function");
+ }
+ }
+
+ private void checkDropWithFullyQualifiedNameWhenSchemaDoesntExist(
+ Statement statement, String objectType, String objectTypeInErrorMessage)
throws Exception {
+ SQLException e = assertThrows(SQLException.class, () ->
+ statement.execute("drop " + objectType + " s.o"),
+ "expected error because the object doesn't exist");
Review comment:
The description of the test case is not necessarily the same as the
error message. The test case checks the behavior of the `DROP` command when the
schema doesn't exist. If the schema doesn't exist, any object inside the schema
doesn't exist either. Currently, Apache Calcite throws errors like `table not
found` for such cases. Therefore, the current assertion message is correct - it
expresses the same problem as we show to the user.
As I mentioned before, perhaps this is not the correct semantics. For
example, Postgres will throw `schema not found`, which I think is a better
error description. But this is not the concern of the given PR.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]