Skip to content

Commit bc3b6cb

Browse files
Nathan Howellmarmbrus
authored andcommitted
[SPARK-3858][SQL] Pass the generator alias into logical plan node
The alias parameter is being ignored, which makes it more difficult to specify a qualifier for Generator expressions. Author: Nathan Howell <[email protected]> Closes apache#2721 from NathanHowell/SPARK-3858 and squashes the following commits: 8aa0f43 [Nathan Howell] [SPARK-3858][SQL] Pass the generator alias into logical plan node
1 parent 0c0e09f commit bc3b6cb

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

sql/core/src/main/scala/org/apache/spark/sql/SchemaRDD.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ class SchemaRDD(
360360
join: Boolean = false,
361361
outer: Boolean = false,
362362
alias: Option[String] = None) =
363-
new SchemaRDD(sqlContext, Generate(generator, join, outer, None, logicalPlan))
363+
new SchemaRDD(sqlContext, Generate(generator, join, outer, alias, logicalPlan))
364364

365365
/**
366366
* Returns this RDD as a SchemaRDD. Intended primarily to force the invocation of the implicit

sql/core/src/test/scala/org/apache/spark/sql/DslQuerySuite.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,14 @@ class DslQuerySuite extends QueryTest {
147147
(1, 1, 1, 2) :: Nil)
148148
}
149149

150+
test("SPARK-3858 generator qualifiers are discarded") {
151+
checkAnswer(
152+
arrayData.as('ad)
153+
.generate(Explode("data" :: Nil, 'data), alias = Some("ex"))
154+
.select("ex.data".attr),
155+
Seq(1, 2, 3, 2, 3, 4).map(Seq(_)))
156+
}
157+
150158
test("average") {
151159
checkAnswer(
152160
testData2.groupBy()(avg('a)),

0 commit comments

Comments
 (0)