ankitsultana commented on code in PR #15225: URL: https://github.com/apache/pinot/pull/15225#discussion_r1989978634
########## 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: The thrown exception here would get caught in `MultiStageBrokerRequestHandler` which will set the `QUERY_PLANNING_ERROR_CODE`. I think the idea behind this approach is that the planner etc. can throw whatever exception seems right in their context (e.g. illegal state in this case), and the broker request handler will convert it to a structured form with an error code. I don't think QueryException is used for throwing. It is mainly used for getting a ProcessingException which shows up nicely in broker response (we should ideally make the contract explicit in QueryException javadocs) <img width="898" alt="image" src="https://github.com/user-attachments/assets/8d53ea31-fd2c-4e89-81ca-3d7083e8c442" /> -- 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