Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-4529] [SQL] support view with column alias #3396

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ private[hive] object HiveQl {
protected def nameExpressions(exprs: Seq[Expression]): Seq[NamedExpression] = {
exprs.zipWithIndex.map {
case (ne: NamedExpression, _) => ne
case (e, i) => Alias(e, s"c_$i")()
case (e, i) => Alias(e, s"_c$i")()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly is going on here? Have we been doing this wrong all along? or is this a Hive version specific thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked hive-{0.9.0, 0.12.0, 0.13.1}, they all use _c as the default auto-gen column alias prefix label.

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ private[hive] case class HiveGenericUdtf(
}

override protected def makeOutput() = {
// Use column names when given, otherwise c_1, c_2, ... c_n.
// Use column names when given, otherwise _c1, _c2, ... _cn.
if (aliasNames.size == outputDataTypes.size) {
aliasNames.zip(outputDataTypes).map {
case (attrName, attrDataType) =>
Expand All @@ -290,7 +290,7 @@ private[hive] case class HiveGenericUdtf(
} else {
outputDataTypes.zipWithIndex.map {
case (attrDataType, i) =>
AttributeReference(s"c_$i", attrDataType, nullable = true)()
AttributeReference(s"_c$i", attrDataType, nullable = true)()
}
}
}
Expand Down