Skip to content
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 @@ -563,7 +563,9 @@ class Analyzer(
private object AliasedGenerator {
def unapply(e: Expression): Option[(Generator, Seq[String])] = e match {
case Alias(g: Generator, name)
if g.elementTypes.size > 1 && java.util.regex.Pattern.matches("_c[0-9]+", name) => {
if g.resolved &&
g.elementTypes.size > 1 &&
java.util.regex.Pattern.matches("_c[0-9]+", name) => {
// Assume the default name given by parser is "_c[0-9]+",
// TODO in long term, move the naming logic from Parser to Analyzer.
// In projection, Parser gave default name for TGF as does for normal UDF,
Expand All @@ -572,7 +574,7 @@ class Analyzer(
// Let's simply ignore the default given name for this case.
Some((g, Nil))
}
case Alias(g: Generator, name) if g.elementTypes.size > 1 =>
case Alias(g: Generator, name) if g.resolved && g.elementTypes.size > 1 =>
// If not given the default names, and the TGF with multiple output columns
failAnalysis(
s"""Expect multiple names given for ${g.getClass.getName},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,14 @@ class DataFrameSuite extends QueryTest {
)
}

test("explode alias and star") {
val df = Seq((Array("a"), 1)).toDF("a", "b")

checkAnswer(
df.select(explode($"a").as("a"), $"*"),
Row("a", Seq("a"), 1) :: Nil)
}

test("selectExpr") {
checkAnswer(
testData.selectExpr("abs(key)", "value"),
Expand Down