-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-16355] [SPARK-16354] [SQL] Fix Bugs When LIMIT/TABLESAMPLE is Non-foldable, Zero or Negative #14034
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-16355] [SPARK-16354] [SQL] Fix Bugs When LIMIT/TABLESAMPLE is Non-foldable, Zero or Negative #14034
Changes from 1 commit
1255968
bdf4e56
3c402d3
5b36fbc
a2a828f
f600ba4
8fd72f6
1abdbb9
3036847
d135b77
028aa79
01137dc
0ebbdfe
dec5ad9
2e6f8d8
d66870b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,14 +50,14 @@ trait CheckAnalysis extends PredicateHelper { | |
| if (!limitExpr.foldable) { | ||
| failAnalysis( | ||
| "The argument to the LIMIT clause must evaluate to a constant value. " + | ||
| s"Limit:${limitExpr.sql}") | ||
| s"Limit:${limitExpr.sql}") | ||
| } | ||
| // Analyzer rule ResolveLimits already converts limitExpr to integers. | ||
| limitExpr match { | ||
| case IntegerLiteral(limit) if limit >= 0 => // OK | ||
| case IntegerLiteral(limit) => failAnalysis( | ||
| s"number_rows in limit clause must be equal to or greater than 0. number_rows:$limit") | ||
| case o => failAnalysis(s"""number_rows in limit clause cannot be cast to integer:"$o".""") | ||
| limitExpr.eval() match { | ||
| case o: Int if o >= 0 => // OK | ||
| case o: Int => failAnalysis( | ||
| s"number_rows in limit clause must be equal to or greater than 0. number_rows:$o") | ||
| case o => failAnalysis( | ||
|
||
| s"""number_rows in limit clause cannot be cast to integer:\"$o\".""") | ||
|
||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it must be foldable, can we just use
intas limit instead of expression?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you saying we should change the SQL parser? You know, if so, we also need to change the
TABLESAMPLE n ROWS.FYI, even Hive does not support foldable expressions.
I found that Impala supports it.
http://www.cloudera.com/documentation/archive/impala/2-x/2-1-x/topics/impala_limit.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm saying maybe we can declare Limit as
case class GlobalLimit(limit: Int, child: LogicalPlan), but it's not a small change, we could think about it later.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uh, I see. Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this may be more readable: