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 @@ -378,6 +378,7 @@ case class OuterReference(e: NamedExpression)
override def nullable: Boolean = e.nullable
override def prettyName: String = "outer"

override def sql: String = s"$prettyName(${e.sql})"
override def name: String = e.name
override def qualifier: Seq[String] = e.qualifier
override def exprId: ExprId = e.exprId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -641,12 +641,12 @@ class AnalysisErrorSuite extends AnalysisTest {
val t1 = LocalRelation(a, b)
val t2 = LocalRelation(c)
val conditions = Seq(
(abs($"a") === $"c", "abs(`a`) = outer()"),
(abs($"a") <=> $"c", "abs(`a`) <=> outer()"),
($"a" + 1 === $"c", "(`a` + 1) = outer()"),
($"a" + $"b" === $"c", "(`a` + `b`) = outer()"),
($"a" + $"c" === $"b", "(`a` + outer()) = `b`"),
(And($"a" === $"c", Cast($"a", IntegerType) === $"c"), "CAST(`a` AS INT) = outer()"))
(abs($"a") === $"c", "abs(`a`) = outer(`c`)"),
(abs($"a") <=> $"c", "abs(`a`) <=> outer(`c`)"),
($"a" + 1 === $"c", "(`a` + 1) = outer(`c`)"),
($"a" + $"b" === $"c", "(`a` + `b`) = outer(`c`)"),
($"a" + $"c" === $"b", "(`a` + outer(`c`)) = `b`"),
(And($"a" === $"c", Cast($"a", IntegerType) === $"c"), "CAST(`a` AS INT) = outer(`c`)"))
conditions.foreach { case (cond, msg) =>
val plan = Project(
ScalarSubquery(
Expand Down
18 changes: 9 additions & 9 deletions sql/core/src/test/resources/sql-tests/results/having.sql.out
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Automatically generated by SQLQueryTestSuite
-- Number of queries: 9
-- Number of queries: 13


-- !query 0
Expand Down Expand Up @@ -85,31 +85,31 @@ struct<b:bigint>

-- !query 9
SELECT c1 FROM VALUES (1, 2) as t(c1, c2) GROUP BY GROUPING SETS(t.c1) HAVING t.c1 = 1
-- !query schema
-- !query 9 schema
struct<c1:int>
-- !query output
-- !query 9 output
1


-- !query 10
SELECT c1 FROM VALUES (1, 2) as t(c1, c2) GROUP BY CUBE(t.c1) HAVING t.c1 = 1
-- !query schema
-- !query 10 schema
struct<c1:int>
-- !query output
-- !query 10 output
1


-- !query 11
SELECT c1 FROM VALUES (1, 2) as t(c1, c2) GROUP BY ROLLUP(t.c1) HAVING t.c1 = 1
-- !query schema
-- !query 11 schema
struct<c1:int>
-- !query output
-- !query 11 output
1


-- !query 12
SELECT c1 FROM VALUES (1, 2) as t(c1, c2) GROUP BY t.c1 HAVING t.c1 = 1
-- !query schema
-- !query 12 schema
struct<c1:int>
-- !query output
-- !query 12 output
1
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ struct<>
-- !query 7 output
org.apache.spark.sql.AnalysisException
Expressions referencing the outer query are not supported outside of WHERE/HAVING clauses:
Aggregate [min(outer(t2a#x)) AS min(outer())#x]
Aggregate [min(outer(t2a#x)) AS min(outer(t2.`t2a`))#x]
+- SubqueryAlias `t3`
+- Project [t3a#x, t3b#x, t3c#x]
+- SubqueryAlias `t3`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ class SubquerySuite extends QueryTest with SharedSQLContext {
sql("select a, (select sum(b) from l l2 where l2.a < l1.a) sum_b from l l1")
}
assert(msg1.getMessage.contains(
"Correlated column is not allowed in predicate (l2.`a` < outer())"))
"Correlated column is not allowed in predicate (l2.`a` < outer(l1.`a`))"))
}

test("disjunctive correlated scalar subquery") {
Expand Down