Skip to content

Commit ac4abcd

Browse files
committed
Fix UT
1 parent eb6dd80 commit ac4abcd

File tree

1 file changed

+7
-6
lines changed
  • sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions

1 file changed

+7
-6
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/package.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717

1818
package 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
2223
import org.apache.spark.sql.AnalysisException
2324
import org.apache.spark.sql.catalyst.analysis.{Resolver, UnresolvedAttribute}
2425
import 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

Comments
 (0)