comphead commented on code in PR #2758: URL: https://github.com/apache/datafusion-comet/pull/2758#discussion_r2512010347
########## docs/source/contributor-guide/adding_a_new_operator.md: ########## @@ -0,0 +1,354 @@ +<!--- + 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. +--> + +# Adding a New Operator + +This guide explains how to add support for a new Spark physical operator in Apache DataFusion Comet. + +## Overview + +`CometExecRule` is responsible for replacing Spark operators with Comet operators. There are different approaches to implementing Comet operators depending on where they execute and how they integrate with the native execution engine. + +### Types of Comet Operators + +#### 1. Comet Native Operators + +These operators run entirely in native Rust code and are the primary way to accelerate Spark workloads. For native operators, `CometExecRule` delegates to `QueryPlanSerde.operator2Proto` to: + +- Check if the operator is enabled or disabled via configuration +- Validate if the operator can be supported +- Tag the operator with fallback reasons if conversion fails +- Serialize the operator to protobuf for native execution + +Examples: `ProjectExec`, `FilterExec`, `SortExec`, `HashAggregateExec`, `SortMergeJoinExec` + +#### 2. Comet JVM Operators + +These operators run in the JVM but are part of the Comet execution path. For JVM operators, all checks happen in `CometExecRule` rather than `QueryPlanSerde`, because they don't need protobuf serialization. + +Examples: `CometBroadcastExchangeExec`, `CometShuffleExchangeExec` + +#### 3. Comet Sinks + +Some operators serve as "sinks" or entry points for native execution, meaning they can be leaf nodes that feed data into native execution blocks. Review Comment: Thanks for highlighting this -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
