1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
|
<sql-statement>
--
-- TIMESTAMP
--
CREATE TABLE TIMESTAMP_TBL (d1 timestamp(2) without time zone);
</sql-statement>
<sql-statement>
-- Test shorthand input values
-- We can't just "select" the results since they aren't constants; test for
-- equality instead. We can do that by running the test inside a transaction
-- block, within which the value of 'now' shouldn't change, and so these
-- related values shouldn't either.
BEGIN;
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('today');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('yesterday');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('tomorrow');
</sql-statement>
<sql-statement>
-- time zone should be ignored by this data type
INSERT INTO TIMESTAMP_TBL VALUES ('tomorrow EST');
</sql-statement>
-stdin-:<main>: Fatal: Execution
-stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
-- time zone should be ignored by this data type
^
-stdin-:<main>:1:1: Fatal: ERROR: invalid input syntax for type timestamp: "tomorrow EST"
-- time zone should be ignored by this data type
^
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('tomorrow zulu');
</sql-statement>
-stdin-:<main>: Fatal: Execution
-stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
INSERT INTO TIMESTAMP_TBL VALUES ('tomorrow zulu');
^
-stdin-:<main>:1:1: Fatal: ERROR: invalid input syntax for type timestamp: "tomorrow zulu"
INSERT INTO TIMESTAMP_TBL VALUES ('tomorrow zulu');
^
<sql-statement>
SELECT count(*) AS One FROM TIMESTAMP_TBL WHERE d1 = timestamp without time zone 'today';
</sql-statement>
<sql-statement>
SELECT count(*) AS Three FROM TIMESTAMP_TBL WHERE d1 = timestamp without time zone 'tomorrow';
</sql-statement>
<sql-statement>
SELECT count(*) AS One FROM TIMESTAMP_TBL WHERE d1 = timestamp without time zone 'yesterday';
</sql-statement>
<sql-statement>
COMMIT;
</sql-statement>
<sql-statement>
DELETE FROM TIMESTAMP_TBL;
</sql-statement>
-stdin-:<main>: Fatal: Pre type annotation
-stdin-:<main>: Fatal: tools/enum_parser/enum_serialization_runtime/enum_runtime.cpp:70: Key 'pg_delete' not found in enum NYql::EYtSettingType. Valid options are: 'initial', 'infer_scheme', 'force_infer_schema', 'do_not_fail_on_invalid_schema', 'direct_read', 'view', 'mode', 'scheme', 'weak_concat', 'anonymous', 'with_qb', 'inline', 'sample', 'joinLabel', 'ignore_non_existing', 'warn_non_existing', 'xlock', 'unordered', 'nonUnique', 'userschema', 'usercolumns', 'statcolumns', 'syscolumns', 'ignoretypev3', 'memUsage', 'itemsCount', 'rowFactor', 'ordered', 'keyFilter', 'keyFilter2', 'take', 'skip', 'limit', 'sortLimitBy', 'sortBy', 'reduceBy', 'reduceFilterBy', 'forceTransform', 'weakFields', 'sharded', 'combineChunks', 'jobCount', 'joinReduce', 'firstAsPrimary', 'flow', 'keepSorted', 'keySwitch', 'uniqueBy', 'opHash', 'mapOutputType', 'reduceInputType', 'noDq', 'split', 'compression_codec', 'erasure_codec', 'expiration', 'replication_factor', 'user_attrs', 'media', 'primary_medium', 'keep_meta', 'monotonic_keys', 'mutationid'.
<sql-statement>
-- Verify that 'now' *does* change over a reasonable interval such as 100 msec,
-- and that it doesn't change over the same interval within a transaction block
INSERT INTO TIMESTAMP_TBL VALUES ('now');
</sql-statement>
<sql-statement>
SELECT pg_sleep(0.1);
</sql-statement>
<sql-statement>
BEGIN;
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('now');
</sql-statement>
<sql-statement>
SELECT pg_sleep(0.1);
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('now');
</sql-statement>
<sql-statement>
SELECT pg_sleep(0.1);
</sql-statement>
<sql-statement>
SELECT count(*) AS two FROM TIMESTAMP_TBL WHERE d1 = timestamp(2) without time zone 'now';
</sql-statement>
<sql-statement>
SELECT count(d1) AS three, count(DISTINCT d1) AS two FROM TIMESTAMP_TBL;
</sql-statement>
<sql-statement>
COMMIT;
</sql-statement>
<sql-statement>
TRUNCATE TIMESTAMP_TBL;
</sql-statement>
-stdin-:<main>: Error: Parse Sql
-stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 257
TRUNCATE TIMESTAMP_TBL;
^
<sql-statement>
-- Special values
INSERT INTO TIMESTAMP_TBL VALUES ('-infinity');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('infinity');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('epoch');
</sql-statement>
<sql-statement>
-- Postgres v6.0 standard output format
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST');
</sql-statement>
-stdin-:<main>: Fatal: Execution
-stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
-- Postgres v6.0 standard output format
^
-stdin-:<main>:1:1: Fatal: ERROR: invalid input syntax for type timestamp: "Mon Feb 10 17:32:01 1997 PST"
-- Postgres v6.0 standard output format
^
<sql-statement>
-- Variations on Postgres v6.1 standard output format
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01.000001 1997 PST');
</sql-statement>
-stdin-:<main>: Fatal: Execution
-stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
-- Variations on Postgres v6.1 standard output format
^
-stdin-:<main>:1:1: Fatal: ERROR: invalid input syntax for type timestamp: "Mon Feb 10 17:32:01.000001 1997 PST"
-- Variations on Postgres v6.1 standard output format
^
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01.999999 1997 PST');
</sql-statement>
-stdin-:<main>: Fatal: Execution
-stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01.999999 1997 PST');
^
-stdin-:<main>:1:1: Fatal: ERROR: invalid input syntax for type timestamp: "Mon Feb 10 17:32:01.999999 1997 PST"
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01.999999 1997 PST');
^
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01.4 1997 PST');
</sql-statement>
-stdin-:<main>: Fatal: Execution
-stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01.4 1997 PST');
^
-stdin-:<main>:1:1: Fatal: ERROR: invalid input syntax for type timestamp: "Mon Feb 10 17:32:01.4 1997 PST"
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01.4 1997 PST');
^
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01.5 1997 PST');
</sql-statement>
-stdin-:<main>: Fatal: Execution
-stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01.5 1997 PST');
^
-stdin-:<main>:1:1: Fatal: ERROR: invalid input syntax for type timestamp: "Mon Feb 10 17:32:01.5 1997 PST"
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01.5 1997 PST');
^
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01.6 1997 PST');
</sql-statement>
-stdin-:<main>: Fatal: Execution
-stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01.6 1997 PST');
^
-stdin-:<main>:1:1: Fatal: ERROR: invalid input syntax for type timestamp: "Mon Feb 10 17:32:01.6 1997 PST"
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01.6 1997 PST');
^
<sql-statement>
-- ISO 8601 format
INSERT INTO TIMESTAMP_TBL VALUES ('1997-01-02');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('1997-01-02 03:04:05');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('1997-02-10 17:32:01-08');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('1997-02-10 17:32:01-0800');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('1997-02-10 17:32:01 -08:00');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('19970210 173201 -0800');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('1997-06-10 17:32:01 -07:00');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('2001-09-22T18:19:20');
</sql-statement>
<sql-statement>
-- POSIX format (note that the timezone abbrev is just decoration here)
INSERT INTO TIMESTAMP_TBL VALUES ('2000-03-15 08:14:01 GMT+8');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('2000-03-15 13:14:02 GMT-1');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('2000-03-15 12:14:03 GMT-2');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('2000-03-15 03:14:04 PST+8');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('2000-03-15 02:14:05 MST+7:00');
</sql-statement>
<sql-statement>
-- Variations for acceptable input formats
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 10 17:32:01 1997 -0800');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 10 17:32:01 1997');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 10 5:32PM 1997');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('1997/02/10 17:32:01-0800');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('1997-02-10 17:32:01 PST');
</sql-statement>
-stdin-:<main>: Fatal: Execution
-stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
INSERT INTO TIMESTAMP_TBL VALUES ('1997-02-10 17:32:01 PST');
^
-stdin-:<main>:1:1: Fatal: ERROR: invalid input syntax for type timestamp: "1997-02-10 17:32:01 PST"
INSERT INTO TIMESTAMP_TBL VALUES ('1997-02-10 17:32:01 PST');
^
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Feb-10-1997 17:32:01 PST');
</sql-statement>
-stdin-:<main>: Fatal: Execution
-stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
INSERT INTO TIMESTAMP_TBL VALUES ('Feb-10-1997 17:32:01 PST');
^
-stdin-:<main>:1:1: Fatal: ERROR: invalid input syntax for type timestamp: "Feb-10-1997 17:32:01 PST"
INSERT INTO TIMESTAMP_TBL VALUES ('Feb-10-1997 17:32:01 PST');
^
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('02-10-1997 17:32:01 PST');
</sql-statement>
-stdin-:<main>: Fatal: Execution
-stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
INSERT INTO TIMESTAMP_TBL VALUES ('02-10-1997 17:32:01 PST');
^
-stdin-:<main>:1:1: Fatal: ERROR: invalid input syntax for type timestamp: "02-10-1997 17:32:01 PST"
INSERT INTO TIMESTAMP_TBL VALUES ('02-10-1997 17:32:01 PST');
^
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('19970210 173201 PST');
</sql-statement>
-stdin-:<main>: Fatal: Execution
-stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
INSERT INTO TIMESTAMP_TBL VALUES ('19970210 173201 PST');
^
-stdin-:<main>:1:1: Fatal: ERROR: invalid input syntax for type timestamp: "19970210 173201 PST"
INSERT INTO TIMESTAMP_TBL VALUES ('19970210 173201 PST');
^
<sql-statement>
set datestyle to ymd;
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('97FEB10 5:32:01PM UTC');
</sql-statement>
-stdin-:<main>: Fatal: Execution
-stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
INSERT INTO TIMESTAMP_TBL VALUES ('97FEB10 5:32:01PM UTC');
^
-stdin-:<main>:1:1: Fatal: ERROR: invalid input syntax for type timestamp: "97FEB10 5:32:01PM UTC"
INSERT INTO TIMESTAMP_TBL VALUES ('97FEB10 5:32:01PM UTC');
^
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('97/02/10 17:32:01 UTC');
</sql-statement>
-stdin-:<main>: Fatal: Execution
-stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
INSERT INTO TIMESTAMP_TBL VALUES ('97/02/10 17:32:01 UTC');
^
-stdin-:<main>:1:1: Fatal: ERROR: invalid input syntax for type timestamp: "97/02/10 17:32:01 UTC"
INSERT INTO TIMESTAMP_TBL VALUES ('97/02/10 17:32:01 UTC');
^
<sql-statement>
reset datestyle;
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('1997.041 17:32:01 UTC');
</sql-statement>
-stdin-:<main>: Fatal: Execution
-stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
INSERT INTO TIMESTAMP_TBL VALUES ('1997.041 17:32:01 UTC');
^
-stdin-:<main>:1:1: Fatal: ERROR: invalid input syntax for type timestamp: "1997.041 17:32:01 UTC"
INSERT INTO TIMESTAMP_TBL VALUES ('1997.041 17:32:01 UTC');
^
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('19970210 173201 America/New_York');
</sql-statement>
-stdin-:<main>: Fatal: Execution
-stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
INSERT INTO TIMESTAMP_TBL VALUES ('19970210 173201 America/New_York');
^
-stdin-:<main>:1:1: Fatal: ERROR: time zone "america/new_york" not recognized
INSERT INTO TIMESTAMP_TBL VALUES ('19970210 173201 America/New_York');
^
<sql-statement>
-- this fails (even though TZ is a no-op, we still look it up)
INSERT INTO TIMESTAMP_TBL VALUES ('19970710 173201 America/Does_not_exist');
</sql-statement>
-stdin-:<main>: Fatal: Execution
-stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
-- this fails (even though TZ is a no-op, we still look it up)
^
-stdin-:<main>:1:1: Fatal: ERROR: time zone "america/does_not_exist" not recognized
-- this fails (even though TZ is a no-op, we still look it up)
^
<sql-statement>
-- Check date conversion and date arithmetic
INSERT INTO TIMESTAMP_TBL VALUES ('1997-06-10 18:32:01 PDT');
</sql-statement>
-stdin-:<main>: Fatal: Execution
-stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
-- Check date conversion and date arithmetic
^
-stdin-:<main>:1:1: Fatal: ERROR: invalid input syntax for type timestamp: "1997-06-10 18:32:01 PDT"
-- Check date conversion and date arithmetic
^
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 10 17:32:01 1997');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 11 17:32:01 1997');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 12 17:32:01 1997');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 13 17:32:01 1997');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 14 17:32:01 1997');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 15 17:32:01 1997');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 1997');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 0097 BC');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 0097');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 0597');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 1097');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 1697');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 1797');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 1897');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 1997');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 2097');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 28 17:32:01 1996');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 29 17:32:01 1996');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Mar 01 17:32:01 1996');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Dec 30 17:32:01 1996');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Dec 31 17:32:01 1996');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Jan 01 17:32:01 1997');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 28 17:32:01 1997');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 29 17:32:01 1997');
</sql-statement>
-stdin-:<main>: Fatal: Execution
-stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 29 17:32:01 1997');
^
-stdin-:<main>:1:1: Fatal: ERROR: date/time field value out of range: "Feb 29 17:32:01 1997"
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 29 17:32:01 1997');
^
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Mar 01 17:32:01 1997');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Dec 30 17:32:01 1997');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Dec 31 17:32:01 1997');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Dec 31 17:32:01 1999');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Jan 01 17:32:01 2000');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Dec 31 17:32:01 2000');
</sql-statement>
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Jan 01 17:32:01 2001');
</sql-statement>
<sql-statement>
-- Currently unsupported syntax and ranges
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 -0097');
</sql-statement>
-stdin-:<main>: Fatal: Execution
-stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
-- Currently unsupported syntax and ranges
^
-stdin-:<main>:1:1: Fatal: ERROR: time zone displacement out of range: "Feb 16 17:32:01 -0097"
-- Currently unsupported syntax and ranges
^
<sql-statement>
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 5097 BC');
</sql-statement>
-stdin-:<main>: Fatal: Execution
-stdin-:<main>:1:1: Fatal: Execution of node: YtFill!
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 5097 BC');
^
-stdin-:<main>:1:1: Fatal: ERROR: timestamp out of range: "Feb 16 17:32:01 5097 BC"
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 5097 BC');
^
<sql-statement>
SELECT d1 FROM TIMESTAMP_TBL;
</sql-statement>
<sql-statement>
-- Check behavior at the boundaries of the timestamp range
SELECT '4714-11-24 00:00:00 BC'::timestamp;
</sql-statement>
<sql-statement>
SELECT '4714-11-23 23:59:59 BC'::timestamp; -- out of range
</sql-statement>
-stdin-:<main>: Fatal: Execution
-stdin-:<main>:1:1: Fatal: Execution of node: Result
SELECT '4714-11-23 23:59:59 BC'::timestamp; -- out of range
^
-stdin-:<main>:1:1: Fatal: ERROR: timestamp out of range: "4714-11-23 23:59:59 BC"
SELECT '4714-11-23 23:59:59 BC'::timestamp; -- out of range
^
<sql-statement>
SELECT '294276-12-31 23:59:59'::timestamp;
</sql-statement>
<sql-statement>
SELECT '294277-01-01 00:00:00'::timestamp; -- out of range
</sql-statement>
-stdin-:<main>: Fatal: Execution
-stdin-:<main>:1:1: Fatal: Execution of node: Result
SELECT '294277-01-01 00:00:00'::timestamp; -- out of range
^
-stdin-:<main>:1:1: Fatal: ERROR: timestamp out of range: "294277-01-01 00:00:00"
SELECT '294277-01-01 00:00:00'::timestamp; -- out of range
^
<sql-statement>
-- Demonstrate functions and operators
SELECT d1 FROM TIMESTAMP_TBL
WHERE d1 > timestamp without time zone '1997-01-02';
</sql-statement>
<sql-statement>
SELECT d1 FROM TIMESTAMP_TBL
WHERE d1 < timestamp without time zone '1997-01-02';
</sql-statement>
<sql-statement>
SELECT d1 FROM TIMESTAMP_TBL
WHERE d1 = timestamp without time zone '1997-01-02';
</sql-statement>
<sql-statement>
SELECT d1 FROM TIMESTAMP_TBL
WHERE d1 != timestamp without time zone '1997-01-02';
</sql-statement>
<sql-statement>
SELECT d1 FROM TIMESTAMP_TBL
WHERE d1 <= timestamp without time zone '1997-01-02';
</sql-statement>
<sql-statement>
SELECT d1 FROM TIMESTAMP_TBL
WHERE d1 >= timestamp without time zone '1997-01-02';
</sql-statement>
<sql-statement>
SELECT d1 - timestamp without time zone '1997-01-02' AS diff
FROM TIMESTAMP_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01';
</sql-statement>
<sql-statement>
SELECT date_trunc( 'week', timestamp '2004-02-29 15:44:17.71393' ) AS week_trunc;
</sql-statement>
<sql-statement>
-- verify date_bin behaves the same as date_trunc for relevant intervals
-- case 1: AD dates, origin < input
SELECT
str,
interval,
date_trunc(str, ts) = date_bin(interval::interval, ts, timestamp '2001-01-01') AS equal
FROM (
VALUES
('week', '7 d'),
('day', '1 d'),
('hour', '1 h'),
('minute', '1 m'),
('second', '1 s'),
('millisecond', '1 ms'),
('microsecond', '1 us')
) intervals (str, interval),
(VALUES (timestamp '2020-02-29 15:44:17.71393')) ts (ts);
</sql-statement>
<sql-statement>
-- case 2: BC dates, origin < input
SELECT
str,
interval,
date_trunc(str, ts) = date_bin(interval::interval, ts, timestamp '2000-01-01 BC') AS equal
FROM (
VALUES
('week', '7 d'),
('day', '1 d'),
('hour', '1 h'),
('minute', '1 m'),
('second', '1 s'),
('millisecond', '1 ms'),
('microsecond', '1 us')
) intervals (str, interval),
(VALUES (timestamp '0055-6-10 15:44:17.71393 BC')) ts (ts);
</sql-statement>
<sql-statement>
-- case 3: AD dates, origin > input
SELECT
str,
interval,
date_trunc(str, ts) = date_bin(interval::interval, ts, timestamp '2020-03-02') AS equal
FROM (
VALUES
('week', '7 d'),
('day', '1 d'),
('hour', '1 h'),
('minute', '1 m'),
('second', '1 s'),
('millisecond', '1 ms'),
('microsecond', '1 us')
) intervals (str, interval),
(VALUES (timestamp '2020-02-29 15:44:17.71393')) ts (ts);
</sql-statement>
<sql-statement>
-- case 4: BC dates, origin > input
SELECT
str,
interval,
date_trunc(str, ts) = date_bin(interval::interval, ts, timestamp '0055-06-17 BC') AS equal
FROM (
VALUES
('week', '7 d'),
('day', '1 d'),
('hour', '1 h'),
('minute', '1 m'),
('second', '1 s'),
('millisecond', '1 ms'),
('microsecond', '1 us')
) intervals (str, interval),
(VALUES (timestamp '0055-6-10 15:44:17.71393 BC')) ts (ts);
</sql-statement>
<sql-statement>
-- bin timestamps into arbitrary intervals
SELECT
interval,
ts,
origin,
date_bin(interval::interval, ts, origin)
FROM (
VALUES
('15 days'),
('2 hours'),
('1 hour 30 minutes'),
('15 minutes'),
('10 seconds'),
('100 milliseconds'),
('250 microseconds')
) intervals (interval),
(VALUES (timestamp '2020-02-11 15:44:17.71393')) ts (ts),
(VALUES (timestamp '2001-01-01')) origin (origin);
</sql-statement>
<sql-statement>
-- shift bins using the origin parameter:
SELECT date_bin('5 min'::interval, timestamp '2020-02-01 01:01:01', timestamp '2020-02-01 00:02:30');
</sql-statement>
<sql-statement>
-- disallow intervals with months or years
SELECT date_bin('5 months'::interval, timestamp '2020-02-01 01:01:01', timestamp '2001-01-01');
</sql-statement>
-stdin-:<main>: Fatal: Execution
-stdin-:<main>:1:1: Fatal: Execution of node: Result
-- disallow intervals with months or years
^
-stdin-:<main>:1:1: Fatal: ERROR: timestamps cannot be binned into intervals containing months or years
-- disallow intervals with months or years
^
<sql-statement>
SELECT date_bin('5 years'::interval, timestamp '2020-02-01 01:01:01', timestamp '2001-01-01');
</sql-statement>
-stdin-:<main>: Fatal: Execution
-stdin-:<main>:1:1: Fatal: Execution of node: Result
SELECT date_bin('5 years'::interval, timestamp '2020-02-01 01:01:01', timestamp '2001-01-01');
^
-stdin-:<main>:1:1: Fatal: ERROR: timestamps cannot be binned into intervals containing months or years
SELECT date_bin('5 years'::interval, timestamp '2020-02-01 01:01:01', timestamp '2001-01-01');
^
<sql-statement>
-- disallow zero intervals
SELECT date_bin('0 days'::interval, timestamp '1970-01-01 01:00:00' , timestamp '1970-01-01 00:00:00');
</sql-statement>
-stdin-:<main>: Fatal: Execution
-stdin-:<main>:1:1: Fatal: Execution of node: Result
-- disallow zero intervals
^
-stdin-:<main>:1:1: Fatal: ERROR: stride must be greater than zero
-- disallow zero intervals
^
<sql-statement>
-- disallow negative intervals
SELECT date_bin('-2 days'::interval, timestamp '1970-01-01 01:00:00' , timestamp '1970-01-01 00:00:00');
</sql-statement>
-stdin-:<main>: Fatal: Execution
-stdin-:<main>:1:1: Fatal: Execution of node: Result
-- disallow negative intervals
^
-stdin-:<main>:1:1: Fatal: ERROR: stride must be greater than zero
-- disallow negative intervals
^
<sql-statement>
-- Test casting within a BETWEEN qualifier
SELECT d1 - timestamp without time zone '1997-01-02' AS diff
FROM TIMESTAMP_TBL
WHERE d1 BETWEEN timestamp without time zone '1902-01-01'
AND timestamp without time zone '2038-01-01';
</sql-statement>
<sql-statement>
-- DATE_PART (timestamp_part)
SELECT d1 as "timestamp",
date_part( 'year', d1) AS year, date_part( 'month', d1) AS month,
date_part( 'day', d1) AS day, date_part( 'hour', d1) AS hour,
date_part( 'minute', d1) AS minute, date_part( 'second', d1) AS second
FROM TIMESTAMP_TBL;
</sql-statement>
<sql-statement>
SELECT d1 as "timestamp",
date_part( 'quarter', d1) AS quarter, date_part( 'msec', d1) AS msec,
date_part( 'usec', d1) AS usec
FROM TIMESTAMP_TBL;
</sql-statement>
<sql-statement>
SELECT d1 as "timestamp",
date_part( 'isoyear', d1) AS isoyear, date_part( 'week', d1) AS week,
date_part( 'isodow', d1) AS isodow, date_part( 'dow', d1) AS dow,
date_part( 'doy', d1) AS doy
FROM TIMESTAMP_TBL;
</sql-statement>
<sql-statement>
SELECT d1 as "timestamp",
date_part( 'decade', d1) AS decade,
date_part( 'century', d1) AS century,
date_part( 'millennium', d1) AS millennium,
round(date_part( 'julian', d1)) AS julian,
date_part( 'epoch', d1) AS epoch
FROM TIMESTAMP_TBL;
</sql-statement>
<sql-statement>
-- extract implementation is mostly the same as date_part, so only
-- test a few cases for additional coverage.
SELECT d1 as "timestamp",
extract(microseconds from d1) AS microseconds,
extract(milliseconds from d1) AS milliseconds,
extract(seconds from d1) AS seconds,
round(extract(julian from d1)) AS julian,
extract(epoch from d1) AS epoch
FROM TIMESTAMP_TBL;
</sql-statement>
<sql-statement>
-- value near upper bound uses special case in code
SELECT date_part('epoch', '294270-01-01 00:00:00'::timestamp);
</sql-statement>
<sql-statement>
SELECT extract(epoch from '294270-01-01 00:00:00'::timestamp);
</sql-statement>
<sql-statement>
-- another internal overflow test case
SELECT extract(epoch from '5000-01-01 00:00:00'::timestamp);
</sql-statement>
<sql-statement>
-- TO_CHAR()
SELECT to_char(d1, 'DAY Day day DY Dy dy MONTH Month month RM MON Mon mon')
FROM TIMESTAMP_TBL;
</sql-statement>
<sql-statement>
SELECT to_char(d1, 'FMDAY FMDay FMday FMMONTH FMMonth FMmonth FMRM')
FROM TIMESTAMP_TBL;
</sql-statement>
<sql-statement>
SELECT to_char(d1, 'Y,YYY YYYY YYY YY Y CC Q MM WW DDD DD D J')
FROM TIMESTAMP_TBL;
</sql-statement>
<sql-statement>
SELECT to_char(d1, 'FMY,YYY FMYYYY FMYYY FMYY FMY FMCC FMQ FMMM FMWW FMDDD FMDD FMD FMJ')
FROM TIMESTAMP_TBL;
</sql-statement>
<sql-statement>
SELECT to_char(d1, 'HH HH12 HH24 MI SS SSSS')
FROM TIMESTAMP_TBL;
</sql-statement>
<sql-statement>
SELECT to_char(d1, E'"HH:MI:SS is" HH:MI:SS "\\"text between quote marks\\""')
FROM TIMESTAMP_TBL;
</sql-statement>
<sql-statement>
SELECT to_char(d1, 'HH24--text--MI--text--SS')
FROM TIMESTAMP_TBL;
</sql-statement>
<sql-statement>
SELECT to_char(d1, 'YYYYTH YYYYth Jth')
FROM TIMESTAMP_TBL;
</sql-statement>
<sql-statement>
SELECT to_char(d1, 'YYYY A.D. YYYY a.d. YYYY bc HH:MI:SS P.M. HH:MI:SS p.m. HH:MI:SS pm')
FROM TIMESTAMP_TBL;
</sql-statement>
<sql-statement>
SELECT to_char(d1, 'IYYY IYY IY I IW IDDD ID')
FROM TIMESTAMP_TBL;
</sql-statement>
<sql-statement>
SELECT to_char(d1, 'FMIYYY FMIYY FMIY FMI FMIW FMIDDD FMID')
FROM TIMESTAMP_TBL;
</sql-statement>
<sql-statement>
SELECT to_char(d, 'FF1 FF2 FF3 FF4 FF5 FF6 ff1 ff2 ff3 ff4 ff5 ff6 MS US')
FROM (VALUES
('2018-11-02 12:34:56'::timestamp),
('2018-11-02 12:34:56.78'),
('2018-11-02 12:34:56.78901'),
('2018-11-02 12:34:56.78901234')
) d(d);
</sql-statement>
<sql-statement>
-- Roman months, with upper and lower case.
SELECT i,
to_char(i * interval '1mon', 'rm'),
to_char(i * interval '1mon', 'RM')
FROM generate_series(-13, 13) i;
</sql-statement>
-stdin-:<main>: Error: Type annotation
-stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
-- Roman months, with upper and lower case.
^
-stdin-:<main>:1:1: Error: Duplicated member: to_char
-- Roman months, with upper and lower case.
^
<sql-statement>
-- timestamp numeric fields constructor
SELECT make_timestamp(2014, 12, 28, 6, 30, 45.887);
</sql-statement>
<sql-statement>
SELECT make_timestamp(-44, 3, 15, 12, 30, 15);
</sql-statement>
<sql-statement>
-- should fail
select make_timestamp(0, 7, 15, 12, 30, 15);
</sql-statement>
-stdin-:<main>: Fatal: Execution
-stdin-:<main>:1:1: Fatal: Execution of node: Result
-- should fail
^
-stdin-:<main>:1:1: Fatal: ERROR: date field value out of range: 0-07-15
-- should fail
^
<sql-statement>
-- generate_series for timestamp
select * from generate_series('2020-01-01 00:00'::timestamp,
'2020-01-02 03:00'::timestamp,
'1 hour'::interval);
</sql-statement>
<sql-statement>
-- the LIMIT should allow this to terminate in a reasonable amount of time
-- (but that unfortunately doesn't work yet for SELECT * FROM ...)
select generate_series('2022-01-01 00:00'::timestamp,
'infinity'::timestamp,
'1 month'::interval) limit 10;
</sql-statement>
-stdin-:<main>: Error: Parse Sql
-stdin-:<main>:3:8: Error: Generator functions are not allowed in: SELECT
select generate_series('2022-01-01 00:00'::timestamp,
^
<sql-statement>
-- errors
select * from generate_series('2020-01-01 00:00'::timestamp,
'2020-01-02 03:00'::timestamp,
'0 hour'::interval);
</sql-statement>
-stdin-:<main>: Fatal: Execution
-stdin-:<main>:1:1: Fatal: Execution of node: Result
-- errors
^
-stdin-:<main>:1:1: Fatal: ERROR: step size cannot equal zero
-- errors
^
|