You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "dongjoon-hyun (via GitHub)" <gi...@apache.org> on 2026/10/19 17:31:07 UTC

[PR] [SPARK-60346][SQL] Keep the precision of `TIME(p)` in `RowEncoder` [spark]

dongjoon-hyun opened a new pull request, #59600:
URL: https://github.com/apache/spark/pull/59600

   ### What changes were proposed in this pull request?
   
   This PR aims to make `RowEncoder` keep the precision of `TIME(p)` by adding the precision to `LocalTimeEncoder`.
   
   - `LocalTimeEncoder` becomes `case class LocalTimeEncoder(precision: Int)` whose type is `TimeType(precision)`.
   - `RowEncoder` maps `TimeType(p)` to `LocalTimeEncoder(p)`.
   - The encoders inferred from `java.time.LocalTime` still use `TIME(6)` via `DEFAULT_LOCAL_TIME_ENCODER`.
   
   ### Why are the changes needed?
   
   `RowEncoder` maps every `TIME(p)` to `LocalTimeEncoder` of `TIME(6)`, and each array element is up-cast to the type of its encoder. Since `TIME(p)` can be up-cast to `TIME(6)` only when `p` is 6, collecting an array of `TIME(p)` fails for all other precisions.
   
   ```scala
   scala> spark.sql("SELECT array(TIME '12:00:00.123456789')").collect()
   org.apache.spark.sql.AnalysisException: [CANNOT_UP_CAST_DATATYPE] Cannot up cast array element from "TIME(9)" to "TIME(6)".
   ```
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. Collecting an array of `TIME(p)` works for every precision, and `Row.schema` of the collected rows reports `TIME(p)` instead of `TIME(6)`. Note that the TIME type is disabled by default (`spark.sql.timeType.enabled`).
   
   The bug exists since:
   - Apache Spark [v4.1.0](https://github.com/apache/spark/releases/tag/v4.1.0) (2025-12-11) for `TIME(0)` to `TIME(5)` (SPARK-51384)
   - Apache Spark [v4.3.0-rc1](https://github.com/apache/spark/releases/tag/v4.3.0-rc1) (2026-08-31) for `TIME(7)` to `TIME(9)` (SPARK-57551)
   
   ### How was this patch tested?
   
   Pass the CIs with the newly added test cases in `RowEncoderSuite`, `DatasetSuite` and `ArrowEncoderSuite`.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Opus 5.5


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-60346][SQL] Keep the precision of `TIME(p)` in `RowEncoder` [spark]

Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun closed pull request #59600: [SPARK-60346][SQL] Keep the precision of `TIME(p)` in `RowEncoder`
URL: https://github.com/apache/spark/pull/59600


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-60346][SQL] Keep the precision of `TIME(p)` in `RowEncoder` [spark]

Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #59600:
URL: https://github.com/apache/spark/pull/59600#issuecomment-6278129819

   Thank you so much, @HyukjinKwon !


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-60346][SQL] Keep the precision of `TIME(p)` in `RowEncoder` [spark]

Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #59600:
URL: https://github.com/apache/spark/pull/59600#issuecomment-6279757235

   **Merge Summary:**
   - merged into master https://github.com/apache/spark/commit/93e95188970931487d2a2ed8526f3fd6e0b63c34
   - merged into branch-4.x https://github.com/apache/spark/commit/17b73d333aeacbdb86006e776fe73ca6f83864ad
   
   *Posted by `merge_spark_pr.py`*


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org