gortiz commented on code in PR #15225: URL: https://github.com/apache/pinot/pull/15225#discussion_r1989488015
########## pinot-query-planner/src/main/java/org/apache/pinot/calcite/rel/logical/PinotLogicalTableScan.java: ########## @@ -0,0 +1,54 @@ +/** + * 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.logical; + +import java.util.List; +import org.apache.calcite.plan.RelOptCluster; +import org.apache.calcite.plan.RelOptTable; +import org.apache.calcite.plan.RelTraitSet; +import org.apache.calcite.rel.RelNode; +import org.apache.calcite.rel.core.TableScan; +import org.apache.calcite.rel.hint.RelHint; +import org.apache.calcite.rel.logical.LogicalTableScan; + + +/** + * Same as {@link org.apache.calcite.rel.logical.LogicalTableScan}, except that it doesn't drop provided traits + * in the {@link #copy} method. + */ +public class PinotLogicalTableScan extends TableScan { + protected PinotLogicalTableScan(RelOptCluster cluster, RelTraitSet traitSet, List<RelHint> hints, RelOptTable table) { + super(cluster, traitSet, hints, table); + } + + @Override public RelNode withHints(List<RelHint> hintList) { Review Comment: nit: Usually, we don't write method annotations in the same line. In fact the copy method below includes the annotation in another line. ########## pinot-query-planner/src/main/java/org/apache/pinot/calcite/rel/rules/PinotImplicitTableHintRule.java: ########## @@ -47,23 +47,23 @@ private PinotImplicitTableHintRule(Config config) { public static PinotImplicitTableHintRule withWorkerManager(WorkerManager workerManager) { return new PinotImplicitTableHintRule(ImmutablePinotImplicitTableHintRule.Config.builder() - .operandSupplier(b0 -> b0.operand(LogicalTableScan.class).anyInputs()) + .operandSupplier(b0 -> b0.operand(PinotLogicalTableScan.class).anyInputs()) Review Comment: Given that we are changing this now, don't you think we should be using the generic TableScan here? Is there a reason we can only apply this (and other) rule to Logical tables? ########## 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: Can we use a QueryException here instead? -- 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