Skip to content
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 @@ -22,7 +22,7 @@ package org.apache.spark.sql.comet
import org.apache.spark.TaskContext
import org.apache.spark.rdd.{ParallelCollectionRDD, RDD}
import org.apache.spark.serializer.Serializer
import org.apache.spark.sql.catalyst.expressions.{Attribute, NamedExpression, SortOrder}
import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeSet, NamedExpression, SortOrder}
import org.apache.spark.sql.catalyst.util.truncatedString
import org.apache.spark.sql.comet.execution.shuffle.{CometShuffledBatchRDD, CometShuffleExchangeExec}
import org.apache.spark.sql.execution.{SparkPlan, TakeOrderedAndProjectExec, UnaryExecNode, UnsafeRowSerializer}
Expand Down Expand Up @@ -98,10 +98,15 @@ case class CometTakeOrderedAndProjectExec(
child: SparkPlan)
extends CometExec
with UnaryExecNode {

override def producedAttributes: AttributeSet = outputSet ++ AttributeSet(projectList)

private lazy val writeMetrics =
SQLShuffleWriteMetricsReporter.createShuffleWriteMetrics(sparkContext)

private lazy val readMetrics =
SQLShuffleReadMetricsReporter.createShuffleReadMetrics(sparkContext)

override lazy val metrics: Map[String, SQLMetric] = Map(
"dataSize" -> SQLMetrics.createSizeMetric(sparkContext, "data size"),
"numPartitions" -> SQLMetrics.createMetric(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
WholeStageCodegen (1)
CometColumnarToRow
InputAdapter
CometTakeOrderedAndProject [c_last_name,c_first_name,substr(s_city, 1, 30),ss_ticket_number,amt,profit,s_city]
CometTakeOrderedAndProject [s_city] [c_last_name,c_first_name,substr(s_city, 1, 30),ss_ticket_number,amt,profit]
CometProject [c_last_name,c_first_name,substr(s_city, 1, 30),ss_ticket_number,amt,profit,s_city]
CometBroadcastHashJoin [ss_ticket_number,ss_customer_sk,s_city,amt,profit,c_customer_sk,c_first_name,c_last_name]
CometHashAggregate [ss_addr_sk,sum,sum] [ss_ticket_number,ss_customer_sk,s_city,amt,profit,sum(UnscaledValue(ss_coupon_amt)),sum(UnscaledValue(ss_net_profit))]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
WholeStageCodegen (1)
CometColumnarToRow
InputAdapter
CometTakeOrderedAndProject [c_last_name,c_first_name,substr(s_city, 1, 30),ss_ticket_number,amt,profit,s_city]
CometTakeOrderedAndProject [s_city] [c_last_name,c_first_name,substr(s_city, 1, 30),ss_ticket_number,amt,profit]
CometProject [c_last_name,c_first_name,substr(s_city, 1, 30),ss_ticket_number,amt,profit,s_city]
CometBroadcastHashJoin [ss_ticket_number,ss_customer_sk,s_city,amt,profit,c_customer_sk,c_first_name,c_last_name]
CometHashAggregate [ss_addr_sk,sum,sum] [ss_ticket_number,ss_customer_sk,s_city,amt,profit,sum(UnscaledValue(ss_coupon_amt)),sum(UnscaledValue(ss_net_profit))]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
WholeStageCodegen (1)
CometColumnarToRow
InputAdapter
CometTakeOrderedAndProject [customer_id,customername,c_customer_id]
CometTakeOrderedAndProject [c_customer_id] [customer_id,customername]
CometProject [c_last_name,c_first_name] [customer_id,customername,c_customer_id]
CometBroadcastHashJoin [c_customer_id,c_first_name,c_last_name,cd_demo_sk,sr_cdemo_sk]
CometBroadcastExchange [c_customer_id,c_first_name,c_last_name,cd_demo_sk] #1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
WholeStageCodegen (1)
CometColumnarToRow
InputAdapter
CometTakeOrderedAndProject [customer_id,customername,c_customer_id]
CometTakeOrderedAndProject [c_customer_id] [customer_id,customername]
CometProject [c_last_name,c_first_name] [customer_id,customername,c_customer_id]
CometBroadcastHashJoin [c_customer_id,c_first_name,c_last_name,cd_demo_sk,sr_cdemo_sk]
CometBroadcastExchange [c_customer_id,c_first_name,c_last_name,cd_demo_sk] #1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
WholeStageCodegen (1)
CometColumnarToRow
InputAdapter
CometTakeOrderedAndProject [customer_id,customername,c_customer_id]
CometTakeOrderedAndProject [c_customer_id] [customer_id,customername]
CometProject [c_last_name,c_first_name] [customer_id,customername,c_customer_id]
CometBroadcastHashJoin [c_customer_id,c_first_name,c_last_name,cd_demo_sk,sr_cdemo_sk]
CometBroadcastExchange [c_customer_id,c_first_name,c_last_name,cd_demo_sk] #1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
WholeStageCodegen (1)
CometColumnarToRow
InputAdapter
CometTakeOrderedAndProject [customer_id,customername,c_customer_id]
CometTakeOrderedAndProject [c_customer_id] [customer_id,customername]
CometProject [c_last_name,c_first_name] [customer_id,customername,c_customer_id]
CometBroadcastHashJoin [c_customer_id,c_first_name,c_last_name,cd_demo_sk,sr_cdemo_sk]
CometBroadcastExchange [c_customer_id,c_first_name,c_last_name,cd_demo_sk] #1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
WholeStageCodegen (1)
CometColumnarToRow
InputAdapter
CometTakeOrderedAndProject [c_last_name,c_first_name,substr(s_city, 1, 30),ss_ticket_number,amt,profit,s_city]
CometTakeOrderedAndProject [s_city] [c_last_name,c_first_name,substr(s_city, 1, 30),ss_ticket_number,amt,profit]
CometProject [c_last_name,c_first_name,substr(s_city, 1, 30),ss_ticket_number,amt,profit,s_city]
CometBroadcastHashJoin [ss_ticket_number,ss_customer_sk,s_city,amt,profit,c_customer_sk,c_first_name,c_last_name]
CometHashAggregate [ss_addr_sk,sum,sum] [ss_ticket_number,ss_customer_sk,s_city,amt,profit,sum(UnscaledValue(ss_coupon_amt)),sum(UnscaledValue(ss_net_profit))]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
WholeStageCodegen (1)
CometColumnarToRow
InputAdapter
CometTakeOrderedAndProject [c_last_name,c_first_name,substr(s_city, 1, 30),ss_ticket_number,amt,profit,s_city]
CometTakeOrderedAndProject [s_city] [c_last_name,c_first_name,substr(s_city, 1, 30),ss_ticket_number,amt,profit]
CometProject [c_last_name,c_first_name,substr(s_city, 1, 30),ss_ticket_number,amt,profit,s_city]
CometBroadcastHashJoin [ss_ticket_number,ss_customer_sk,s_city,amt,profit,c_customer_sk,c_first_name,c_last_name]
CometHashAggregate [ss_addr_sk,sum,sum] [ss_ticket_number,ss_customer_sk,s_city,amt,profit,sum(UnscaledValue(ss_coupon_amt)),sum(UnscaledValue(ss_net_profit))]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
WholeStageCodegen (1)
CometColumnarToRow
InputAdapter
CometTakeOrderedAndProject [customer_id,customername,c_customer_id]
CometTakeOrderedAndProject [c_customer_id] [customer_id,customername]
CometProject [c_last_name,c_first_name] [customer_id,customername,c_customer_id]
CometBroadcastHashJoin [c_customer_id,c_first_name,c_last_name,cd_demo_sk,sr_cdemo_sk]
CometBroadcastExchange [c_customer_id,c_first_name,c_last_name,cd_demo_sk] #1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
WholeStageCodegen (1)
CometColumnarToRow
InputAdapter
CometTakeOrderedAndProject [customer_id,customername,c_customer_id]
CometTakeOrderedAndProject [c_customer_id] [customer_id,customername]
CometProject [c_last_name,c_first_name] [customer_id,customername,c_customer_id]
CometBroadcastHashJoin [c_customer_id,c_first_name,c_last_name,cd_demo_sk,sr_cdemo_sk]
CometBroadcastExchange [c_customer_id,c_first_name,c_last_name,cd_demo_sk] #1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
WholeStageCodegen (1)
CometColumnarToRow
InputAdapter
CometTakeOrderedAndProject [state,cnt,ca_state]
CometTakeOrderedAndProject [ca_state] [state,cnt]
CometFilter [state,cnt,ca_state]
CometHashAggregate [count] [state,cnt,ca_state,count(1)]
CometExchange [ca_state] #1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
WholeStageCodegen (1)
CometColumnarToRow
InputAdapter
CometTakeOrderedAndProject [state,cnt,ca_state]
CometTakeOrderedAndProject [ca_state] [state,cnt]
CometFilter [state,cnt,ca_state]
CometHashAggregate [count] [state,cnt,ca_state,count(1)]
CometExchange [ca_state] #1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
WholeStageCodegen (1)
CometColumnarToRow
InputAdapter
CometTakeOrderedAndProject [state,cnt,ca_state]
CometTakeOrderedAndProject [ca_state] [state,cnt]
CometFilter [state,cnt,ca_state]
CometHashAggregate [count] [state,cnt,ca_state,count(1)]
CometExchange [ca_state] #1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
WholeStageCodegen (1)
CometColumnarToRow
InputAdapter
CometTakeOrderedAndProject [state,cnt,ca_state]
CometTakeOrderedAndProject [ca_state] [state,cnt]
CometFilter [state,cnt,ca_state]
CometHashAggregate [count] [state,cnt,ca_state,count(1)]
CometExchange [ca_state] #1
Expand Down
24 changes: 24 additions & 0 deletions spark/src/test/scala/org/apache/spark/sql/CometTestBase.scala
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,8 @@ abstract class CometTestBase
s"plan: ${new ExtendedExplainInfo().generateExtendedInfo(plan)}")
case _ =>
}

checkPlanNotMissingInput(plan)
}

protected def findFirstNonCometOperator(
Expand All @@ -406,6 +408,28 @@ abstract class CometTestBase
None
}

// checks the plan node has no missing inputs
// such nodes represented in plan with exclamation mark !
// example: !CometWindowExec
protected def checkPlanNotMissingInput(plan: SparkPlan): Unit = {
def hasMissingInput(node: SparkPlan): Boolean = {
node.missingInput.nonEmpty && node.children.nonEmpty
}

val isCometNode = plan.nodeName.startsWith("Comet")

if (isCometNode && hasMissingInput(plan)) {
assert(
false,
s"Plan node `${plan.nodeName}` has invalid missingInput: ${plan.missingInput}")
}

// Otherwise recursively check children
plan.children.foreach { child =>
checkPlanNotMissingInput(child)
}
}

private def checkPlanContains(plan: SparkPlan, includePlans: Class[_]*): Unit = {
includePlans.foreach { case planClass =>
if (plan.find(op => planClass.isAssignableFrom(op.getClass)).isEmpty) {
Expand Down
Loading