Skip to content

Commit

Permalink
follow up: support select array(key, *) from src
Browse files Browse the repository at this point in the history
  • Loading branch information
scwf committed Feb 4, 2015
2 parents e380d2d + 6ae00db commit 0942fb1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,12 @@ class Analyzer(catalog: Catalog,
case o => o :: Nil
}
Alias(child = f.copy(children = expandedArgs), name)() :: Nil
case Alias(c @ CreateArray(args), name) if containsStar(args) =>
val expandedArgs = args.flatMap {
case s: Star => s.expand(child.output, resolver)
case o => o :: Nil
}
Alias(c.copy(children = expandedArgs), name)() :: Nil
case o => o :: Nil
},
child)
Expand Down Expand Up @@ -305,7 +311,14 @@ class Analyzer(catalog: Catalog,
* Returns true if `exprs` contains a [[Star]].
*/
protected def containsStar(exprs: Seq[Expression]): Boolean =
<<<<<<< HEAD
exprs.exists(_.collect { case _: Star => true }.nonEmpty)
=======
exprs.flatMap { _ collect {
case s: Star => true
}
}.nonEmpty
>>>>>>> 6ae00db691c4d51c6b99904b4b1984382add313b
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,8 @@ class HiveQuerySuite extends HiveComparisonTest with BeforeAndAfter {
test("SPARK-5367: resolve star expression in udf") {
assert(sql("select concat(*) from src limit 5").collect().size == 5)
assert(sql("select array(*) from src limit 5").collect().size == 5)
assert(sql("select concat(key, *) from src limit 5").collect().size == 5)
assert(sql("select array(key, *) from src limit 5").collect().size == 5)
}

test("Query Hive native command execution result") {
Expand Down

0 comments on commit 0942fb1

Please sign in to comment.