1717
1818package org .apache .spark .sql .catalyst
1919
20- import com . google . common . collect . Maps
20+ import java . util . Locale
2121
22+ import com .google .common .collect .Maps
2223import org .apache .spark .sql .AnalysisException
2324import org .apache .spark .sql .catalyst .analysis .{Resolver , UnresolvedAttribute }
2425import org .apache .spark .sql .catalyst .expressions ._
@@ -147,13 +148,13 @@ package object expressions {
147148
148149 /** Map to use for direct case insensitive attribute lookups. */
149150 @ transient private lazy val direct : Map [String , Seq [Attribute ]] = {
150- unique(attrs.groupBy(_.name.toLowerCase))
151+ unique(attrs.groupBy(_.name.toLowerCase( Locale . ROOT ) ))
151152 }
152153
153154 /** Map to use for qualified case insensitive attribute lookups. */
154155 @ transient private val qualified : Map [(String , String ), Seq [Attribute ]] = {
155156 val grouped = attrs.filter(_.qualifier.isDefined).groupBy { a =>
156- (a.qualifier.get.toLowerCase, a.name.toLowerCase)
157+ (a.qualifier.get.toLowerCase( Locale . ROOT ) , a.name.toLowerCase( Locale . ROOT ) )
157158 }
158159 unique(grouped)
159160 }
@@ -176,7 +177,7 @@ package object expressions {
176177 // and the second element will be List("c").
177178 val matches = nameParts match {
178179 case qualifier +: name +: nestedFields =>
179- val key = (qualifier.toLowerCase, name.toLowerCase)
180+ val key = (qualifier.toLowerCase( Locale . ROOT ) , name.toLowerCase( Locale . ROOT ) )
180181 val attributes = collectMatches(name, qualified.get(key)).filter { a =>
181182 resolver(qualifier, a.qualifier.get)
182183 }
@@ -189,7 +190,7 @@ package object expressions {
189190 val (candidates, nestedFields) = matches match {
190191 case (Seq (), _) =>
191192 val name = nameParts.head
192- val attributes = collectMatches(name, direct.get(name.toLowerCase))
193+ val attributes = collectMatches(name, direct.get(name.toLowerCase( Locale . ROOT ) ))
193194 (attributes, nameParts.tail)
194195 case _ => matches
195196 }
@@ -218,7 +219,7 @@ package object expressions {
218219
219220 case ambiguousReferences =>
220221 // More than one match.
221- val referenceNames = ambiguousReferences.mkString(" , " )
222+ val referenceNames = ambiguousReferences.map(_.qualifiedName). mkString(" , " )
222223 throw new AnalysisException (s " Reference ' $name' is ambiguous, could be: $referenceNames. " )
223224 }
224225 }
0 commit comments