You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by ya...@apache.org on 2025/02/25 02:03:54 UTC
(spark) branch master updated: [SPARK-50795][SQL][FOLLOWUP] Set isParsing to false for the timestamp formatter in DESCRIBE AS JSON
This is an automated email from the ASF dual-hosted git repository.
yao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 7feb911c814b [SPARK-50795][SQL][FOLLOWUP] Set isParsing to false for the timestamp formatter in DESCRIBE AS JSON
7feb911c814b is described below
commit 7feb911c814b3b0e285bd2b146085668e964f014
Author: Kent Yao <ya...@apache.org>
AuthorDate: Tue Feb 25 10:03:41 2025 +0800
[SPARK-50795][SQL][FOLLOWUP] Set isParsing to false for the timestamp formatter in DESCRIBE AS JSON
### What changes were proposed in this pull request?
This PR set isParsing to false for the timestamp formatter in DESCRIBE AS JSON, because the formatter is not used for parsing datetime strings
### Why are the changes needed?
Although it does not affect the final output due to the current fmt we use now being w/o 'S' portion, it can prevent potential bugs if we store/display higher-precision timestamps.
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
Existing tests
### Was this patch authored or co-authored using generative AI tooling?
No
Closes #50065 from yaooqinn/SPARK-50795.
Authored-by: Kent Yao <ya...@apache.org>
Signed-off-by: Kent Yao <ya...@apache.org>
---
.../command/DescribeRelationJsonCommand.scala | 19 ++++---------------
1 file changed, 4 insertions(+), 15 deletions(-)
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/command/DescribeRelationJsonCommand.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/command/DescribeRelationJsonCommand.scala
index 33b0e5e794ad..0607a8593fbb 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/execution/command/DescribeRelationJsonCommand.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/command/DescribeRelationJsonCommand.scala
@@ -17,7 +17,7 @@
package org.apache.spark.sql.execution.command
-import java.time.ZoneId
+import java.time.ZoneOffset
import scala.collection.mutable
@@ -31,13 +31,7 @@ import org.apache.spark.sql.catalyst.catalog.{CatalogTable, CatalogTableType, Se
import org.apache.spark.sql.catalyst.catalog.CatalogTypes.TablePartitionSpec
import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeReference}
import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan
-import org.apache.spark.sql.catalyst.util.{
- quoteIfNeeded,
- DateFormatter,
- DateTimeUtils,
- Iso8601TimestampFormatter,
- LegacyDateFormats
-}
+import org.apache.spark.sql.catalyst.util.{quoteIfNeeded, DateTimeUtils, TimestampFormatter}
import org.apache.spark.sql.classic.ClassicConversions.castToImpl
import org.apache.spark.sql.connector.catalog.CatalogV2Implicits._
import org.apache.spark.sql.connector.catalog.V1Table
@@ -59,13 +53,8 @@ case class DescribeRelationJsonCommand(
nullable = false,
new MetadataBuilder().putString("comment", "JSON metadata of the table").build())()
)) extends UnaryRunnableCommand {
- private lazy val timestampFormatter = new Iso8601TimestampFormatter(
- pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'",
- zoneId = ZoneId.of("UTC"),
- locale = DateFormatter.defaultLocale,
- legacyFormat = LegacyDateFormats.LENIENT_SIMPLE_DATE_FORMAT,
- isParsing = true
- )
+ private lazy val timestampFormatter =
+ TimestampFormatter("yyyy-MM-dd'T'HH:mm:ss'Z'", ZoneOffset.UTC, isParsing = false)
override def run(sparkSession: SparkSession): Seq[Row] = {
val jsonMap = mutable.LinkedHashMap[String, JValue]()
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org