Github user sureshthalamati commented on a diff in the pull request: https://github.com/apache/spark/pull/16891#discussion_r100976184 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/CaseInsensitiveMap.scala --- @@ -18,21 +18,25 @@ package org.apache.spark.sql.catalyst.util /** - * Builds a map in which keys are case insensitive + * Builds a map in which keys are case insensitive. Input map can be accessed for cases where + * case-sensitive information is also required. */ -class CaseInsensitiveMap(map: Map[String, String]) extends Map[String, String] +class CaseInsensitiveMap(val caseSensitiveMap: Map[String, String]) extends Map[String, String] with Serializable { - val baseMap = map.map(kv => kv.copy(_1 = kv._1.toLowerCase)) + val baseMap = caseSensitiveMap.map(kv => kv.copy(_1 = kv._1.toLowerCase)) override def get(k: String): Option[String] = baseMap.get(k.toLowerCase) override def contains(k: String): Boolean = baseMap.contains(k.toLowerCase) - override def + [B1 >: String](kv: (String, B1)): Map[String, B1] = - baseMap + kv.copy(_1 = kv._1.toLowerCase) + override def +[B1 >: String](kv: (String, B1)): Map[String, B1] = { + new CaseInsensitiveMap(caseSensitiveMap + kv.copy(_2 = kv._2.asInstanceOf[String])) + } override def iterator: Iterator[(String, String)] = baseMap.iterator - override def -(key: String): Map[String, String] = baseMap - key.toLowerCase + override def -(key: String): Map[String, String] = { + new CaseInsensitiveMap(caseSensitiveMap.filterKeys(k => k.toLowerCase != key.toLowerCase)) --- End diff -- done.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org