Skip to content

Commit

Permalink
[SPARK-4529] [SQL] support view with column alias
Browse files Browse the repository at this point in the history
Support view definition like

CREATE VIEW view3(valoo)
TBLPROPERTIES ("fear" = "factor")
AS SELECT upper(value) FROM src WHERE key=86;

[valoo as the alias of upper(value)]. This is missing part of SPARK-4239, for a fully view support.

Author: Daoyuan Wang <daoyuan.wang@intel.com>

Closes #3396 from adrian-wang/viewcolumn and squashes the following commits:

4d001d0 [Daoyuan Wang] support view with column alias
  • Loading branch information
adrian-wang authored and marmbrus committed Dec 2, 2014
1 parent 5edbcbf commit 4df60a8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,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")()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,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 @@ -288,7 +288,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

0 comments on commit 4df60a8

Please sign in to comment.