Skip to content

Commit 4df60a8

Browse files
adrian-wangmarmbrus
authored andcommitted
[SPARK-4529] [SQL] support view with column alias
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 <[email protected]> Closes #3396 from adrian-wang/viewcolumn and squashes the following commits: 4d001d0 [Daoyuan Wang] support view with column alias
1 parent 5edbcbf commit 4df60a8

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveQl.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ private[hive] object HiveQl {
379379
protected def nameExpressions(exprs: Seq[Expression]): Seq[NamedExpression] = {
380380
exprs.zipWithIndex.map {
381381
case (ne: NamedExpression, _) => ne
382-
case (e, i) => Alias(e, s"c_$i")()
382+
case (e, i) => Alias(e, s"_c$i")()
383383
}
384384
}
385385

sql/hive/src/main/scala/org/apache/spark/sql/hive/hiveUdfs.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ private[hive] case class HiveGenericUdtf(
279279
}
280280

281281
override protected def makeOutput() = {
282-
// Use column names when given, otherwise c_1, c_2, ... c_n.
282+
// Use column names when given, otherwise _c1, _c2, ... _cn.
283283
if (aliasNames.size == outputDataTypes.size) {
284284
aliasNames.zip(outputDataTypes).map {
285285
case (attrName, attrDataType) =>
@@ -288,7 +288,7 @@ private[hive] case class HiveGenericUdtf(
288288
} else {
289289
outputDataTypes.zipWithIndex.map {
290290
case (attrDataType, i) =>
291-
AttributeReference(s"c_$i", attrDataType, nullable = true)()
291+
AttributeReference(s"_c$i", attrDataType, nullable = true)()
292292
}
293293
}
294294
}

0 commit comments

Comments
 (0)