parthchandra commented on code in PR #255:
URL: https://github.com/apache/datafusion-comet/pull/255#discussion_r1574880087


##########
spark/src/main/scala/org/apache/comet/CometSparkSessionExtensions.scala:
##########
@@ -128,6 +158,26 @@ class CometSparkSessionExtensions
                 _) if isSchemaSupported(requiredSchema) && 
isSchemaSupported(partitionSchema) =>
             logInfo("Comet extension enabled for v1 Scan")
             CometScanExec(scanExec, session)
+
+          // data source v1 not supported case
+          case scanExec @ FileSourceScanExec(
+                HadoopFsRelation(_, partitionSchema, _, _, _: 
ParquetFileFormat, _),
+                _: Seq[AttributeReference],
+                requiredSchema,
+                _,
+                _,
+                _,
+                _,
+                _,
+                _) =>
+            val info1 = createMessage(
+              !isSchemaSupported(requiredSchema),
+              s"Schema $requiredSchema is not supported")
+            val info2 = createMessage(
+              !isSchemaSupported(partitionSchema),
+              s"Schema $partitionSchema is not supported")

Review Comment:
   Done



##########
spark/src/main/scala/org/apache/comet/ExtendedExplainInfo.scala:
##########
@@ -0,0 +1,87 @@
+/*
+ * 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.comet
+
+import scala.collection.mutable
+
+import org.apache.spark.sql.ExtendedExplainGenerator
+import org.apache.spark.sql.catalyst.trees.{TreeNode, TreeNodeTag}
+import org.apache.spark.sql.execution.{InputAdapter, SparkPlan, 
WholeStageCodegenExec}
+import org.apache.spark.sql.execution.adaptive.{AdaptiveSparkPlanExec, 
QueryStageExec}
+
+class ExtendedExplainInfo extends ExtendedExplainGenerator {
+
+  override def title: String = "Comet"
+
+  override def generateExtendedInfo(plan: SparkPlan): String = {
+    val info = extensionInfo(plan)
+    info.distinct.mkString("\n").trim
+  }
+
+  private def getActualPlan(node: TreeNode[_]): TreeNode[_] = {

Review Comment:
   I used TreeNode because we can add the extended info tag to any TreeNode 
(SparkPlan, Expression, or AggregateExpression). This particular method only 
operates on SparkPlan, but I couldn't get the compiler to agree with me :( so I 
finally left it as a TreeNode. 



##########
spark/src/main/scala/org/apache/spark/sql/ExtendedExplainGenerator.scala:
##########
@@ -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.spark.sql
+
+import org.apache.spark.sql.execution.SparkPlan
+
+/**
+ * A trait for a session extension to implement that provides addition explain 
plan information.
+ */
+

Review Comment:
   Done



##########
spark/src/test/scala/org/apache/spark/sql/CometTPCQueryListBase.scala:
##########
@@ -84,11 +86,15 @@ trait CometTPCQueryListBase
       withSQLConf(
         CometConf.COMET_ENABLED.key -> "true",
         CometConf.COMET_EXEC_ENABLED.key -> "true",
-        CometConf.COMET_EXEC_ALL_OPERATOR_ENABLED.key -> "true") {
+        CometConf.COMET_EXEC_SHUFFLE_ENABLED.key -> "true",
+        CometConf.COMET_EXEC_ALL_OPERATOR_ENABLED.key -> "true",
+        "spark.sql.optimizer.runtime.bloomFilter.creationSideThreshold" -> 
"1MB",
+        
"spark.sql.optimizer.runtime.bloomFilter.applicationSideScanSizeThreshold" -> 
"1MB") {

Review Comment:
   This allows us to simulate the plan produced at larger loads. When we run 
this on a 1TB dataset, we get bloom filters enabled because the thresholds are 
met. However for smaller datasets, we need to lower the thresholds so that 
bloom filters are enabled.
   Added this as a comment.



##########
spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala:
##########
@@ -917,6 +1026,7 @@ object QueryPlanSerde extends Logging with 
ShimQueryPlanSerde {
                 .setStringSpace(builder)
                 .build())
           } else {
+            withInfo(expr, null, child)

Review Comment:
   Done. There are one or two cases where the second param is not null. But 
mostly it is null.



##########
spark/src/main/scala/org/apache/comet/ExtendedExplainInfo.scala:
##########
@@ -0,0 +1,87 @@
+/*
+ * 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.comet
+
+import scala.collection.mutable
+
+import org.apache.spark.sql.ExtendedExplainGenerator
+import org.apache.spark.sql.catalyst.trees.{TreeNode, TreeNodeTag}
+import org.apache.spark.sql.execution.{InputAdapter, SparkPlan, 
WholeStageCodegenExec}
+import org.apache.spark.sql.execution.adaptive.{AdaptiveSparkPlanExec, 
QueryStageExec}
+
+class ExtendedExplainInfo extends ExtendedExplainGenerator {
+
+  override def title: String = "Comet"
+
+  override def generateExtendedInfo(plan: SparkPlan): String = {
+    val info = extensionInfo(plan)
+    info.distinct.mkString("\n").trim
+  }
+
+  private def getActualPlan(node: TreeNode[_]): TreeNode[_] = {
+    node match {
+      case p: AdaptiveSparkPlanExec => getActualPlan(p.executedPlan)
+      case p: InputAdapter => getActualPlan(p.child)
+      case p: QueryStageExec => getActualPlan(p.plan)
+      case p: WholeStageCodegenExec => getActualPlan(p.child)
+      case p => p
+    }
+  }
+
+  private def extensionInfo(node: TreeNode[_]): mutable.Seq[String] = {
+    var info = mutable.Seq[String]()
+    val sorted = sortup(node)
+    sorted.foreach { p =>
+      val all: Array[String] =
+        
getActualPlan(p).getTagValue(CometExplainInfo.EXTENSION_INFO).getOrElse("").split("\n")
+      for (s <- all) {
+        info = info :+ s
+      }
+    }
+    info.filter(!_.contentEquals("\n"))
+  }
+
+  // get all plan nodes, breadth first, leaf nodes first

Review Comment:
   Reversed breadth first would be a more accurate description I suppose. The 
traversal is BF but the order is reversed at the end. 



-- 
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-unsubscr...@datafusion.apache.org

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


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

Reply via email to