Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/17185#discussion_r207104432
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala
---
@@ -262,17 +262,47 @@ abstract class Star extends LeafExpression with
NamedExpression {
*/
case class UnresolvedStar(target: Option[Seq[String]]) extends Star with
Unevaluable {
- override def expand(input: LogicalPlan, resolver: Resolver):
Seq[NamedExpression] = {
+ /**
+ * Returns true if the nameParts match the qualifier of the attribute
+ *
+ * There are two checks: i) Check if the nameParts match the qualifier
fully.
+ * E.g. SELECT db.t1.* FROM db1.t1 In this case, the nameParts is
Seq("db1", "t1") and
+ * qualifier of the attribute is Seq("db1","t1")
+ * ii) If (i) is not true, then check if nameParts is only a single
element and it
+ * matches the table portion of the qualifier
+ *
+ * E.g. SELECT t1.* FROM db1.t1 In this case nameParts is Seq("t1") and
+ * qualifier is Seq("db1","t1")
+ * SELECT a.* FROM db1.t1 AS a
+ * In this case nameParts is Seq("a") and qualifier for
+ * attribute is Seq("a")
+ */
+ private def matchedQualifier(
+ attribute: Attribute,
+ nameParts: Seq[String],
+ resolver: Resolver): Boolean = {
+ val qualifierList = attribute.qualifier.getOrElse(Seq.empty)
+
+ // match the qualifiers and nameParts
+ val matched = nameParts.corresponds(qualifierList)(resolver) match {
--- End diff --
it's weird to use pattern match like this, maybe better to write
```
nameParts.corresponds(qualifierList)(resolver) || {
if (nameParts.length == 1 && qualifierList.nonEmpty) {
resolver(nameParts.head, qualifierList.last)
} else {
false
}
}
```
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]