Skip to content

Commit c75ae8d

Browse files
committed
Use Seq-based instead of List-based pattern matching
1 parent 3e39720 commit c75ae8d

File tree

1 file changed

+3
-3
lines changed
  • sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical

1 file changed

+3
-3
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/LogicalPlan.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ private[catalyst] class AttributeResolver(attributes: Seq[Attribute]) extends Lo
189189
}
190190

191191
/** Map to use for direct case insensitive attribute lookups. */
192-
private val direct: Map[String, Seq[Attribute]] = {
192+
private lazy val direct: Map[String, Seq[Attribute]] = {
193193
unique(attributes.groupBy(_.name.toLowerCase))
194194
}
195195

@@ -214,7 +214,7 @@ private[catalyst] class AttributeResolver(attributes: Seq[Attribute]) extends Lo
214214
// and "c" is the struct field name, i.e. "a.b.c". In this case, Attribute will be "a.b",
215215
// and the second element will be List("c").
216216
val matches = nameParts match {
217-
case qualifier :: name :: nestedFields =>
217+
case qualifier +: name +: nestedFields =>
218218
val key = (qualifier.toLowerCase, name.toLowerCase)
219219
val attributes = qualified.get(key).toSeq.flatMap(_.filter { a =>
220220
resolver(qualifier, a.qualifier.get) && isMatch(name, a)
@@ -226,7 +226,7 @@ private[catalyst] class AttributeResolver(attributes: Seq[Attribute]) extends Lo
226226

227227
// If none of attributes match `table.column` pattern, we try to resolve it as a column.
228228
val (candidates, nestedFields) = matches match {
229-
case (Nil, _) =>
229+
case (Seq(), _) =>
230230
val name = nameParts.head
231231
val attributes = direct.get(name.toLowerCase).toSeq.flatMap(_.filter(isMatch(name, _)))
232232
(attributes, nameParts.tail)

0 commit comments

Comments
 (0)