[GitHub] spark pull request #14773: [SPARK-17203][SQL] data source options should alw...
Github user cloud-fan closed the pull request at: https://github.com/apache/spark/pull/14773 --- 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
[GitHub] spark pull request #14773: [SPARK-17203][SQL] data source options should alw...
Github user clockfly commented on a diff in the pull request: https://github.com/apache/spark/pull/14773#discussion_r77295324 --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/ddl.scala --- @@ -90,17 +90,31 @@ case class RefreshResource(path: String) /** * Builds a map in which keys are case insensitive */ -class CaseInsensitiveMap(map: Map[String, String]) extends Map[String, String] +class CaseInsensitiveMap[T] private(baseMap: Map[String, T]) extends Map[String, T] --- End diff -- If we decide to go case-insensitive all usage of options, probably we don't need class CaseInsensitiveMap adapter class any longer. Instead, we should probably convert to user provided options to lower case directly. --- 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
[GitHub] spark pull request #14773: [SPARK-17203][SQL] data source options should alw...
Github user clockfly commented on a diff in the pull request: https://github.com/apache/spark/pull/14773#discussion_r77294893 --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/ddl.scala --- @@ -90,17 +90,31 @@ case class RefreshResource(path: String) /** * Builds a map in which keys are case insensitive */ -class CaseInsensitiveMap(map: Map[String, String]) extends Map[String, String] +class CaseInsensitiveMap[T] private(baseMap: Map[String, T]) extends Map[String, T] with Serializable { - val baseMap = map.map(kv => kv.copy(_1 = kv._1.toLowerCase)) + override def get(k: String): Option[T] = baseMap.get(k.toLowerCase) - override def get(k: String): Option[String] = baseMap.get(k.toLowerCase) + override def + [B1 >: T](kv: (String, B1)): Map[String, B1] = +new CaseInsensitiveMap(baseMap + kv.copy(_1 = kv._1.toLowerCase)) - override def + [B1 >: String](kv: (String, B1)): Map[String, B1] = -baseMap + kv.copy(_1 = kv._1.toLowerCase) + override def iterator: Iterator[(String, T)] = baseMap.iterator - override def iterator: Iterator[(String, String)] = baseMap.iterator + override def -(key: String): Map[String, T] = +new CaseInsensitiveMap(baseMap - key.toLowerCase) +} - override def -(key: String): Map[String, String] = baseMap - key.toLowerCase +object CaseInsensitiveMap { + def apply[T](map: Map[String, T]): CaseInsensitiveMap[T] = { +val lowercaseKeys = map.keys.map(_.toLowerCase) +if (lowercaseKeys.toSet.size != map.size) { + val duplicatedKeys = lowercaseKeys.groupBy(identity).collect { +case (x, ys) if ys.size > 1 => x + } + throw new AnalysisException( --- End diff -- Why it is a AnalysisException? This class is only supposed to be used at driver? --- 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
[GitHub] spark pull request #14773: [SPARK-17203][SQL] data source options should alw...
Github user frreiss commented on a diff in the pull request: https://github.com/apache/spark/pull/14773#discussion_r76503740 --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/command/createDataSourceTables.scala --- @@ -65,7 +65,7 @@ case class CreateDataSourceTableCommand( var isExternal = true val optionsWithPath = - if (!new CaseInsensitiveMap(options).contains("path") && managedIfNoPath) { + if (!options.contains("path") && managedIfNoPath) { --- End diff -- Maybe create a constant for the string "path" as a data source param? It occurs in quite a few places. --- 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
[GitHub] spark pull request #14773: [SPARK-17203][SQL] data source options should alw...
GitHub user cloud-fan opened a pull request: https://github.com/apache/spark/pull/14773 [SPARK-17203][SQL] data source options should always be case insensitive ## What changes were proposed in this pull request? We don't have a clear definition about When data source options should be case sensitive and when not. Currently `path` is case-insensitive, `numFeatures` in LibSVMFileFormat is case-sensitive, `maxFilesPerTrigger` in FileStreamSource is case-insensitive, etc. Instead of letting every conf decide whether they should be case-sensitive or not themselves, I think it's better to make it clear that all data source options are case-insensitive. ## How was this patch tested? existing tests. You can merge this pull request into a Git repository by running: $ git pull https://github.com/cloud-fan/spark case Alternatively you can review and apply these changes as the patch at: https://github.com/apache/spark/pull/14773.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #14773 commit 2e4368eb4375b08bbbf0caf5633f02828a7c40b9 Author: Wenchen FanDate: 2016-08-23T15:16:06Z data source options should always be case insensitive --- 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