Skip to content

Commit

Permalink
use createUnsafe for ProjectExec
Browse files Browse the repository at this point in the history
  • Loading branch information
dcoliversun committed Sep 19, 2024
1 parent 4303560 commit cddc291
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class CHSparkPlanExecApi extends SparkPlanExecApi with Logging {

override def genProjectExecTransformer(
projectList: Seq[NamedExpression],
child: SparkPlan): ProjectExecTransformerBase = {
child: SparkPlan): ProjectExecTransformer = {
def processProjectExecTransformer(projectList: Seq[NamedExpression]): Seq[NamedExpression] = {
// When there is a MergeScalarSubqueries which will create the named_struct with the
// same name, looks like {'bloomFilter', BF1, 'bloomFilter', BF2}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,6 @@ class VeloxSparkPlanExecApi extends SparkPlanExecApi {
FilterExecTransformer(condition, child)
}

override def genProjectExecTransformer(
projectList: Seq[NamedExpression],
child: SparkPlan): ProjectExecTransformerBase = {
ProjectExecTransformer(projectList, child)
}

/** Generate HashAggregateExecTransformer. */
override def genHashAggregateExecTransformer(
requiredChildDistributionExpressions: Option[Seq[Expression]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ case class DeltaProjectExecTransformer(projectList: Seq[NamedExpression], child:
Alias(
child = CaseWhen(newBranches, newElseValue),
name = alias.name
)()
)(alias.exprId)

case _ =>
alias
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ trait SparkPlanExecApi {

def genProjectExecTransformer(
projectList: Seq[NamedExpression],
child: SparkPlan): ProjectExecTransformerBase
child: SparkPlan): ProjectExecTransformer =
ProjectExecTransformer.createUnsafe(projectList, child)

/** Generate HashAggregateExecTransformer. */
def genHashAggregateExecTransformer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.gluten.execution

import org.apache.gluten.backendsapi.BackendsApiManager

import org.apache.spark.sql.catalyst.expressions.NamedExpression
import org.apache.spark.sql.execution.SparkPlan

Expand All @@ -28,6 +30,10 @@ case class ProjectExecTransformer(projectList: Seq[NamedExpression], child: Spar

object ProjectExecTransformer {

def apply(projectList: Seq[NamedExpression], child: SparkPlan): ProjectExecTransformer = {
BackendsApiManager.getSparkPlanExecApiInstance.genProjectExecTransformer(projectList, child)
}

// Directly creating a project transformer may not be considered safe since some backends, E.g.,
// Clickhouse may require to intercept the instantiation procedure.
def createUnsafe(projectList: Seq[NamedExpression], child: SparkPlan): ProjectExecTransformer =
Expand Down

0 comments on commit cddc291

Please sign in to comment.