lowka commented on code in PR #5682: URL: https://github.com/apache/ignite-3/pull/5682#discussion_r2063807044
########## modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/sql/fun/SqlDateTimeIntervalTypeChecker.java: ########## @@ -0,0 +1,130 @@ +/* + * 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.sql.engine.sql.fun; + +import static org.apache.ignite.internal.lang.IgniteStringFormatter.format; + +import java.util.Map; +import java.util.Set; +import org.apache.calcite.rel.type.RelDataType; +import org.apache.calcite.sql.SqlCallBinding; +import org.apache.calcite.sql.SqlOperandCountRange; +import org.apache.calcite.sql.SqlOperator; +import org.apache.calcite.sql.type.SqlOperandCountRanges; +import org.apache.calcite.sql.type.SqlOperandTypeChecker; +import org.apache.calcite.sql.type.SqlTypeName; +import org.apache.calcite.sql.type.SqlTypeUtil; + +/** + * Type checking strategy for DATETIME + INTERVAL / INTERVAL + DATETIME / DATETIME - INTERVAL operations. + * This strategy only permits operands in which all fields of interval operand's type can be included in datetime operand's type. Examples: + * <ul> + * <li>it permits {@code TIME op DAY TO SECOND INTERVALS} but does not allow {@code TIME op INTERVAL_MONTHS}, + * because the time type consists of hours, minutes, seconds. The day component is ignored.</li> + * <li>it permits {@code DATE op INTERVAL (any interval type)}, because the date type includes both years, month, and days. + * and that a sub-day interval is converted to day intervals e.g. {@code 25 HOURS} is {@code 1 DAY}, + * {@code 5 SECONDS} = {@code 0 DAYS}, {@code 1440 MINUTES} is {@code 1 DAY}. + * </li> + * <li>it permits {@code TIMESTAMP op INTERVAL (any interval type)}, because the timestamp type consists of fields from both the date + * and the time types.</li> + * </ul> + */ +public class SqlDateTimeIntervalTypeChecker implements SqlOperandTypeChecker { + + private static final Map<SqlTypeName, Set<SqlTypeName>> MATCHING_INTERVAL_TYPES = Map.of( + SqlTypeName.TIME, Set.of( + SqlTypeName.INTERVAL_DAY, Review Comment: Thanks. Fixed. -- 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