[ 
https://issues.apache.org/jira/browse/SPARK-52621?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Max Gekk updated SPARK-52621:
-----------------------------
    Description: 
h2. What

Support {{CAST}} in both directions between {{TIME}} and {{VARIANT}}.

h2. Key design decision

The Spark Variant binary encoding has no native TIME primitive today. The 
ticket must pick
and document one of:
* (Preferred) Add a TIME primitive to the Variant encoding so the value and its 
precision
  round-trip losslessly, consistent with how TIMESTAMP/TIMESTAMP_NTZ are 
encoded; or
* Encode TIME as a Variant string (ISO-8601 {{HH:mm:ss[.fffffffff]}}) when no 
primitive is
  added - lossless textually but typed as string on the way out.

State the chosen representation explicitly in the ticket and in the Variant 
spec doc.

h2. Semantics

* {{CAST(time AS VARIANT)}}: produce the representation above, preserving 
fractional-seconds
  precision.
* {{CAST(variant AS TIME(p))}}: accept the TIME primitive (or a string 
parseable by
  {{stringToTime}}); truncate fractional seconds to {{p}}; invalid content 
follows
  {{try_variant_get}}/cast null-vs-error rules for ANSI/non-ANSI.

h2. Scope

* {{VariantGet.checkDataType}} already accepts {{DatetimeType}}; implement the 
actual
  encode/decode in the Variant build/get paths (the current generic path has no
  {{Type.TIME}}).
* Temporal interplay with {{variant_get}}, {{to_variant}}, 
{{schema_of_variant}}.

h2. Acceptance criteria

* {{cast(cast(t as variant) as time)}} round-trips for precisions 0..9 
(coordinate with
  the precision-9 extension SPARK-57551).
* Tests in the variant cast suites and SQL golden files.

  was:Support casting the TIME data type to/from the VARIANT type.


> Cast TIME to/from VARIANT
> -------------------------
>
>                 Key: SPARK-52621
>                 URL: https://issues.apache.org/jira/browse/SPARK-52621
>             Project: Spark
>          Issue Type: Sub-task
>          Components: SQL
>    Affects Versions: 4.1.0
>            Reporter: Max Gekk
>            Priority: Major
>              Labels: pull-request-available
>
> h2. What
> Support {{CAST}} in both directions between {{TIME}} and {{VARIANT}}.
> h2. Key design decision
> The Spark Variant binary encoding has no native TIME primitive today. The 
> ticket must pick
> and document one of:
> * (Preferred) Add a TIME primitive to the Variant encoding so the value and 
> its precision
>   round-trip losslessly, consistent with how TIMESTAMP/TIMESTAMP_NTZ are 
> encoded; or
> * Encode TIME as a Variant string (ISO-8601 {{HH:mm:ss[.fffffffff]}}) when no 
> primitive is
>   added - lossless textually but typed as string on the way out.
> State the chosen representation explicitly in the ticket and in the Variant 
> spec doc.
> h2. Semantics
> * {{CAST(time AS VARIANT)}}: produce the representation above, preserving 
> fractional-seconds
>   precision.
> * {{CAST(variant AS TIME(p))}}: accept the TIME primitive (or a string 
> parseable by
>   {{stringToTime}}); truncate fractional seconds to {{p}}; invalid content 
> follows
>   {{try_variant_get}}/cast null-vs-error rules for ANSI/non-ANSI.
> h2. Scope
> * {{VariantGet.checkDataType}} already accepts {{DatetimeType}}; implement 
> the actual
>   encode/decode in the Variant build/get paths (the current generic path has 
> no
>   {{Type.TIME}}).
> * Temporal interplay with {{variant_get}}, {{to_variant}}, 
> {{schema_of_variant}}.
> h2. Acceptance criteria
> * {{cast(cast(t as variant) as time)}} round-trips for precisions 0..9 
> (coordinate with
>   the precision-9 extension SPARK-57551).
> * Tests in the variant cast suites and SQL golden files.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to