danny0405 commented on a change in pull request #2124: URL: https://github.com/apache/calcite/pull/2124#discussion_r479917650
########## File path: core/src/main/java/org/apache/calcite/util/Sarg.java ########## @@ -0,0 +1,132 @@ +/* + * 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.calcite.util; + +import org.apache.calcite.linq4j.Ord; +import org.apache.calcite.sql.fun.SqlStdOperatorTable; + +import com.google.common.collect.ImmutableRangeSet; +import com.google.common.collect.Range; +import com.google.common.collect.RangeSet; + +import java.util.Objects; +import java.util.function.BiConsumer; + +/** Set of values (or ranges) that are the target of a search. + * + * <p>The name is derived from <b>S</b>earch <b>arg</b>ument, an ancient + * concept in database implementation; see Access Path Selection in a Relational + * Database Management System — Selinger et al. 1979 or the + * "<a href="https://blog.acolyer.org/2016/01/04/access-path-selection/">morning + * paper summary</a>. + * + * <p>In RexNode, Sargs only occur as an </p> + * Review comment: as an what ? ########## File path: core/src/main/java/org/apache/calcite/rex/RexUtil.java ########## @@ -2833,4 +2898,77 @@ public boolean anyContain(Iterable<? extends RexNode> nodes) { } } + /** Converts a {@link Range} to a {@link RexNode} expression. + * + * @param <C> Value type */ + private static class RangeToRex<C extends Comparable<C>> + implements RangeSets.Consumer<C> { + private final List<RexNode> list; + private final RexBuilder rexBuilder; + private final RelDataType type; + private final SqlTypeName typeName; + private final RexNode ref; Review comment: The `typeName` is never used, and why we can trim a literal value there ? If people did write a `foo `, we should respect that. ########## File path: core/src/main/java/org/apache/calcite/sql/fun/SqlInOperator.java ########## @@ -60,7 +60,8 @@ */ SqlInOperator(SqlKind kind) { this(kind.sql, kind); - assert kind == SqlKind.IN || kind == SqlKind.NOT_IN; + assert kind == SqlKind.IN || kind == SqlKind.NOT_IN + || kind == SqlKind.DRUID_IN || kind == SqlKind.DRUID_NOT_IN; Review comment: Introduces Druid code here is not a good idea ~ ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected]
