cloud-fan commented on a change in pull request #27906: [SPARK-31150][SQL] 
Parsing seconds fraction with variable length for timestamp
URL: https://github.com/apache/spark/pull/27906#discussion_r393437428
 
 

 ##########
 File path: sql/core/src/test/resources/sql-tests/results/datetime.sql.out
 ##########
 @@ -391,3 +391,163 @@ select date '2001-10-01' - date '2001-09-28'
 struct<subtractdates(DATE '2001-10-01', DATE '2001-09-28'):interval>
 -- !query output
 3 days
+
+
+-- !query
+select to_timestamp('2019-10-06 10:11:12.', 'yyyy-MM-dd HH:mm:ss.SSSSSS[zzz]')
+-- !query schema
+struct<to_timestamp('2019-10-06 10:11:12.', 'yyyy-MM-dd 
HH:mm:ss.SSSSSS[zzz]'):timestamp>
+-- !query output
+NULL
+
+
+-- !query
+select to_timestamp('2019-10-06 10:11:12.0', 'yyyy-MM-dd HH:mm:ss.SSSSSS[zzz]')
+-- !query schema
+struct<to_timestamp('2019-10-06 10:11:12.0', 'yyyy-MM-dd 
HH:mm:ss.SSSSSS[zzz]'):timestamp>
+-- !query output
+2019-10-06 10:11:12
+
+
+-- !query
+select to_timestamp('2019-10-06 10:11:12.1', 'yyyy-MM-dd HH:mm:ss.SSSSSS[zzz]')
+-- !query schema
+struct<to_timestamp('2019-10-06 10:11:12.1', 'yyyy-MM-dd 
HH:mm:ss.SSSSSS[zzz]'):timestamp>
+-- !query output
+2019-10-06 10:11:12.1
+
+
+-- !query
+select to_timestamp('2019-10-06 10:11:12.12', 'yyyy-MM-dd 
HH:mm:ss.SSSSSS[zzz]')
+-- !query schema
+struct<to_timestamp('2019-10-06 10:11:12.12', 'yyyy-MM-dd 
HH:mm:ss.SSSSSS[zzz]'):timestamp>
+-- !query output
+2019-10-06 10:11:12.12
+
+
+-- !query
+select to_timestamp('2019-10-06 10:11:12.123UTC', 'yyyy-MM-dd 
HH:mm:ss.SSSSSS[zzz]')
+-- !query schema
+struct<to_timestamp('2019-10-06 10:11:12.123UTC', 'yyyy-MM-dd 
HH:mm:ss.SSSSSS[zzz]'):timestamp>
+-- !query output
+2019-10-06 03:11:12.123
+
+
+-- !query
+select to_timestamp('2019-10-06 10:11:12.1234', 'yyyy-MM-dd 
HH:mm:ss.SSSSSS[zzz]')
+-- !query schema
+struct<to_timestamp('2019-10-06 10:11:12.1234', 'yyyy-MM-dd 
HH:mm:ss.SSSSSS[zzz]'):timestamp>
+-- !query output
+2019-10-06 10:11:12.1234
+
+
+-- !query
+select to_timestamp('2019-10-06 10:11:12.12345CST', 'yyyy-MM-dd 
HH:mm:ss.SSSSSS[zzz]')
+-- !query schema
+struct<to_timestamp('2019-10-06 10:11:12.12345CST', 'yyyy-MM-dd 
HH:mm:ss.SSSSSS[zzz]'):timestamp>
+-- !query output
+2019-10-06 08:11:12.12345
+
+
+-- !query
+select to_timestamp('2019-10-06 10:11:12.123456PST', 'yyyy-MM-dd 
HH:mm:ss.SSSSSS[zzz]')
+-- !query schema
+struct<to_timestamp('2019-10-06 10:11:12.123456PST', 'yyyy-MM-dd 
HH:mm:ss.SSSSSS[zzz]'):timestamp>
+-- !query output
+2019-10-06 10:11:12.123456
+
+
+-- !query
+select to_timestamp('2019-10-06 10:11:12.1234567PST', 'yyyy-MM-dd 
HH:mm:ss.SSSSSS[zzz]')
+-- !query schema
+struct<to_timestamp('2019-10-06 10:11:12.1234567PST', 'yyyy-MM-dd 
HH:mm:ss.SSSSSS[zzz]'):timestamp>
+-- !query output
+NULL
+
+
+-- !query
+select to_timestamp('123456 2019-10-06 10:11:12.123456PST', 'SSSSSS yyyy-MM-dd 
HH:mm:ss.SSSSSS[zzz]')
+-- !query schema
+struct<to_timestamp('123456 2019-10-06 10:11:12.123456PST', 'SSSSSS yyyy-MM-dd 
HH:mm:ss.SSSSSS[zzz]'):timestamp>
+-- !query output
+2019-10-06 10:11:12.123456
+
+
+-- !query
+select to_timestamp('223456 2019-10-06 10:11:12.123456PST', 'SSSSSS yyyy-MM-dd 
HH:mm:ss.SSSSSS[zzz]')
+-- !query schema
+struct<to_timestamp('223456 2019-10-06 10:11:12.123456PST', 'SSSSSS yyyy-MM-dd 
HH:mm:ss.SSSSSS[zzz]'):timestamp>
+-- !query output
+NULL
+
+
+-- !query
+select to_timestamp('2019-10-06 10:11:12.1234', 'yyyy-MM-dd HH:mm:ss.[SSSSSS]')
+-- !query schema
+struct<to_timestamp('2019-10-06 10:11:12.1234', 'yyyy-MM-dd 
HH:mm:ss.[SSSSSS]'):timestamp>
+-- !query output
+2019-10-06 10:11:12.1234
+
+
+-- !query
+select to_timestamp('2019-10-06 10:11:12.123', 'yyyy-MM-dd HH:mm:ss[.SSSSSS]')
 
 Review comment:
   can we test the optional case? `to_timestamp('2019-10-06 10:11:12', 
'yyyy-MM-dd HH:mm:ss[.SSSSSS]')`

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to