Au-Miner commented on code in PR #28387: URL: https://github.com/apache/flink/pull/28387#discussion_r3496772390
########## flink-table/flink-sql-parser/src/test/java/org/apache/flink/sql/parser/FlinkSqlParserTestBase.java: ########## @@ -0,0 +1,79 @@ +/* + * 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.flink.sql.parser; + +import org.apache.flink.sql.parser.error.SqlValidateException; +import org.apache.flink.sql.parser.impl.FlinkSqlParserImpl; + +import org.apache.calcite.sql.SqlNode; +import org.apache.calcite.sql.parser.SqlParserFixture; +import org.hamcrest.BaseMatcher; +import org.hamcrest.Description; +import org.hamcrest.TypeSafeDiagnosingMatcher; +import org.junit.jupiter.api.parallel.Execution; + +import static org.junit.jupiter.api.parallel.ExecutionMode.CONCURRENT; + +/** Base class providing shared parser test utilities for Flink SQL parser tests. */ +@Execution(CONCURRENT) +abstract class FlinkSqlParserTestBase { Review Comment: The split FlinkSqlParserCalciteTest has specifically inherited SqlParserTest and is responsible for running all Calcite native tests collectively. If FlinkSqlParserTestBase were also made to inherit SqlParserTest, then each subclass such as FlinkSqlParserCatalogTest and FlinkSqlParserMiscTest would have to rerun hundreds of Calcite tests, resulting in a significant amount of duplication. ########## flink-table/flink-sql-parser/src/test/java/org/apache/flink/sql/parser/FlinkSqlParserCatalogTest.java: ########## @@ -0,0 +1,208 @@ +/* + * 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.flink.sql.parser; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; + +import java.util.Locale; + +import static org.junit.jupiter.api.parallel.ExecutionMode.CONCURRENT; + +/** Catalog and database parser tests. */ +@Execution(CONCURRENT) +class FlinkSqlParserCatalogTest extends FlinkSqlParserTestBase { + + @Test + void testShowCatalogs() { + sql("show catalogs").ok("SHOW CATALOGS"); + + sql("show catalogs like '%'").ok("SHOW CATALOGS LIKE '%'"); + sql("show catalogs not like '%'").ok("SHOW CATALOGS NOT LIKE '%'"); + + sql("show catalogs ilike '%'").ok("SHOW CATALOGS ILIKE '%'"); + sql("show catalogs not ilike '%'").ok("SHOW CATALOGS NOT ILIKE '%'"); + + sql("show catalogs ^likes^").fails("(?s).*Encountered \"likes\" at line 1, column 15.\n.*"); + sql("show catalogs not ^likes^") + .fails("(?s).*Encountered \"likes\" at line 1, column 19" + ".\n" + ".*"); + sql("show catalogs ^ilikes^") + .fails("(?s).*Encountered \"ilikes\" at line 1, column 15.\n.*"); + sql("show catalogs not ^ilikes^") + .fails("(?s).*Encountered \"ilikes\" at line 1, column 19" + ".\n" + ".*"); + } + + @Test + void testShowCurrentCatalog() { + sql("show current catalog").ok("SHOW CURRENT CATALOG"); + } + + @Test + void testDescribeCatalog() { + sql("describe catalog a").ok("DESCRIBE CATALOG `A`"); + sql("describe catalog extended a").ok("DESCRIBE CATALOG EXTENDED `A`"); + + sql("desc catalog a").ok("DESCRIBE CATALOG `A`"); + sql("desc catalog extended a").ok("DESCRIBE CATALOG EXTENDED `A`"); + } + + @Test + void testAlterCatalog() { + sql("alter catalog a set ('k1'='v1', 'k2'='v2')") + .ok("ALTER CATALOG `A` SET (\n" + " 'k1' = 'v1',\n" + " 'k2' = 'v2'\n" + ")"); + sql("alter catalog a reset ('k1')").ok("ALTER CATALOG `A` RESET (\n" + " 'k1'\n" + ")"); + sql("alter catalog a comment 'comment1'").ok("ALTER CATALOG `A` COMMENT 'comment1'"); + } + + // END Review Comment: After analyzing the commit history, it was found that this is a leftover comment. FLINK-20873 introduced the "// begin - end" notation, but subsequently deleted the comment for "begin", leaving the comment for "end" here. I have already deleted it -- 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]
