You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "alex-plekhanov (via GitHub)" <gi...@apache.org> on 2024/11/26 14:44:38 UTC
[PR] IGNITE-23745 SQL Calcite: Add ability to extend SQL engine with new system functions/operators [ignite]
alex-plekhanov opened a new pull request, #11684:
URL: https://github.com/apache/ignite/pull/11684
Thank you for submitting the pull request to the Apache Ignite.
In order to streamline the review of the contribution
we ask you to ensure the following steps have been taken:
### The Contribution Checklist
- [ ] There is a single JIRA ticket related to the pull request.
- [ ] The web-link to the pull request is attached to the JIRA ticket.
- [ ] The JIRA ticket has the _Patch Available_ state.
- [ ] The pull request body describes changes that have been made.
The description explains _WHAT_ and _WHY_ was made instead of _HOW_.
- [ ] The pull request title is treated as the final commit message.
The following pattern must be used: `IGNITE-XXXX Change summary` where `XXXX` - number of JIRA issue.
- [ ] A reviewer has been mentioned through the JIRA comments
(see [the Maintainers list](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute#HowtoContribute-ReviewProcessandMaintainers))
- [ ] The pull request has been checked by the Teamcity Bot and
the `green visa` attached to the JIRA ticket (see [TC.Bot: Check PR](https://mtcga.gridgain.com/prs.html))
### Notes
- [How to Contribute](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute)
- [Coding abbreviation rules](https://cwiki.apache.org/confluence/display/IGNITE/Abbreviation+Rules)
- [Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Coding+Guidelines)
- [Apache Ignite Teamcity Bot](https://cwiki.apache.org/confluence/display/IGNITE/Apache+Ignite+Teamcity+Bot)
If you need any help, please email dev@ignite.apache.org or ask anу advice on http://asf.slack.com _#ignite_ channel.
--
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-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-23745 SQL Calcite: Add ability to extend SQL engine with new system functions/operators [ignite]
Posted by "Vladsz83 (via GitHub)" <gi...@apache.org>.
Vladsz83 commented on code in PR #11684:
URL: https://github.com/apache/ignite/pull/11684#discussion_r1861052024
##########
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/IgniteConvertletTable.java:
##########
@@ -53,6 +54,16 @@ private IgniteConvertletTable() {
addAlias(IgniteOwnSqlOperatorTable.LENGTH, SqlStdOperatorTable.CHAR_LENGTH);
}
+ /** {@inheritDoc} */
+ @Override public void registerOp(SqlOperator op, SqlRexConvertlet convertlet) {
+ super.registerOp(op, convertlet);
Review Comment:
If we want to extend a default operator, we should take in account overriding a default converter like `StandardConvertletTable#convertPlus(..)`.
--
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-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-23745 SQL Calcite: Add ability to extend SQL engine with new system functions/operators [ignite]
Posted by "Vladsz83 (via GitHub)" <gi...@apache.org>.
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-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-23745 SQL Calcite: Add ability to extend SQL engine with new system functions/operators [ignite]
Posted by "asfgit (via GitHub)" <gi...@apache.org>.
asfgit closed pull request #11684: IGNITE-23745 SQL Calcite: Add ability to extend SQL engine with new system functions/operators
URL: https://github.com/apache/ignite/pull/11684
--
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-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org