-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-29774][SQL] Date and Timestamp type +/- null should be null as Postgres #26412
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
Closed
Closed
Changes from 25 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
0b293db
[SPARK-29774][SQL] Date and Timestamp type +/- null should be null as…
yaooqinn f726297
Merge branch 'master' into SPARK-29774
yaooqinn e7225a3
regen golden file
yaooqinn b925517
null - dates
yaooqinn cd49411
Merge branch 'master' into SPARK-29774
yaooqinn 57b13e9
support +/-
yaooqinn eab6a83
support ×/÷
yaooqinn e8b75ba
import
yaooqinn 02b3738
childResolved required
yaooqinn e89d806
regen golden file
yaooqinn 0694e07
update comments
yaooqinn 0f5618b
fix tests
yaooqinn efab3ec
fix tests
yaooqinn 1c27be1
refine case match pattern
yaooqinn 5df6980
fix ut
yaooqinn 9817d2d
hack assert Equal
yaooqinn 9808b9c
regen g f
yaooqinn b190612
AnalysisTest
yaooqinn e544137
regen g f
yaooqinn 83705fd
fix test
yaooqinn 846802d
date add/sub only work for int/smallint/tinyint
yaooqinn 4af7edb
regen g f
yaooqinn a67be30
refine
yaooqinn 9a1affd
type coercion for subtract timestamp
yaooqinn ae70022
add and reorgnize tests in datetime.sql
yaooqinn 571225b
DateExpressionsSuite
yaooqinn 6052e5a
fix py
yaooqinn 928fd86
fix py
yaooqinn 254d2d2
Revert "fix py"
yaooqinn 5dd632c
fix py
yaooqinn c84d46e
rm unresolved binary arithmetic
yaooqinn a44948e
import
yaooqinn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -151,17 +151,18 @@ case class CurrentBatchTimestamp( | |
| """, | ||
| since = "1.5.0") | ||
| case class DateAdd(startDate: Expression, days: Expression) | ||
| extends BinaryExpression with ImplicitCastInputTypes { | ||
| extends BinaryExpression with ExpectsInputTypes { | ||
|
|
||
| override def left: Expression = startDate | ||
| override def right: Expression = days | ||
|
|
||
| override def inputTypes: Seq[AbstractDataType] = Seq(DateType, IntegerType) | ||
| override def inputTypes: Seq[AbstractDataType] = | ||
| Seq(DateType, TypeCollection(IntegerType, ShortType, ByteType)) | ||
|
|
||
| override def dataType: DataType = DateType | ||
|
|
||
| override def nullSafeEval(start: Any, d: Any): Any = { | ||
| start.asInstanceOf[Int] + d.asInstanceOf[Int] | ||
| start.asInstanceOf[Int] + d.asInstanceOf[Number].intValue() | ||
| } | ||
|
|
||
| override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = { | ||
|
|
@@ -185,16 +186,17 @@ case class DateAdd(startDate: Expression, days: Expression) | |
| """, | ||
| since = "1.5.0") | ||
| case class DateSub(startDate: Expression, days: Expression) | ||
| extends BinaryExpression with ImplicitCastInputTypes { | ||
| extends BinaryExpression with ExpectsInputTypes { | ||
| override def left: Expression = startDate | ||
| override def right: Expression = days | ||
|
|
||
| override def inputTypes: Seq[AbstractDataType] = Seq(DateType, IntegerType) | ||
| override def inputTypes: Seq[AbstractDataType] = | ||
| Seq(DateType, TypeCollection(IntegerType, ShortType, ByteType)) | ||
|
|
||
| override def dataType: DataType = DateType | ||
|
|
||
| override def nullSafeEval(start: Any, d: Any): Any = { | ||
| start.asInstanceOf[Int] - d.asInstanceOf[Int] | ||
| start.asInstanceOf[Int] - d.asInstanceOf[Number].intValue() | ||
|
Contributor
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. can we add some UT in
Member
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. done |
||
| } | ||
|
|
||
| override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = { | ||
|
|
@@ -1072,7 +1074,7 @@ case class NextDay(startDate: Expression, dayOfWeek: Expression) | |
| * Adds an interval to timestamp. | ||
| */ | ||
| case class TimeAdd(start: Expression, interval: Expression, timeZoneId: Option[String] = None) | ||
| extends BinaryExpression with TimeZoneAwareExpression with ImplicitCastInputTypes { | ||
| extends BinaryExpression with TimeZoneAwareExpression with ExpectsInputTypes { | ||
|
|
||
| def this(start: Expression, interval: Expression) = this(start, interval, None) | ||
|
|
||
|
|
@@ -1187,7 +1189,7 @@ case class FromUTCTimestamp(left: Expression, right: Expression) | |
| * Subtracts an interval from timestamp. | ||
| */ | ||
| case class TimeSub(start: Expression, interval: Expression, timeZoneId: Option[String] = None) | ||
| extends BinaryExpression with TimeZoneAwareExpression with ImplicitCastInputTypes { | ||
| extends BinaryExpression with TimeZoneAwareExpression with ExpectsInputTypes { | ||
|
|
||
| def this(start: Expression, interval: Expression) = this(start, interval, None) | ||
|
|
||
|
|
@@ -2127,7 +2129,7 @@ case class DatePart(field: Expression, source: Expression, child: Expression) | |
| * between the given timestamps. | ||
| */ | ||
| case class SubtractTimestamps(endTimestamp: Expression, startTimestamp: Expression) | ||
| extends BinaryExpression with ImplicitCastInputTypes { | ||
| extends BinaryExpression with ExpectsInputTypes { | ||
|
|
||
| override def left: Expression = endTimestamp | ||
| override def right: Expression = startTimestamp | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.