[GitHub] [spark] HyukjinKwon commented on a change in pull request #26927: [SPARK-29505][SQL] Make DESC EXTENDED case insensitive

Tue, 24 Dec 2019 01:43:48 -0800

HyukjinKwon commented on a change in pull request #26927: [SPARK-29505][SQL] 
Make DESC EXTENDED <table name> <column name> case insensitive
URL: https://github.com/apache/spark/pull/26927#discussion_r361119708
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala
 ##########
 @@ -720,8 +721,14 @@ case class DescribeColumnCommand(
     }
 
     val catalogTable = catalog.getTempViewOrPermanentTableMetadata(table)
-    val colStats = catalogTable.stats.map(_.colStats).getOrElse(Map.empty)
-    val cs = colStats.get(field.name)
+    val colStats = if (conf.caseSensitiveAnalysis) {
+      catalogTable.stats.map(_.colStats).getOrElse(Map.empty)
+    } else {
+      catalogTable.stats.map(_.colStats.map {
+        case (key, value) => key.toLowerCase(Locale.ROOT) -> value
+      }).getOrElse(Map.empty)
+    }
+    val cs = colStats.get(getColumnName(field.name))
 
 Review comment:
   Can we just do:
   
   ```scala
   val colStatsMap = catalogTable.stats.map(_.colStats).getOrElse(Map.empty)
   val colStats = if (conf.caseSensitiveAnalysis) colStatsMap else 
CaseInsensitiveMap(colStatsMap)
   ```
   
   ? I think this will fix all problems here.

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


With regards,
Apache Git Services

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

Reply via email to