-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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-50795][SQL] Store timestamp as long
type in describe
LinkedHashMap
#49513
Conversation
long
timestamp type in describe
linkedhashmap to improve of date formatlong
timestamp type in describe
linkedhashmap
long
timestamp type in describe
linkedhashmaplong
timestamp type in describe
LinkedHashMap
long
timestamp type in describe
LinkedHashMaplong
type in describe
LinkedHashMap
...core/src/main/scala/org/apache/spark/sql/execution/command/DescribeRelationJsonCommand.scala
Outdated
Show resolved
Hide resolved
val formattedValue = renamedKey match { | ||
case "created_time" | "last_access" => | ||
value match { | ||
case JLong(timestamp) if timestamp > 0 => |
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 can be negative for dates before 1970-01-01
. We should allow it
...core/src/main/scala/org/apache/spark/sql/execution/command/DescribeRelationJsonCommand.scala
Outdated
Show resolved
Hide resolved
…/DescribeRelationJsonCommand.scala
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/interface.scala
Outdated
Show resolved
Hide resolved
...core/src/main/scala/org/apache/spark/sql/execution/command/DescribeRelationJsonCommand.scala
Outdated
Show resolved
Hide resolved
@@ -80,20 +82,18 @@ trait MetadataMapSupport { | |||
.mkString("[", ", ", "]") | |||
case JInt(value) => value.toString | |||
case JDouble(value) => value.toString | |||
case JLong(value) => | |||
if (timestampKeys.contains(key)) { | |||
new Date(value).toString |
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.
Could you use Iso8601TimestampFormatter
instead of the legacy class Date
.
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 is the behavior for DESCRIBE TABLE without AS JSON, see 36d23ef#diff-f2a04f920c41d18a7d387216f86405bfdc6fb09c44ebe1bb09312ba7dde55333L136
Here we just revert it back.
thanks, merging to master/4.0! |
…dHashMap ### What changes were proposed in this pull request? When storing table metadata in the `describe` LinkedHashMap object, we retain the timestamp as a `long`data type (instead of converting to a formatted date `string` type) to allow flexibility and extensibility of `describe` date format. Formatting the date fields is delegated to the caller (e.g. describe table, describe as json, describe column, etc.). Example date for describe table: `Mon Nov 01 12:00:00 UTC 2021` Example date for describe as json: `2021-11-01T12:00:00Z` ### Why are the changes needed? Improve extensibility of `describe` and ensure backwards compatibility ### Does this PR introduce _any_ user-facing change? Affects the `describe` output date format ### How was this patch tested? Added `describe table` tests for date format ### Was this patch authored or co-authored using generative AI tooling? No Closes #49513 from asl3/asl3/describetable-dateplaintext. Lead-authored-by: Amanda Liu <[email protected]> Co-authored-by: Wenchen Fan <[email protected]> Signed-off-by: Wenchen Fan <[email protected]> (cherry picked from commit 8bbec5d) Signed-off-by: Wenchen Fan <[email protected]>
What changes were proposed in this pull request?
When storing table metadata in the
describe
LinkedHashMap object, we retain the timestamp as along
data type (instead of converting to a formatted datestring
type) to allow flexibility and extensibility ofdescribe
date format. Formatting the date fields is delegated to the caller (e.g. describe table, describe as json, describe column, etc.).Example date for describe table:
Mon Nov 01 12:00:00 UTC 2021
Example date for describe as json:
2021-11-01T12:00:00Z
Why are the changes needed?
Improve extensibility of
describe
and ensure backwards compatibilityDoes this PR introduce any user-facing change?
Affects the
describe
output date formatHow was this patch tested?
Added
describe table
tests for date formatWas this patch authored or co-authored using generative AI tooling?
No