agavra commented on code in PR #9832: URL: https://github.com/apache/pinot/pull/9832#discussion_r1030730187
########## pinot-query-planner/src/main/java/org/apache/pinot/query/planner/logical/IntExprRexVisitor.java: ########## @@ -0,0 +1,126 @@ +/** + * 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.pinot.query.planner.logical; + +import org.apache.calcite.rex.RexCall; +import org.apache.calcite.rex.RexCorrelVariable; +import org.apache.calcite.rex.RexDynamicParam; +import org.apache.calcite.rex.RexFieldAccess; +import org.apache.calcite.rex.RexInputRef; +import org.apache.calcite.rex.RexLiteral; +import org.apache.calcite.rex.RexLocalRef; +import org.apache.calcite.rex.RexNode; +import org.apache.calcite.rex.RexOver; +import org.apache.calcite.rex.RexPatternFieldRef; +import org.apache.calcite.rex.RexRangeRef; +import org.apache.calcite.rex.RexSubQuery; +import org.apache.calcite.rex.RexTableInputRef; +import org.apache.calcite.rex.RexVisitor; +import org.apache.calcite.sql.SqlOperator; +import org.apache.calcite.sql.fun.SqlStdOperatorTable; + + +/** + * {@code IntExprRexVisitor} will visit a {@link RexNode} that + * contains only integer literals and uses the {@link SqlStdOperatorTable#PLUS} + * operator and return the Integer that the expression represents. + */ +public class IntExprRexVisitor implements RexVisitor<Integer> { + + public static final IntExprRexVisitor INSTANCE = new IntExprRexVisitor(); + + private IntExprRexVisitor() { + } + + public Integer visit(RexNode in) { + if (in == null) { + return null; + } + + return in.accept(this); + } + + @Override + public Integer visitInputRef(RexInputRef inputRef) { + throw new UnsupportedOperationException(); + } + + @Override + public Integer visitLocalRef(RexLocalRef localRef) { + throw new UnsupportedOperationException(); + } + + @Override + public Integer visitLiteral(RexLiteral literal) { + return literal.getValueAs(Integer.class); + } + + @Override + public Integer visitCall(RexCall call) { + SqlOperator operator = call.getOperator(); + if (!(operator == SqlStdOperatorTable.PLUS)) { Review Comment: same as the above, this was actually left over from a refactor where I used the PLUS call to add the offset and fetch, but now I'm just resolving it in place. I'll just delete this class, it doesn't make much sense the way it is now. -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org