Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

[NSE-540] enable reuse subquery #543

Merged
merged 4 commits into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,39 +66,27 @@ case class ColumnarHashAggregateExec(
aggregateExpressions: Seq[AggregateExpression],
aggregateAttributes: Seq[Attribute],
initialInputBufferOffset: Int,
var resultExpressions: Seq[NamedExpression],
resultExpressions: Seq[NamedExpression],
child: SparkPlan)
extends BaseAggregateExec
with ColumnarCodegenSupport
with AliasAwareOutputPartitioning {
with ColumnarCodegenSupport {

val sparkConf = sparkContext.getConf
val numaBindingInfo = GazellePluginConfig.getConf.numaBindingInfo
override def supportsColumnar = true

var resAttributes: Seq[Attribute] = resultExpressions.map(_.toAttribute)
if (aggregateExpressions != null && aggregateExpressions.nonEmpty) {
aggregateExpressions.head.mode match {
case Partial =>
// To fix the expression ids in result expressions being different with those from
// inputAggBufferAttributes, in Partial Aggregate,
// result attributes are recalculated to set the result expressions.
resAttributes = groupingExpressions.map(_.toAttribute) ++
aggregateExpressions.flatMap(_.aggregateFunction.inputAggBufferAttributes)
resultExpressions = resAttributes
case _ =>
}
}

override lazy val allAttributes: AttributeSeq =
child.output ++ aggregateBufferAttributes ++ aggregateAttributes ++
aggregateExpressions.flatMap(_.aggregateFunction.inputAggBufferAttributes)

// Members declared in org.apache.spark.sql.execution.AliasAwareOutputPartitioning
override protected def outputExpressions: Seq[NamedExpression] = resultExpressions

// Members declared in org.apache.spark.sql.execution.CodegenSupport
protected def doProduce(ctx: CodegenContext): String = throw new UnsupportedOperationException()

// Members declared in org.apache.spark.sql.catalyst.plans.QueryPlan
override def output: Seq[Attribute] = resAttributes

// Members declared in org.apache.spark.sql.execution.SparkPlan
protected override def doExecute()
: org.apache.spark.rdd.RDD[org.apache.spark.sql.catalyst.InternalRow] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,6 @@ object ColumnarExpressionConverter extends Logging {
columnarDivide,
expr)
}
case oaps: com.intel.oap.expression.ColumnarScalarSubquery =>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: this removes columnar subquery support, will fix this in another patch

oaps
case s: org.apache.spark.sql.execution.ScalarSubquery =>
logInfo(s"${expr.getClass} ${expr} is supported, no_cal is $check_if_no_calculation.")
new ColumnarScalarSubquery(s)
case c: Concat =>
check_if_no_calculation = false
logInfo(s"${expr.getClass} ${expr} is supported, no_cal is $check_if_no_calculation.")
Expand Down