-
Notifications
You must be signed in to change notification settings - Fork 28.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-2866][SQL] Support attributes in ORDER BY that aren't in SELECT
Minor refactoring to allow resolution either using a nodes input or output. Author: Michael Armbrust <michael@databricks.com> Closes #1795 from marmbrus/ordering and squashes the following commits: 237f580 [Michael Armbrust] style 74d833b [Michael Armbrust] newline 705d963 [Michael Armbrust] Add a rule for resolving ORDER BY expressions that reference attributes not present in the SELECT clause. 82cabda [Michael Armbrust] Generalize attribute resolution.
- Loading branch information
Showing
3 changed files
with
116 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.spark.sql.hive.execution | ||
|
||
import scala.reflect.ClassTag | ||
|
||
import org.apache.spark.sql.{SQLConf, QueryTest} | ||
import org.apache.spark.sql.execution.{BroadcastHashJoin, ShuffledHashJoin} | ||
import org.apache.spark.sql.hive.test.TestHive | ||
import org.apache.spark.sql.hive.test.TestHive._ | ||
|
||
/** | ||
* A collection of hive query tests where we generate the answers ourselves instead of depending on | ||
* Hive to generate them (in contrast to HiveQuerySuite). Often this is because the query is | ||
* valid, but Hive currently cannot execute it. | ||
*/ | ||
class SQLQuerySuite extends QueryTest { | ||
test("ordering not in select") { | ||
checkAnswer( | ||
sql("SELECT key FROM src ORDER BY value"), | ||
sql("SELECT key FROM (SELECT key, value FROM src ORDER BY value) a").collect().toSeq) | ||
} | ||
|
||
test("ordering not in agg") { | ||
checkAnswer( | ||
sql("SELECT key FROM src GROUP BY key, value ORDER BY value"), | ||
sql(""" | ||
SELECT key | ||
FROM ( | ||
SELECT key, value | ||
FROM src | ||
GROUP BY key, value | ||
ORDER BY value) a""").collect().toSeq) | ||
} | ||
} |