You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/04/16 03:25:52 UTC

[GitHub] [spark] sandeep-katta commented on a change in pull request #32194: [SPARK-35096][Core] SchemaPruning should adhere spark.sql.caseSensitive config

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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org