zstan commented on code in PR #13311: URL: https://github.com/apache/ignite/pull/13311#discussion_r3513332207
########## modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/StatementChecker.java: ########## @@ -0,0 +1,194 @@ +/* + * 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.processors.query.calcite.planner; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Consumer; +import java.util.function.Supplier; +import org.apache.ignite.internal.processors.query.calcite.prepare.IgnitePlanner; +import org.apache.ignite.internal.processors.query.calcite.rel.IgniteRel; +import org.apache.ignite.internal.processors.query.calcite.schema.IgniteSchema; +import org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions; +import org.apache.ignite.internal.util.typedef.T2; + +import static org.apache.ignite.internal.processors.query.calcite.planner.AbstractPlannerTest.createTable; + +/** + * Constructs SQL statements checks. + * + * <pre> + * // Checks that plan validation throws no errors. + * new StatementChecker().sql("SELECT 1 + 1").ok(); + * + * // Checks that plan validation fails and a error message contains the given string. + * new StatementChecker().sql("SELECT").fails("Parse error"); + * + * </pre> + * + * <p>Default test name consists of expected result {@code ok()} if test should pass and {@code fail()} if it should fail, + * an SQL statement string, and dynamic parameters. + * <pre> + * new StatementChecker().sql("SELECT 1").ok(); // OK SELECT 1 + * new StatementChecker().sql("SELECT t").fails(); // ERR SELECT t + * new StatementChecker().sql("SELECT ?", 1).ok(); // OK SELECT 1, params=1 + * </pre> + * + * <p><b>Schema initialization</b> + * + * <pre> + * new StatementChecker() + * .table("t1", "int_col", Integer.class) + * .sql("SELECT int_col FROM t1") + * .ok(); + * </pre> + */ +public class StatementChecker { Review Comment: this checker will be used not only for dyn params checks and will be extended in future -- 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]
