[ 
https://issues.apache.org/jira/browse/SPARK-29371?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16962798#comment-16962798
 ] 

Kent Yao commented on SPARK-29371:
----------------------------------

{code:java}
postgres=# select interval '1.41 years 2.51 months 2.21 weeks 15.24 days 3.31 
hours 5.38 minutes 12.3456789 seconds';
               interval
---------------------------------------
 1 year 6 mons 45 days 27:38:35.145679
(1 row)postgres=# select interval '1.42 years 2.51 months 2.21 weeks 15.24 days 
3.31 hours 5.38 minutes 12.3456789 seconds';
               interval
---------------------------------------
 1 year 7 mons 45 days 27:38:35.145679
(1 row)postgres=# select interval '1.42 years 2.51 months 2.21 weeks 15.24 days 
3.31 hours 5.38 minutes 12.3456789 seconds 2.1 milliseconds ';
ERROR:  invalid input syntax for type interval: "1.42 years 2.51 months 2.21 
weeks 15.24 days 3.31 hours 5.38 minutes 12.3456789 seconds 2.1 milliseconds "
LINE 1: select interval '1.42 years 2.51 months 2.21 weeks 15.24 day...
{code}
 # the fraction part of the year only affects the month.
 # pg not support millisecond or microsecond

> Support interval field values with fractional parts
> ---------------------------------------------------
>
>                 Key: SPARK-29371
>                 URL: https://issues.apache.org/jira/browse/SPARK-29371
>             Project: Spark
>          Issue Type: Sub-task
>          Components: SQL
>    Affects Versions: 3.0.0
>            Reporter: Maxim Gekk
>            Priority: Major
>
> In PostgreSQL, field values can have fractional parts; for example '1.5 week' 
> or '01:02:03.45'. Such input is converted to the appropriate number of 
> months, days, and seconds for storage. When this would result in a fractional 
> number of months or days, the fraction is added to the lower-order fields 
> using the conversion factors 1 month = 30 days and 1 day = 24 hours. For 
> example, '1.5 month' becomes 1 month and 15 days. Only seconds will ever be 
> shown as fractional on output. See 
> https://www.postgresql.org/docs/current/datatype-datetime.html#DATATYPE-INTERVAL-INPUT
> For example:
> {code}
> maxim=# SELECT INTERVAL '1.5 months' AS "One month 15 days";
>  One month 15 days 
> -------------------
>  1 mon 15 days
> (1 row)
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to