Skip to content

Commit

Permalink
Fix scala test.
Browse files Browse the repository at this point in the history
  • Loading branch information
rxin committed Feb 2, 2015
1 parent 17f6bae commit 5afe1ff
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -795,21 +795,19 @@ class SQLQuerySuite extends QueryTest with BeforeAndAfterAll {

test("throw errors for non-aggregate attributes with aggregation") {
def checkAggregation(query: String, isInvalidQuery: Boolean = true) {
val logicalPlan = sql(query).queryExecution.logical

if (isInvalidQuery) {
val e = intercept[TreeNodeException[LogicalPlan]](sql(query).queryExecution.analyzed)
assert(
e.getMessage.startsWith("Expression not in GROUP BY"),
"Non-aggregate attribute(s) not detected\n" + logicalPlan)
"Non-aggregate attribute(s) not detected\n")
} else {
// Should not throw
sql(query).queryExecution.analyzed
}
}

checkAggregation("SELECT key, COUNT(*) FROM testData")
checkAggregation("SELECT COUNT(key), COUNT(*) FROM testData", false)
checkAggregation("SELECT COUNT(key), COUNT(*) FROM testData", isInvalidQuery = false)

checkAggregation("SELECT value, COUNT(*) FROM testData GROUP BY key")
checkAggregation("SELECT COUNT(value), SUM(key) FROM testData GROUP BY key", false)
Expand Down

0 comments on commit 5afe1ff

Please sign in to comment.