Copilot commented on code in PR #61700: URL: https://github.com/apache/doris/pull/61700#discussion_r2985568061
########## fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/CheckMatchExpressionTest.java: ########## @@ -0,0 +1,91 @@ +// 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.doris.nereids.rules.rewrite; + +import org.apache.doris.nereids.exceptions.AnalysisException; +import org.apache.doris.nereids.trees.expressions.Cast; +import org.apache.doris.nereids.trees.expressions.Expression; +import org.apache.doris.nereids.trees.expressions.MatchAny; +import org.apache.doris.nereids.trees.expressions.SlotReference; +import org.apache.doris.nereids.trees.expressions.literal.StringLiteral; +import org.apache.doris.nereids.trees.plans.logical.LogicalFilter; +import org.apache.doris.nereids.trees.plans.logical.LogicalOlapScan; +import org.apache.doris.nereids.types.StringType; +import org.apache.doris.nereids.types.VariantType; +import org.apache.doris.nereids.util.PlanConstructor; + +import com.google.common.collect.ImmutableSet; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Arrays; + +class CheckMatchExpressionTest { + + private CheckMatchExpression checkMatchExpression; + private Method checkChildrenMethod; + + @BeforeEach + void setUp() throws Exception { + checkMatchExpression = new CheckMatchExpression(); + checkChildrenMethod = CheckMatchExpression.class.getDeclaredMethod("checkChildren", LogicalFilter.class); + checkChildrenMethod.setAccessible(true); + } Review Comment: This unit test reaches into `CheckMatchExpression` via reflection to invoke the private `checkChildren` method. That makes the test brittle to harmless refactors (renames/signature changes) and bypasses the normal rule application path. Prefer exercising the rule via `PlanChecker.from(connectContext, plan).applyBottomUp(new CheckMatchExpression())` (or similar) so the test covers the public behavior and avoids reflective access. ########## regression-test/suites/inverted_index_p0/test_variant_empty_index_file.groovy: ########## @@ -57,6 +57,6 @@ suite("test_variant_empty_index_file", "p0") { sql """ select /*+ SET_VAR(enable_match_without_inverted_index = 0) */ * from ${tableName} where v match 'abcd'; """ } catch (Exception e) { log.info(e.getMessage()); - assertTrue(e.getMessage().contains("match_any not support execute_match")) + assertTrue(e.getMessage().contains("VARIANT root column does not support MATCH predicates")) Review Comment: The test currently relies on a try/catch but will silently pass if the query does *not* throw (i.e., the `sql` call succeeds). Please add an explicit failure after the `sql` call or convert this to the regression-test `test { ... exception "..." }` pattern so the test asserts the exception is mandatory. ########## regression-test/suites/search/test_disable_root_variant_match.groovy: ########## @@ -0,0 +1,73 @@ +// 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. + +suite("test_disable_root_variant_match", "p0") { + sql """ set enable_match_without_inverted_index = false """ + sql """ set enable_common_expr_pushdown = true """ + sql """ set default_variant_enable_typed_paths_to_sparse = false """ + sql """ set default_variant_enable_doc_mode = false """ + + sql "DROP TABLE IF EXISTS test_disable_root_variant_match_tbl" + + sql """ + CREATE TABLE test_disable_root_variant_match_tbl ( + `id` INT NOT NULL, Review Comment: In this suite, the table name is hard-coded in multiple SQL statements instead of being defined once (as other `regression-test/suites/search/*` suites do). Consider introducing a `def tableName = "..."` and using `${tableName}` throughout to reduce duplication and prevent accidental mismatches if the name changes. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
