sandeep-katta commented on a change in pull request #32194:
URL: https://github.com/apache/spark/pull/32194#discussion_r614535186



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/SchemaPruning.scala
##########
@@ -36,7 +38,8 @@ object SchemaPruning {
       .reduceLeft(_ merge _)
     val dataSchemaFieldNames = dataSchema.fieldNames.toSet
     val mergedDataSchema =
-      StructType(mergedSchema.filter(f => 
dataSchemaFieldNames.contains(f.name)))
+      StructType(mergedSchema.filter(f => 
dataSchemaFieldNames.exists(resolver(_, f.name))

Review comment:
       Before query should fail without this fix
   ```
   val inputPath = "/Users/xyz/data/testcaseInsensitivity"
   val output_path = "/Users/xyz/output"
   
   spark.range(10).write.format("parquet").save(inputPath)
   
   def process_row(microBatch: DataFrame, batchId: Long): Unit = {
     val df = microBatch.select($"ID".alias("other")) // Doesn't work
     df.write.format("parquet").mode("append").save(output_path)
   
   }
   
   val schema = new StructType().add("id", LongType)
   
   val stream_df = 
spark.readStream.schema(schema).format("parquet").load(inputPath)
   stream_df.writeStream.trigger(Trigger.Once).foreachBatch(process_row _)
     .start().awaitTermination()
   ```




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

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