Vladsz83 commented on code in PR #11684: URL: https://github.com/apache/ignite/pull/11684#discussion_r1861049190
########## modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/OperatorsExtensionIntegrationTest.java: ########## @@ -0,0 +1,160 @@ +/* + * 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.integration; + +import java.math.BigDecimal; +import java.sql.Timestamp; +import com.google.common.collect.ImmutableList; +import org.apache.calcite.adapter.enumerable.NullPolicy; +import org.apache.calcite.avatica.util.TimeUnitRange; +import org.apache.calcite.rex.RexBuilder; +import org.apache.calcite.rex.RexNode; +import org.apache.calcite.sql.SqlCall; +import org.apache.calcite.sql.SqlFunction; +import org.apache.calcite.sql.SqlFunctionCategory; +import org.apache.calcite.sql.SqlKind; +import org.apache.calcite.sql.fun.SqlStdOperatorTable; +import org.apache.calcite.sql.fun.SqlTrimFunction; +import org.apache.calcite.sql.parser.SqlParserPos; +import org.apache.calcite.sql.type.OperandTypes; +import org.apache.calcite.sql.type.ReturnTypes; +import org.apache.calcite.sql.type.SqlTypeName; +import org.apache.calcite.sql.validate.SqlValidator; +import org.apache.calcite.sql2rel.SqlRexContext; +import org.apache.calcite.sql2rel.SqlRexConvertlet; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.processors.query.calcite.exec.exp.RexImpTable; +import org.apache.ignite.internal.processors.query.calcite.prepare.IgniteConvertletTable; +import org.apache.ignite.internal.processors.query.calcite.prepare.IgniteSqlCallRewriteTable; +import org.apache.ignite.internal.processors.query.calcite.sql.fun.IgniteOwnSqlOperatorTable; +import org.apache.ignite.plugin.AbstractTestPluginProvider; +import org.apache.ignite.plugin.PluginContext; +import org.junit.Test; + +/** */ +public class OperatorsExtensionIntegrationTest extends AbstractBasicIntegrationTest { + /** */ + private static final SqlFunction SUBSTR = + new SqlFunction( + "SUBSTR", + SqlKind.OTHER_FUNCTION, + ReturnTypes.ARG0_NULLABLE_VARYING, + null, + OperandTypes.STRING_INTEGER_INTEGER, + SqlFunctionCategory.STRING); + + /** */ + private static final SqlFunction TRUNC = + new SqlFunction( + "TRUNC", + SqlKind.OTHER_FUNCTION, + ReturnTypes.ARG0_OR_EXACT_NO_SCALE, + null, + OperandTypes.TIMESTAMP, + SqlFunctionCategory.TIMEDATE); + + /** */ + private static final SqlFunction TO_NUMBER = + new SqlFunction( + "TO_NUMBER", + SqlKind.OTHER_FUNCTION, + opBinding -> opBinding.getTypeFactory().createSqlType(SqlTypeName.DECIMAL), + null, + OperandTypes.STRING, + SqlFunctionCategory.NUMERIC); + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + return super.getConfiguration(igniteInstanceName) + .setPluginProviders(new AbstractTestPluginProvider() { + @Override public String name() { + return "Test operators extension plugin"; + } + + @Override public void start(PluginContext ctx) { + IgniteOwnSqlOperatorTable.instance().register(SUBSTR); Review Comment: If we want to extend a default operator, `IgniteOwnSqlOperatorTable` should go first in `FrameworkConfig` (`CalciteQueryProcessor#FRAMEWORK_CONFIG`). Otherwise, filtering operator overload by strict operands types isn't reliable. Operand types might not be consedered in `SqlUtil#filterRoutinesByParameterTypeAndName()` -- 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: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org