jinchengchenghh commented on code in PR #9529:
URL: https://github.com/apache/incubator-gluten/pull/9529#discussion_r2079451174


##########
gluten-iceberg/src/main/scala/org/apache/iceberg/spark/source/GlutenIcebergSourceUtil.scala:
##########
@@ -195,6 +195,32 @@ object GlutenIcebergSourceUtil {
       throw new UnsupportedOperationException("Only support iceberg 
SparkBatchQueryScan.")
   }
 
+  def isSchemaReAdd(scan: Scan): Boolean = {
+    scan match {
+      case scan: SparkScan =>
+        val readSchema: StructType = scan.readSchema()
+        val readFieldNames = readSchema.fieldNames.toSet
+
+        val schemasMap = scan.table.schemas().asScala.map { case (k, v) => 
k.intValue() -> v }.toMap
+
+        val nameToIdSet = schemasMap.values
+          .flatMap {
+            schema => schema.idToName().asScala.map { case (id, name) => name 
-> id.intValue() }
+          }
+          .groupBy(_._1)
+          .mapValues(_.map(_._2).toSet)
+
+        readFieldNames.exists {
+          name =>
+            nameToIdSet.get(name) match {
+              case Some(ids) if ids.size > 1 => true

Review Comment:
   If the id exists in old schema twice, it won't affect the result



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to