viirya commented on a change in pull request #29457:
URL: https://github.com/apache/spark/pull/29457#discussion_r474160197



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/orc/OrcFiltersBase.scala
##########
@@ -49,19 +51,21 @@ trait OrcFiltersBase {
    */
   protected[sql] def getSearchableTypeMap(
       schema: StructType,
-      caseSensitive: Boolean): Map[String, DataType] = {
+      caseSensitive: Boolean): Map[String, OrcPrimitiveField] = {
     import 
org.apache.spark.sql.connector.catalog.CatalogV2Implicits.MultipartIdentifierHelper
 
     def getPrimitiveFields(
         fields: Seq[StructField],
-        parentFieldNames: Seq[String] = Seq.empty): Seq[(String, DataType)] = {
+        parentFieldNames: Seq[String] = Seq.empty): Seq[(String, 
OrcPrimitiveField)] = {
       fields.flatMap { f =>
         f.dataType match {
           case st: StructType =>
             getPrimitiveFields(st.fields, parentFieldNames :+ f.name)
           case BinaryType => None
           case _: AtomicType =>
-            Some(((parentFieldNames :+ f.name).quoted, f.dataType))
+            val fieldName = (parentFieldNames :+ f.name).quoted
+            val orcField = OrcPrimitiveField(fieldName, f.dataType)
+            Some((fieldName, orcField))

Review comment:
       Because we look up attribute name of pushed down predicates in the map 
`dataTypeMap(name)`, we need to easily retrieve the file schema's field name. 
If we simply use `Map[String, DataType]`, the matched attribute name under 
case-insensitive analysis could be possibly in different letter case to the 
file schema's field name.
   
   E,g, If ORC file has 'ABC` field, pushed down predicate is "abc > 0", 
`dataTypeMap.contain("abc")` is true and we can get `dataTypeMap("abc")` back. 
But we need file schema's field name "ABC".
   
   It is similar to Parquet: 
https://github.com/apache/spark/blob/d6a68e0b67ff7de58073c176dd097070e88ac831/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetFilters.scala#L56-L76
   
   




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