kazuyukitanimura commented on code in PR #1621:
URL: https://github.com/apache/datafusion-comet/pull/1621#discussion_r2035865358


##########
spark/src/main/scala/org/apache/comet/CometSparkSessionExtensions.scala:
##########
@@ -246,6 +183,65 @@ class CometSparkSessionExtensions
     }
   }
 
+  private def transformV2Scan(scanExec: BatchScanExec): SparkPlan = {
+
+    scanExec.scan match {
+      case scan: ParquetScan =>
+        val fallbackReasons = new ListBuffer[String]()
+        if (!CometBatchScanExec.isSchemaSupported(scan.readDataSchema)) {
+          fallbackReasons += s"Schema ${scan.readDataSchema} is not supported"
+        }
+
+        if (!CometBatchScanExec.isSchemaSupported(scan.readPartitionSchema)) {
+          fallbackReasons += s"Partition schema ${scan.readPartitionSchema} is 
not supported"
+        }
+
+        if (scan.pushedAggregate.nonEmpty) {
+          fallbackReasons += "Comet does not support pushed aggregate"
+        }
+
+        if (fallbackReasons.isEmpty) {
+          val cometScan = 
CometParquetScan(scanExec.scan.asInstanceOf[ParquetScan])
+          logInfo("Comet extension enabled for Scan")
+          CometBatchScanExec(
+            scanExec.copy(scan = cometScan),
+            runtimeFilters = scanExec.runtimeFilters)
+        } else {
+          withInfo(scanExec, withInfo(scanExec, fallbackReasons.mkString(", 
")))

Review Comment:
   same here



##########
spark/src/main/scala/org/apache/comet/CometSparkSessionExtensions.scala:
##########
@@ -246,6 +183,65 @@ class CometSparkSessionExtensions
     }
   }
 
+  private def transformV2Scan(scanExec: BatchScanExec): SparkPlan = {
+
+    scanExec.scan match {
+      case scan: ParquetScan =>
+        val fallbackReasons = new ListBuffer[String]()
+        if (!CometBatchScanExec.isSchemaSupported(scan.readDataSchema)) {
+          fallbackReasons += s"Schema ${scan.readDataSchema} is not supported"
+        }
+
+        if (!CometBatchScanExec.isSchemaSupported(scan.readPartitionSchema)) {
+          fallbackReasons += s"Partition schema ${scan.readPartitionSchema} is 
not supported"
+        }
+
+        if (scan.pushedAggregate.nonEmpty) {
+          fallbackReasons += "Comet does not support pushed aggregate"
+        }
+
+        if (fallbackReasons.isEmpty) {
+          val cometScan = 
CometParquetScan(scanExec.scan.asInstanceOf[ParquetScan])
+          logInfo("Comet extension enabled for Scan")
+          CometBatchScanExec(
+            scanExec.copy(scan = cometScan),
+            runtimeFilters = scanExec.runtimeFilters)
+        } else {
+          withInfo(scanExec, withInfo(scanExec, fallbackReasons.mkString(", 
")))
+          scanExec
+        }
+
+      // Iceberg scan
+      case s: SupportsComet =>
+        val fallbackReasons = new ListBuffer[String]()
+
+        if (!s.isCometEnabled) {
+          fallbackReasons += "Comet extension is not enabled for " +
+            s"${scanExec.scan.getClass.getSimpleName}: not enabled on data 
source side"
+        }
+
+        if (!CometBatchScanExec.isSchemaSupported(scanExec.scan.readSchema())) 
{
+          fallbackReasons += "Comet extension is not enabled for " +
+            s"${scanExec.scan.getClass.getSimpleName}: Schema not supported"
+        }
+
+        if (fallbackReasons.isEmpty) {
+          // When reading from Iceberg, we automatically enable type promotion
+          SQLConf.get.setConfString(COMET_SCHEMA_EVOLUTION_ENABLED.key, "true")
+          CometBatchScanExec(
+            scanExec.clone().asInstanceOf[BatchScanExec],
+            runtimeFilters = scanExec.runtimeFilters)
+        } else {
+          withInfo(scanExec, withInfo(scanExec, fallbackReasons.mkString(", 
")))

Review Comment:
   Is this nested `withInfo` correct?



-- 
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