Skip to content
Snippets Groups Projects
Commit 14c7236d authored by Cheng Lian's avatar Cheng Lian
Browse files

[SPARK-14004][SQL][MINOR] AttributeReference and Alias should only use the...

[SPARK-14004][SQL][MINOR] AttributeReference and Alias should only use the first qualifier to generate SQL strings

## What changes were proposed in this pull request?

Current implementations of `AttributeReference.sql` and `Alias.sql` joins all available qualifiers, which is logically wrong. But this implementation mistake doesn't cause any real SQL generation bugs though, since there is always at most one qualifier for any given `AttributeReference` or `Alias`.

This PR fixes this issue by only picking the first qualifiers.

## How was this patch tested?

(Please explain how this patch was tested. E.g. unit tests, integration tests, manual tests)

Existing tests should be enough.

Author: Cheng Lian <lian@databricks.com>

Closes #11820 from liancheng/spark-14004-single-qualifier.
parent 0acb32a3
No related branches found
No related tags found
No related merge requests found
......@@ -183,8 +183,7 @@ case class Alias(child: Expression, name: String)(
}
override def sql: String = {
val qualifiersString =
if (qualifiers.isEmpty) "" else qualifiers.map(quoteIdentifier).mkString("", ".", ".")
val qualifiersString = if (qualifiers.isEmpty) "" else qualifiers.head + "."
s"${child.sql} AS $qualifiersString${quoteIdentifier(name)}"
}
}
......@@ -299,8 +298,7 @@ case class AttributeReference(
override def simpleString: String = s"$name#${exprId.id}: ${dataType.simpleString}"
override def sql: String = {
val qualifiersString =
if (qualifiers.isEmpty) "" else qualifiers.map(quoteIdentifier).mkString("", ".", ".")
val qualifiersString = if (qualifiers.isEmpty) "" else qualifiers.head + "."
s"$qualifiersString${quoteIdentifier(name)}"
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment