[SPARK-7834] [SQL] Better window error messages

Author: Michael Armbrust <michael@databricks.com>

Closes #6363 from marmbrus/windowErrors and squashes the following commits:

516b02d [Michael Armbrust] [SPARK-7834] [SQL] Better window error messages

(cherry picked from commit 3c1305107a)
Signed-off-by: Michael Armbrust <michael@databricks.com>
This commit is contained in:
Michael Armbrust 2015-05-22 17:23:12 -07:00
parent afde4019b8
commit d7660dc2f5
2 changed files with 18 additions and 0 deletions

View file

@ -71,6 +71,11 @@ trait CheckAnalysis {
s"invalid expression ${b.prettyString} " + s"invalid expression ${b.prettyString} " +
s"between ${b.left.dataType.simpleString} and ${b.right.dataType.simpleString}") s"between ${b.left.dataType.simpleString} and ${b.right.dataType.simpleString}")
case WindowExpression(UnresolvedWindowFunction(name, _), _) =>
failAnalysis(
s"Could not resolve window function '$name'. " +
"Note that, using window functions currently requires a HiveContext")
case w @ WindowExpression(windowFunction, windowSpec) if windowSpec.validate.nonEmpty => case w @ WindowExpression(windowFunction, windowSpec) if windowSpec.validate.nonEmpty =>
// The window spec is not valid. // The window spec is not valid.
val reason = windowSpec.validate.get val reason = windowSpec.validate.get

View file

@ -166,6 +166,19 @@ class AnalysisSuite extends FunSuite with BeforeAndAfter {
} }
} }
errorTest(
"unresolved window function",
testRelation2.select(
WindowExpression(
UnresolvedWindowFunction(
"lead",
UnresolvedAttribute("c") :: Nil),
WindowSpecDefinition(
UnresolvedAttribute("a") :: Nil,
SortOrder(UnresolvedAttribute("b"), Ascending) :: Nil,
UnspecifiedFrame)).as('window)),
"lead" :: "window functions currently requires a HiveContext" :: Nil)
errorTest( errorTest(
"too many generators", "too many generators",
listRelation.select(Explode('list).as('a), Explode('list).as('b)), listRelation.select(Explode('list).as('a), Explode('list).as('b)),