-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-19451][SQL] rangeBetween method should accept Long value as boundary #18540
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
Changes from all commits
f7baf92
3c0718b
a761f63
427753d
43b2399
5c9a992
a1f91cd
9abdb5e
7d05c3d
9b8a19b
fbcea1e
38b04df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,6 +59,7 @@ object TypeCoercion { | |
| PropagateTypes :: | ||
| ImplicitTypeCasts :: | ||
| DateTimeOperations :: | ||
| WindowFrameCoercion :: | ||
| Nil | ||
|
|
||
| // See https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Types. | ||
|
|
@@ -805,4 +806,26 @@ object TypeCoercion { | |
| Option(ret) | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Cast WindowFrame boundaries to the type they operate upon. | ||
| */ | ||
| object WindowFrameCoercion extends Rule[LogicalPlan] { | ||
|
||
| def apply(plan: LogicalPlan): LogicalPlan = plan resolveExpressions { | ||
| case s @ WindowSpecDefinition(_, Seq(order), SpecifiedWindowFrame(RangeFrame, lower, upper)) | ||
| if order.resolved => | ||
| s.copy(frameSpecification = SpecifiedWindowFrame( | ||
| RangeFrame, | ||
| createBoundaryCast(lower, order.dataType), | ||
| createBoundaryCast(upper, order.dataType))) | ||
| } | ||
|
|
||
| private def createBoundaryCast(boundary: Expression, dt: DataType): Expression = { | ||
| boundary match { | ||
| case e: SpecialFrameBoundary => e | ||
| case e: Expression if e.dataType != dt && Cast.canCast(e.dataType, dt) => Cast(e, dt) | ||
| case _ => boundary | ||
| } | ||
| } | ||
| } | ||
| } | ||
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.
The verification is moved to
checkInputDataTypes, right?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.
yea