Uh oh!
There was an error while loading. Please reload this page.
[SPARK-28973][SQL] Add TimeType and support java.time.LocalTime as its external type. - #25678
[SPARK-28973][SQL] Add TimeType and support java.time.LocalTime as its external type.#25678MaxGekk wants to merge 18 commits into
TimeType and support java.time.LocalTime as its external type.#25678Conversation
SparkQA
commented
Sep 4, 2019
Test build #110123 has finished for PR 25678 at commit
|
TimeType and support java.time.LocalTime as its external type.TimeType and support java.time.LocalTime as its external type.MaxGekk
commented
Sep 4, 2019
@cloud-fan@dongjoon-hyun@wangyum May I ask you to review this PR. |
SparkQA
commented
Sep 4, 2019
Test build #110125 has finished for PR 25678 at commit
|
MaxGekk
commented
Sep 8, 2019
@gatorsmile@rxin@HyukjinKwon Do you have any objections for the new type? |
MaxGekk
commented
Sep 10, 2019
@srowen WDYT of the PR? |
srowen
commented
Sep 10, 2019
It looks pretty thorough to me. I don't see a problem with supporting You're right that the more important question is whether introducing a catalyst |
MaxGekk
commented
Sep 10, 2019
@srowen Thank you for your quick response.
Parquet has appropriate logical type for |
srowen
commented
Sep 10, 2019
This is just for my education, but how is TimeType mapped to Parquet TIME here? Yes, that's good confirmation that this is a common type and we are using the same semantics as, at least, Parquet. Let's say I wrote to some other system that didn't have such a type, like an RDBMS. It would end up a long? wouldn't cause any particular problem right? |
MaxGekk
commented
Sep 10, 2019
I think in the same way as The physical Parquet type will be
|
srowen
commented
Sep 10, 2019
Just to be clear, does ParquetSchemaConverter need a new case to handle the new type then? to and from Parquet? or is it already handled. Likewise, just trying to figure out how for example our JDBC support translates this type, for an RDBMS that does support |
MaxGekk
commented
Sep 10, 2019
We will need to support new type in all data sources. In particular,
In this PR, I just introduce new type and its external type. To support it by the
and |
srowen
commented
Sep 10, 2019
OK, so we need to add those kinds of translations or else this won't properly convert to types in external systems, and the idea is to follow up with that in another PR? I think that could be fine. |
rxin
commented
Sep 10, 2019
via email
Why do we need a new data type? …On Tue, Sep 10, 2019 at 1:13 PM Sean Owen ***@***.***> wrote:
OK, so we need to add those kinds of translations or else this won't
properly convert to types in external systems, and the idea is to follow up
with that in another PR? I think that could be fine.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#25678?email_source=notifications&email_token=AACO6PBO3FEAM5AOOQIEHZTQI75WDA5CNFSM4ITR3EIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6MK5BI#issuecomment-530099845>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AACO6PHACO5BFSHODRBFMJDQI75WDANCNFSM4ITR3EIA>
.
|
HyukjinKwon
commented
Sep 11, 2019
Seems like that's answered in PR description. It targets to follow ANSI I guess:
|
MaxGekk
commented
Sep 11, 2019
@rxin , I see the following reasons to add new type
|
gatorsmile
commented
Sep 13, 2019
Supporting Time type is pretty complex and the sizing is pretty big. Can we delay it and do it in the future? |
rxin
commented
Sep 13, 2019
I haven't had a chance but I'd push back against most of the functionalities in the umbrella ticket (Postgres compatibility). While I think it's a good idea in general to align with some existing standard when a functionality exists, a blanket "implement some other database's functionality" is a dangerous umbrella, because the context and use cases are very different between Spark and "some other databases". A few reasons:
|
MaxGekk
commented
Sep 13, 2019
@rxin how about those real use cases:
Another argument for the
This argument blocks any extensions of Spark SQL type systems, actually forever. It seems implementing the |
marmbrus
commented
Sep 13, 2019
I tend to agree with @rxin here. This is a lot of long term cost without good user justification. I would be much more sympathetic to an argument that showed lots of use of the |
MaxGekk
commented
Sep 15, 2019
I am closing this PR. @srowen@rxin@marmbrus@gatorsmile@HyukjinKwon Thank you for your comments. |
rxin
commented
Sep 15, 2019
Thanks @MaxGekk. In case somebody else wonders in the future, there's a lot more complexity to adding a new type than what's shown here. For example, we need to add support for Python and R. We also need to support expressions. Those are much larger than this PR itself. |
hurelhuyag
commented
Nov 22, 2019
I'm currently using timestamp as time type for create data for rush hour graphic. date part is always epoch (1970-01-01). Because spark don't support TimeType. My point is micros is not important. We can implement it just like timestamp internally. But date part is always epoch. Only requirement is toString() should print only time part (HH:mm:ss.SSS) and mappable to java.sql.Time, java.time.LocalTime. This is enough. Maybe we can use timestamp directly. only printable representation must be only time part. |
@MaxGekk Whether to consider supporting the time type again,iceberg and parquet support time type @rxin Spark 3.2 supports INTERVAL type, whether to consider supports Time type |
redblackcoder
commented
Oct 4, 2023
@MaxGekk@rxin I am also looking into this issue of missing Time type in Spark. I am working with Iceberg tables built on top of parquet files which have Time data type support. Spark cannot read or write to such tables. |
looking forward to this feature because my iceberg table needs time data type. |
MaxGekk
commented
Feb 13, 2025
I sent the SPIP https://issues.apache.org/jira/browse/SPARK-51162 to dev list for discussion (link). @zeddit@Fokko@tundraraj@redblackcoder@melin@hurelhuyag@younggyuchun Please, leave comments in the thread if you are still interested in the feature. |
What changes were proposed in this pull request?
Proposed new type for Catalyst's type system to represent local time. According to the SQL standard, a value of data type
TIMEcomprises values of the datetime fields HOUR, MINUTE and SECOND. It is always a valid time of day.HOUR- hour within day, between 00 and 23MINUTE- minute within hour, between 00 and 59SECOND- second and possibly fraction of a second within minute. Valid range is 0-59.999999Internally, the
TIMEtype is implemented as CatalystTimeTypeand stores a number of microseconds since00:00:00.000000.The java class
java.time.LocalTimewas supported as the external type forTimeType. So, instances ofjava.time.LocalTimecan be parallelized and converted to values ofTimeType, and collected back to instances ofLocalTimeas well. Spark also accepts literals ofTimeTypewith values ofLocalTime.Created an encoder that serializes instances of the
java.time.LocalTimeclassto the internal representation of nullable Catalyst'sTimeType.Why are the changes needed?
To maintain feature parity with PostgreSQL which supports the
TIMEtype and its constructormake_time. The former function is commented indate.sqlat the moment:spark/sql/core/src/test/resources/sql-tests/inputs/pgSQL/date.sql
Line 353 in 3a4afce
To be compliant with the SQL standard
Does this PR introduce any user-facing change?
The PR extends existing functionality. So, users can parallelize instances of the
java.time.LocalTimeclass and collect them back:How was this patch tested?
CatalystTypeConvertersSuiteto check conversion from/tojava.time.LocalTime.RowEncoderSuite.TimeTypeis tested inLiteralExpressionSuiteDatasetSuiteandJavaDatasetSuite.