Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
blocking TABLESAMPLE
  • Loading branch information
nsyca committed Aug 5, 2016
commit 29f82b05c9e40e7934397257c674b260a8e8a996
Original file line number Diff line number Diff line change
Expand Up @@ -1021,16 +1021,19 @@ class Analyzer(
case e: Expand =>
failOnOuterReferenceInSubTree(e, "an EXPAND")
e
case l @ LocalLimit(_, child) =>
case l @ LocalLimit(_, _) =>
failOnOuterReferenceInSubTree(l, "a LIMIT")
l
// Since LIMIT <n> is represented as GlobalLimit(<n>, (LocalLimit (<n>, child))
// and we are walking bottom up, we will fail on LocalLimit before
// reaching GlobalLimit.
// The code below is just a safety net.
case g @ GlobalLimit(_, child) =>
case g @ GlobalLimit(_, _) =>
failOnOuterReferenceInSubTree(g, "a LIMIT")
g
case s @ Sample(_, _, _, _, _) =>
failOnOuterReferenceInSubTree(s, "a TABLESAMPLE")
s
case p =>
failOnOuterReference(p)
p
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,5 +541,13 @@ class AnalysisErrorSuite extends AnalysisTest {
),
LocalRelation(a))
assertAnalysisError(plan4, "Accessing outer query column is not allowed in a LIMIT" :: Nil)

val plan5 = Filter(
Exists(
Sample(0.0, 0.5, false, 1L,
Filter(EqualTo(OuterReference(a), b), LocalRelation(b)))().select('b)
),
LocalRelation(a))
assertAnalysisError(plan5, "Accessing outer query column is not allowed in a TABLESAMPLE" :: Nil)
}
}