-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-7199][SQL] Add date and timestamp support to UnsafeRow #5984
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 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
4c07b57
Add date and timestamp support to UnsafeRow.
viirya e42a809
Fix style.
viirya fcf8db9
Add functions for Date and Timestamp to SpecificRow.
viirya 752251f
Support setDate. Fix failed test.
viirya b16994e
Merge remote-tracking branch 'upstream/master' into add_date_timestamp
viirya 46946c6
Adapt for moved DateUtils.
viirya 635388a
Merge remote-tracking branch 'upstream/master' into add_date_timestamp
viirya a463e83
Use Long to store timestamp for rows.
viirya f4f5de6
Fix scala style.
viirya 80af342
Fix compiling error.
viirya fb532b5
Merge remote-tracking branch 'upstream/master' into add_date_timestamp
viirya 281e844
Fix scala style.
viirya 9f3e577
Merge remote-tracking branch 'upstream/master' into add_date_timestamp
viirya 672ef17
Remove getter/setter for Date and Timestamp and use Int and Long for …
viirya c30d490
Use default IntUnsafeColumnWriter and LongUnsafeColumnWriter.
viirya 0b89698
Add timestamp to settableFieldTypes.
viirya 7f21ce9
For comment.
viirya 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
Merge remote-tracking branch 'upstream/master' into add_date_timestamp
Conflicts: sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/UnsafeRow.java sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/rows.scala
- Loading branch information
commit fb532b5af87d2c2edc440a383397c28081067619
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| package org.apache.spark.sql.catalyst.expressions | ||
|
|
||
| import org.apache.spark.sql.catalyst.util.DateUtils | ||
| import org.apache.spark.sql.catalyst.InternalRow | ||
| import org.apache.spark.sql.types._ | ||
| import org.apache.spark.unsafe.PlatformDependent | ||
| import org.apache.spark.unsafe.array.ByteArrayMethods | ||
|
|
@@ -265,24 +266,24 @@ private class StringUnsafeColumnWriter private() extends UnsafeColumnWriter { | |
| } | ||
|
|
||
| private class DateUnsafeColumnWriter private() extends UnsafeColumnWriter { | ||
| def getSize(source: Row, column: Int): Int = { | ||
| def getSize(source: InternalRow, column: Int): Int = { | ||
| 0 | ||
| } | ||
|
|
||
| override def write(source: Row, target: UnsafeRow, column: Int, appendCursor: Int): Int = { | ||
| override def write(source: InternalRow, target: UnsafeRow, column: Int, appendCursor: Int): Int = { | ||
| target.setDate(column, source.getDate(column)) | ||
| 0 | ||
| } | ||
| } | ||
|
|
||
| private class TimestampUnsafeColumnWriter private() extends UnsafeColumnWriter { | ||
| def getSize(source: Row, column: Int): Int = { | ||
| def getSize(source: InternalRow, column: Int): Int = { | ||
| // Although Timestamp is fixed length, it needs 12-byte that is more than 8-byte word per field. | ||
| // So we need to store it at the variable-length section. | ||
| 16 | ||
|
||
| } | ||
|
|
||
| override def write(source: Row, target: UnsafeRow, column: Int, appendCursor: Int): Int = { | ||
| override def write(source: InternalRow, target: UnsafeRow, column: Int, appendCursor: Int): Int = { | ||
| val value = DateUtils.toJavaTimestamp(source.get(column).asInstanceOf[Long]) | ||
|
||
| val time = value.getTime() | ||
| val nanos = value.getNanos() | ||
|
|
||
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
You are viewing a condensed version of this merge commit. You can view the full changes here.
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.
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.
We should use
target.setInt(column, source.getInt(column))