You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "parthchandra (via GitHub)" <gi...@apache.org> on 2024/06/15 00:32:28 UTC

[PR] fix: Improve error "BroadcastExchange is not supported" [datafusion-comet]

parthchandra opened a new pull request, #577:
URL: https://github.com/apache/datafusion-comet/pull/577

   ## Which issue does this PR close?
   
   Closes #568 
   
   ## Rationale for this change
   
   The message is confusing (and incorrect)
   
   ## What changes are included in this PR?
   Does not add any explain info for BroadcastExchange plan nodes during planning. Explain plan information is added when a native broadcast exchange is added (usually in a parent node)
   Also improves the messages slightly for SortMergeJoin and BroadcastJoin.
   
   ## How are these changes tested?
   
   Rerun queries list output for TPC-H and TPC-DS


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: Improve error "BroadcastExchange is not supported" [datafusion-comet]

Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on code in PR #577:
URL: https://github.com/apache/datafusion-comet/pull/577#discussion_r1643557256


##########
spark/inspections/CometTPCHQueriesList-results.txt:
##########
@@ -1,133 +1,133 @@
-Query: q1 TPCH Snappy. Comet Exec: Enabled (CometHashAggregate, CometProject)
+Query: q1 TPCH Snappy. Comet Exec: Enabled (CometHashAggregate, CometFilter, CometProject)
 Query: q1 TPCH Snappy: ExplainInfo:
 Comet shuffle is not enabled: spark.sql.adaptive.coalescePartitions.enabled is enabled and spark.comet.shuffle.enforceMode.enabled is not enabled
 
 Query: q2 TPCH Snappy. Comet Exec: Enabled (CometFilter, CometProject)
 Query: q2 TPCH Snappy: ExplainInfo:
-BroadcastExchange is not supported
+BroadcastHashJoin is not enabled because not all child plans are native 

Review Comment:
   Thanks the detailed write-up @parthchandra. I am really looking for query specifics, which I can see is is a different use case.
   
   The way we did this in Spark RAPIDS was to store the info on the specific node and then be able to view the query tree in the nested format similar to the example you posted above.
   
   If we stored the info on the specific nodes, I think we could still output the same summary we currently have by walking through the plan and extracting the individual reasons (and removing duplicates) and this would also allow us to have a tree view. Do you think that would add overhead for the main use case we are currently targeting?



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: Improve error "BroadcastExchange is not supported" [datafusion-comet]

Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on code in PR #577:
URL: https://github.com/apache/datafusion-comet/pull/577#discussion_r1643591456


##########
spark/inspections/CometTPCHQueriesList-results.txt:
##########
@@ -1,133 +1,133 @@
-Query: q1 TPCH Snappy. Comet Exec: Enabled (CometHashAggregate, CometProject)
+Query: q1 TPCH Snappy. Comet Exec: Enabled (CometHashAggregate, CometFilter, CometProject)
 Query: q1 TPCH Snappy: ExplainInfo:
 Comet shuffle is not enabled: spark.sql.adaptive.coalescePartitions.enabled is enabled and spark.comet.shuffle.enforceMode.enabled is not enabled
 
 Query: q2 TPCH Snappy. Comet Exec: Enabled (CometFilter, CometProject)
 Query: q2 TPCH Snappy: ExplainInfo:
-BroadcastExchange is not supported
+BroadcastHashJoin is not enabled because not all child plans are native 

Review Comment:
   I see. Yes, it would be great at some point to support the two methods of displaying the info. The query tree view would be very helpful for end users debugging a single query.



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: Improve error "BroadcastExchange is not supported" [datafusion-comet]

Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on code in PR #577:
URL: https://github.com/apache/datafusion-comet/pull/577#discussion_r1643590899


##########
spark/src/main/scala/org/apache/comet/CometSparkSessionExtensions.scala:
##########
@@ -221,6 +221,16 @@ class CometSparkSessionExtensions
 
     private def isCometNative(op: SparkPlan): Boolean = op.isInstanceOf[CometNativeExec]
 
+    private def explainChildNotNative(op: SparkPlan): String = {
+      var nonNatives: Seq[String] = Seq()
+      op.children.foreach(plan => {
+        if (!isCometNative(plan)) {
+          nonNatives = nonNatives :+ plan.nodeName
+        }
+      })

Review Comment:
   nit: this can be simplified with a functional approach:
   
   ```suggestion
         val nonNatives: Seq[String] = op.children.filterNot(isCometNative).map(_.nodeName)
   ```



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: Improve error "BroadcastExchange is not supported" [datafusion-comet]

Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove merged PR #577:
URL: https://github.com/apache/datafusion-comet/pull/577


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: Improve error "BroadcastExchange is not supported" [datafusion-comet]

Posted by "parthchandra (via GitHub)" <gi...@apache.org>.
parthchandra commented on PR #577:
URL: https://github.com/apache/datafusion-comet/pull/577#issuecomment-2204721219

   Thank you @andygrove @kazuyukitanimura 


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: Improve error "BroadcastExchange is not supported" [datafusion-comet]

Posted by "parthchandra (via GitHub)" <gi...@apache.org>.
parthchandra commented on code in PR #577:
URL: https://github.com/apache/datafusion-comet/pull/577#discussion_r1643449854


##########
spark/inspections/CometTPCHQueriesList-results.txt:
##########
@@ -1,133 +1,133 @@
-Query: q1 TPCH Snappy. Comet Exec: Enabled (CometHashAggregate, CometProject)
+Query: q1 TPCH Snappy. Comet Exec: Enabled (CometHashAggregate, CometFilter, CometProject)
 Query: q1 TPCH Snappy: ExplainInfo:
 Comet shuffle is not enabled: spark.sql.adaptive.coalescePartitions.enabled is enabled and spark.comet.shuffle.enforceMode.enabled is not enabled
 
 Query: q2 TPCH Snappy. Comet Exec: Enabled (CometFilter, CometProject)
 Query: q2 TPCH Snappy: ExplainInfo:
-BroadcastExchange is not supported
+BroadcastHashJoin is not enabled because not all child plans are native 

Review Comment:
   TL;DR To get the reason why a specific operation in a specific query is not native we must look at the extended explain info in conjunction with the plan.
   
   One of the goals of the extended explain plan output (perhaps the primary goal) was to run this over a large number of queries and aggregate which operations end users are likely to benefit from. For instance, `xxhash64` appears to be an expression which prevents several TPC-H queries from running natively, so we were able to prioritise the work on it.
   Getting detailed information  for specific queries was not originally a goal, so we subsume some of the extended explain information, preferring to only output root causes. This is also the reason why we do not associate the information with any specific node.
   
   In TPC-H q2, there are _seven_ BroadcastHashJoins in the plan. None of them are converted to native because the child plan is not native. Some of the nodes have one arm which is native but the other is a BroadcastExchange, other nodes have a Project as one arm and a BroadcastExchange  as the other. Now the Project arm in the node is not native because its child is not native. But there are different reasons for why the Project has a child plan that is not native. In this case, some have a child which is a BroadcastHashJoin and others have a SortMergeJoin. And so on.
   The only good way to make this something that end users can leverage is to print the entire plan with the explanation on the same line as the node. That has two disadvantages. Firstly, we can no longer aggregate this information because each extended explain plan is unique to the query. Secondly, the extended explain plan becomes verbose and hard to read.
   
   I've made an attempt that makes it a little more verbose without getting too query specific. For TPC-H q2 it looks like this - 
   ```
   BroadcastHashJoin is not enabled because the following children are not native (BroadcastExchange)
   BroadcastHashJoin is not enabled because the following children are not native (Project, BroadcastExchange)
   Comet shuffle is not enabled: spark.sql.adaptive.coalescePartitions.enabled is enabled and spark.comet.shuffle.enforceMode.enabled is not enabled
   Filter is not native because the following children are not native (HashAggregate)
   HashAggregate is not native because the following children are not native (Project)
   ObjectHashAggregate is not supported
   Project is not native because the following children are not native (BroadcastHashJoin)
   Project is not native because the following children are not native (SortMergeJoin)
   Sort is not native because the following children are not native (Exchange)
   SortMergeJoin is not enabled because the following children are not native (Sort, Sort)
   TakeOrderedAndProject requires shuffle to be enabled
   xxhash64 is disabled by default. Set spark.comet.xxhash64.enabled=true to enable it.
   ```
   WDYT?



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: Improve error "BroadcastExchange is not supported" [datafusion-comet]

Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on code in PR #577:
URL: https://github.com/apache/datafusion-comet/pull/577#discussion_r1642847143


##########
spark/inspections/CometTPCHQueriesList-results.txt:
##########
@@ -1,133 +1,133 @@
-Query: q1 TPCH Snappy. Comet Exec: Enabled (CometHashAggregate, CometProject)
+Query: q1 TPCH Snappy. Comet Exec: Enabled (CometHashAggregate, CometFilter, CometProject)
 Query: q1 TPCH Snappy: ExplainInfo:
 Comet shuffle is not enabled: spark.sql.adaptive.coalescePartitions.enabled is enabled and spark.comet.shuffle.enforceMode.enabled is not enabled
 
 Query: q2 TPCH Snappy. Comet Exec: Enabled (CometFilter, CometProject)
 Query: q2 TPCH Snappy: ExplainInfo:
-BroadcastExchange is not supported
+BroadcastHashJoin is not enabled because not all child plans are native 

Review Comment:
   This is a better error message, but it seems we are still missing information on why  the plan cannot run natively. How can I find out which child plan is not native here?



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: Improve error "BroadcastExchange is not supported" [datafusion-comet]

Posted by "parthchandra (via GitHub)" <gi...@apache.org>.
parthchandra commented on code in PR #577:
URL: https://github.com/apache/datafusion-comet/pull/577#discussion_r1649457828


##########
spark/src/main/scala/org/apache/comet/CometSparkSessionExtensions.scala:
##########
@@ -594,22 +630,41 @@ class CometSparkSessionExtensions
             if (isCometNative(newPlan) || isCometBroadCastForceEnabled(conf)) {
               newPlan
             } else {
-              if (!isCometOperatorEnabled(
-                  conf,
-                  "broadcastExchangeExec") && !isCometBroadCastForceEnabled(conf)) {
-                withInfo(plan, "Native Broadcast is not enabled")
+              if (isCometNative(newPlan)) {
+                val reason =
+                  getCometBroadcastNotEnabledReason(conf).getOrElse("no reason available")
+                withInfo(plan, s"Broadcast is not enabled: $reason")
               }
               plan
             }
           } else {
+            withInfo(
+              plan,
+              s"${plan.nodeName} is not native because the following children are not native " +
+                s"${explainChildNotNative(plan)}")
             plan
           }
 
         // this case should be checked only after the previous case checking for a
         // child BroadcastExchange has been applied, otherwise that transform
         // never gets applied
         case op: BroadcastHashJoinExec if !op.children.forall(isCometNative(_)) =>
-          withInfo(op, "BroadcastHashJoin disabled because not all child plans are native")
+          withInfo(
+            op,
+            "BroadcastHashJoin is not enabled because the following children are not native " +
+              s"${explainChildNotNative(op)}")
+          op
+        case op: BroadcastHashJoinExec
+            if isCometOperatorEnabled(conf, "broadcast_hash_join") &&
+              !op.children.forall(isCometNative(_)) =>
+          withInfo(
+            op,
+            "BroadcastHashJoin is not enabled because the following children are not native " +
+              s"${explainChildNotNative(op)}")
+          op
+
+        case op: BroadcastHashJoinExec if !isCometOperatorEnabled(conf, "broadcast_hash_join") =>
+          withInfo(op, "BroadcastHashJoin is not enabled")

Review Comment:
   Yes, it is. Removed. Thank you! 



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: Improve error "BroadcastExchange is not supported" [datafusion-comet]

Posted by "parthchandra (via GitHub)" <gi...@apache.org>.
parthchandra commented on PR #577:
URL: https://github.com/apache/datafusion-comet/pull/577#issuecomment-2203886808

   Rebased on main, but funnily did not get any conflicts. 


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: Improve error "BroadcastExchange is not supported" [datafusion-comet]

Posted by "parthchandra (via GitHub)" <gi...@apache.org>.
parthchandra commented on code in PR #577:
URL: https://github.com/apache/datafusion-comet/pull/577#discussion_r1643450317


##########
spark/inspections/CometTPCHQueriesList-results.txt:
##########
@@ -1,133 +1,133 @@
-Query: q1 TPCH Snappy. Comet Exec: Enabled (CometHashAggregate, CometProject)
+Query: q1 TPCH Snappy. Comet Exec: Enabled (CometHashAggregate, CometFilter, CometProject)
 Query: q1 TPCH Snappy: ExplainInfo:
 Comet shuffle is not enabled: spark.sql.adaptive.coalescePartitions.enabled is enabled and spark.comet.shuffle.enforceMode.enabled is not enabled
 
 Query: q2 TPCH Snappy. Comet Exec: Enabled (CometFilter, CometProject)
 Query: q2 TPCH Snappy: ExplainInfo:
-BroadcastExchange is not supported
+BroadcastHashJoin is not enabled because not all child plans are native 

Review Comment:
   This would be a lot more readable if the information was nested. For instance something like - 
   ```
   BroadcastHashJoin is not enabled because the following children are not native (Project, BroadcastExchange)
    -- Project is not native because the following children are not native (BroadcastHashJoin)
       -- BroadcastHashJoin is not enabled because the following children are not native (BroadcastExchange)
           -- etc
   ```
   But then we would defeat our first goal because the output would become query specific



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: Improve error "BroadcastExchange is not supported" [datafusion-comet]

Posted by "parthchandra (via GitHub)" <gi...@apache.org>.
parthchandra commented on code in PR #577:
URL: https://github.com/apache/datafusion-comet/pull/577#discussion_r1643577459


##########
spark/inspections/CometTPCHQueriesList-results.txt:
##########
@@ -1,133 +1,133 @@
-Query: q1 TPCH Snappy. Comet Exec: Enabled (CometHashAggregate, CometProject)
+Query: q1 TPCH Snappy. Comet Exec: Enabled (CometHashAggregate, CometFilter, CometProject)
 Query: q1 TPCH Snappy: ExplainInfo:
 Comet shuffle is not enabled: spark.sql.adaptive.coalescePartitions.enabled is enabled and spark.comet.shuffle.enforceMode.enabled is not enabled
 
 Query: q2 TPCH Snappy. Comet Exec: Enabled (CometFilter, CometProject)
 Query: q2 TPCH Snappy: ExplainInfo:
-BroadcastExchange is not supported
+BroadcastHashJoin is not enabled because not all child plans are native 

Review Comment:
   The information is, in fact, in the nodes and it is collected (and de-deuped) later. It's just not printed out in a tree view. I've added the  additional information for nodes where we were explicitly printing the 'not all children are native' message. For most cases where a node is not native because the children are not native, we don't have any information because in the flattened view it is rather uninformative.
   I can add the nested view as an additional interface in `ExtendedExplainInfo` and can print that in the queries list output based on a flag. At some later date if we no longer find the aggregated use case useful, we can switch the flag so the same output will show up in Spark UI as well.
   Over time I expect the information we add in explain info will keep changing. 



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org