-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-32133][SQL] Forbid time field steps for date start/end in Sequence #28926
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
665ac46
7733184
74c683f
9f910d7
9857fdc
b0eb77f
df2138c
b863eef
9a521a3
2bd2d0b
d860c0e
8c4ffaa
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 |
|---|---|---|
|
|
@@ -2612,10 +2612,17 @@ object Sequence { | |
| val stepDays = step.days | ||
| val stepMicros = step.microseconds | ||
|
|
||
| if (scale == MICROS_PER_DAY && stepMonths == 0 && stepDays == 0) { | ||
| throw new IllegalArgumentException( | ||
| "sequence step must be a day interval if start and end values are dates") | ||
| } | ||
|
|
||
| if (stepMonths == 0 && stepMicros == 0 && scale == MICROS_PER_DAY) { | ||
|
||
| // Adding pure days to date start/end | ||
| backedSequenceImpl.eval(start, stop, fromLong(stepDays)) | ||
|
|
||
| } else if (stepMonths == 0 && stepDays == 0 && scale == 1) { | ||
| // Adding pure microseconds to timestamp start/end | ||
|
Comment on lines
+2621
to
+2625
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cloud-fan Thanks, I add more comments for pure days and months branch, the former exception check seems the exception content has enough informs, and the last branch seems have detail content. |
||
| backedSequenceImpl.eval(start, stop, fromLong(stepMicros)) | ||
|
|
||
| } else { | ||
|
|
@@ -2674,11 +2681,24 @@ object Sequence { | |
| |${genSequenceLengthCode(ctx, startMicros, stopMicros, intervalInMicros, arrLength)} | ||
| """.stripMargin | ||
|
|
||
| val check = if (scale == MICROS_PER_DAY) { | ||
| s""" | ||
| |if ($stepMonths == 0 && $stepDays == 0) { | ||
| | throw new IllegalArgumentException( | ||
| | "sequence step must be a day interval if start and end values are dates"); | ||
| |} | ||
| """.stripMargin | ||
| } else { | ||
| "" | ||
| } | ||
|
|
||
| s""" | ||
| |final int $stepMonths = $step.months; | ||
| |final int $stepDays = $step.days; | ||
| |final long $stepMicros = $step.microseconds; | ||
| | | ||
| |$check | ||
| | | ||
| |if ($stepMonths == 0 && $stepMicros == 0 && ${scale}L == ${MICROS_PER_DAY}L) { | ||
| | ${backedSequenceImpl.genCode(ctx, start, stop, stepDays, arr, elemType)}; | ||
| | | ||
|
|
||
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.
@TJX2014 can we just use
requireinstead?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 asked to throw an exception explicitly, to match the codegen code.
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 am both ok, thank you for your attention. :-)