Vladsz83 commented on code in PR #11467: URL: https://github.com/apache/ignite/pull/11467#discussion_r1735126817
########## modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserViewSelfTest.java: ########## @@ -0,0 +1,129 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.sql; + +import org.apache.ignite.internal.sql.command.SqlCreateViewCommand; +import org.apache.ignite.internal.sql.command.SqlDropViewCommand; +import org.junit.Test; + +/** + * Tests for SQL parser: CREATE VIEW. + */ +public class SqlParserViewSelfTest extends SqlParserAbstractSelfTest { + /** + * Tests for CREATE VIEW command. + */ + @Test + public void testCreateView() { + parseValidateCreate("CREATE VIEW test AS SELECT * FROM test2", + null, "TEST", "SELECT * FROM test2", false); + + parseValidateCreate("CREATE OR REPLACE VIEW test AS SELECT * FROM test2", + null, "TEST", "SELECT * FROM test2", true); + + parseValidateCreate("CREATE VIEW test.test AS SELECT * FROM test2", + "TEST", "TEST", "SELECT * FROM test2", false); + + parseValidateCreate("CREATE VIEW \"test\" AS SELECT * FROM test2", + null, "test", "SELECT * FROM test2", false); + + parseValidateCreate("CREATE VIEW \"test\".\"test\" AS SELECT * FROM test2", + "test", "test", "SELECT * FROM test2", false); + + parseValidateCreate("CREATE VIEW \"te.st\".\"te.st\" AS SELECT * FROM test2", + "te.st", "te.st", "SELECT * FROM test2", false); + + parseValidateCreate("CREATE VIEW test.\"test\" AS SELECT * FROM test2", + "TEST", "test", "SELECT * FROM test2", false); + + parseValidateCreate("CREATE VIEW test AS SELECT * FROM test2;", + null, "TEST", "SELECT * FROM test2", false); + + parseValidateCreate("CREATE VIEW test AS SELECT * FROM test2 ;", + null, "TEST", "SELECT * FROM test2", false); + + parseValidateCreate("CREATE VIEW test AS SELECT * FROM test2; SELECT * FROM test", + null, "TEST", "SELECT * FROM test2", false); + + assertParseError(null, "CREATE VIEW test.test.test AS SELECT * FROM test2", + "Unexpected token: \".\" (expected: \"AS\")"); + + assertParseError(null, "CREATE VIEW test AS UNEXPECTED", + "Unexpected token: \"UNEXPECTED\" (expected: \"SELECT\")"); + + assertParseError(null, "CREATE VIEW test AS \"SELECT * FROM test2\"", + "Unexpected token: \"SELECT * FROM test2\" (expected: \"SELECT\")"); + + assertParseError(null, "CREATE OR REPLACE INDEX test", + "Unexpected token: \"INDEX\" (expected: \"VIEW\")"); + + assertParseError(null, "CREATE OR DROP VIEW test AS SELECT * FROM test2", + "Unexpected token: \"DROP\" (expected: \"REPLACE\")"); + } + + /** + * Tests for DROP VIEW command. Review Comment: 'Test' or remove 'for' -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
