-
Notifications
You must be signed in to change notification settings - Fork 450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GLUTEN-8356][CORE][VL][CH] Make Iceberg code implement component API #8192
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.apache.gluten.component.CHIcebergComponent |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* 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.gluten.component | ||
|
||
import org.apache.gluten.backendsapi.clickhouse.CHBackend | ||
import org.apache.gluten.execution.OffloadIcebergScan | ||
import org.apache.gluten.extension.injector.Injector | ||
|
||
class CHIcebergComponent extends Component { | ||
override def name(): String = "clickhouse-iceberg" | ||
override def buildInfo(): Component.BuildInfo = | ||
Component.BuildInfo("ClickHouseIceberg", "N/A", "N/A", "N/A") | ||
override def dependencies(): Seq[Class[_ <: Component]] = classOf[CHBackend] :: Nil | ||
override def injectRules(injector: Injector): Unit = { | ||
OffloadIcebergScan.inject(injector) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.apache.gluten.component.VeloxIcebergComponent |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,10 @@ case class IcebergScanTransformer( | |
commonPartitionValues = commonPartitionValues | ||
) { | ||
|
||
protected[this] def supportsBatchScan(scan: Scan): Boolean = { | ||
IcebergScanTransformer.supportsBatchScan(scan) | ||
} | ||
|
||
override def filterExprs(): Seq[Expression] = pushdownFilters.getOrElse(Seq.empty) | ||
|
||
override lazy val getPartitionSchema: StructType = | ||
|
@@ -94,4 +98,8 @@ object IcebergScanTransformer { | |
commonPartitionValues = SparkShimLoader.getSparkShims.getCommonPartitionValues(batchScan) | ||
) | ||
} | ||
|
||
def supportsBatchScan(scan: Scan): Boolean = { | ||
scan.getClass.getName == "org.apache.iceberg.spark.source.SparkBatchQueryScan" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we just reference this class to get its name for comparison? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
cc @liujiayi771 if there are some better practices for this. |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* 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.gluten.execution | ||
|
||
import org.apache.gluten.extension.columnar.enumerated.RasOffload | ||
import org.apache.gluten.extension.columnar.heuristic.HeuristicTransform | ||
import org.apache.gluten.extension.columnar.offload.OffloadSingleNode | ||
import org.apache.gluten.extension.columnar.validator.Validators | ||
import org.apache.gluten.extension.injector.Injector | ||
|
||
import org.apache.spark.sql.execution.SparkPlan | ||
import org.apache.spark.sql.execution.datasources.v2.BatchScanExec | ||
|
||
case class OffloadIcebergScan() extends OffloadSingleNode { | ||
override def offload(plan: SparkPlan): SparkPlan = plan match { | ||
case scan: BatchScanExec if IcebergScanTransformer.supportsBatchScan(scan.scan) => | ||
IcebergScanTransformer(scan) | ||
case other => other | ||
} | ||
} | ||
|
||
object OffloadIcebergScan { | ||
def inject(injector: Injector): Unit = { | ||
// Inject legacy rule. | ||
injector.gluten.legacy.injectTransform { | ||
c => | ||
val offload = Seq(OffloadIcebergScan()) | ||
HeuristicTransform.Simple( | ||
Validators.newValidator(c.glutenConf, offload), | ||
offload | ||
) | ||
} | ||
|
||
// Inject RAS rule. | ||
injector.gluten.ras.injectRasRule { | ||
c => | ||
RasOffload.Rule( | ||
RasOffload.from[BatchScanExec](OffloadIcebergScan()), | ||
Validators.newValidator(c.glutenConf), | ||
Nil) | ||
} | ||
Comment on lines
+39
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code can be simplified in future PRs. |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems buildInfo is not necessary for component except
Backend
. Maybe, just use it forBackend
in future refactor.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, this part needs some cleanup.
BuildInfo
is not that general indeed. I'd like to see it totally decoupled with Component API somehow.