gengliangwang commented on a change in pull request #33640:
URL: https://github.com/apache/spark/pull/33640#discussion_r683158333



##########
File path: sql/core/src/test/resources/sql-tests/inputs/date.sql
##########
@@ -0,0 +1,106 @@
+-- date literals, functions and operations
+
+select date '2019-01-01\t';
+select date '2020-01-01中文';
+
+-- date with year outside [0000-9999]
+select date'999999-03-18', date'-0001-1-28', date'0015';
+-- invalid: year field must have at least 4 digits
+select date'015';
+-- invalid: month field can have at most 2 digits
+select date'2021-4294967297-11';
+
+select current_date = current_date;
+-- under ANSI mode, `current_date` can't be a function name.
+select current_date() = current_date();
+
+-- conversions between date and unix_date (number of days from epoch)
+select DATE_FROM_UNIX_DATE(0), DATE_FROM_UNIX_DATE(1000), 
DATE_FROM_UNIX_DATE(null);
+select UNIX_DATE(DATE('1970-01-01')), UNIX_DATE(DATE('2020-12-04')), 
UNIX_DATE(null);
+
+select to_date(null), to_date('2016-12-31'), to_date('2016-12-31', 
'yyyy-MM-dd');
+
+-- missing fields in `to_date`
+select to_date("16", "dd");
+-- invalid: there is no 29 in February, 1970
+select to_date("02-29", "MM-dd");
+
+-- `dayofweek` accepts both date and timestamp inputs.
+select dayofweek('2007-02-03'), dayofweek('2009-07-30'), 
dayofweek('2017-05-27'),
+  dayofweek(null), dayofweek('1582-10-15 13:10:15'), 
dayofweek(timestamp'1582-10-15 13:10:15');
+
+-- `weekday` accepts both date and timestamp inputs.
+select weekday('2007-02-03'), weekday('2009-07-30'), weekday('2017-05-27'),
+  weekday(null), weekday('1582-10-15 13:10:15'), weekday(timestamp'1582-10-15 
13:10:15');
+
+-- `year` accepts both date and timestamp inputs.
+select year('1500-01-01'), year('1582-10-15 13:10:15'), 
year(timestamp'1582-10-15 13:10:15');

Review comment:
       ditto




-- 
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-unsubscr...@spark.apache.org

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



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

Reply via email to