gortiz commented on code in PR #15225: URL: https://github.com/apache/pinot/pull/15225#discussion_r1993579054
########## pinot-query-planner/src/main/java/org/apache/pinot/calcite/rel/rules/PinotTableScanConverterRule.java: ########## @@ -0,0 +1,46 @@ +/** + * 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.calcite.rel.rules; + +import org.apache.calcite.plan.RelOptRule; +import org.apache.calcite.plan.RelOptRuleCall; +import org.apache.calcite.rel.core.TableScan; +import org.apache.calcite.rel.logical.LogicalTableScan; +import org.apache.calcite.tools.RelBuilderFactory; +import org.apache.pinot.calcite.rel.logical.PinotLogicalTableScan; + + +public class PinotTableScanConverterRule extends RelOptRule { + public static final PinotTableScanConverterRule INSTANCE = + new PinotTableScanConverterRule(PinotRuleUtils.PINOT_REL_FACTORY); + + public PinotTableScanConverterRule(RelBuilderFactory factory) { + super(operand(TableScan.class, none()), factory, null); + } + + @Override + public void onMatch(RelOptRuleCall call) { + TableScan tableScan = call.rel(0); + if (tableScan instanceof LogicalTableScan) { + call.transformTo(PinotLogicalTableScan.create(call.rel(0))); + } else if (!(tableScan instanceof PinotLogicalTableScan)) { + throw new IllegalStateException("Unknown table scan in PinotTableScanConverterRule: " + tableScan.getClass()); Review Comment: That has recently changed in https://github.com/apache/pinot/pull/15037. Now QueryException is an actual exception. The idea is that you can throw it anywhere during query processing and that way you can define the QueryErrorCode being used. That is not 100% true because there are still some paths that haven't been updated, but it is pretty safe to think that way. For example, here we know that the error is not related to the query but a bug in our code, so it could be marked as QueryErrorCode.INTERNAL instead of QueryErrorCode.QUERY_PLANNING. Anyway, it is completely valid to delegate the caller's responsibility to catch the exception and set the error code. -- 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