@@ -639,6 +639,38 @@ describe('BigQuery', () => {
639
639
} ) ;
640
640
} ) ;
641
641
642
+ it ( 'should parse uint64 timestamps with nanosecond precision' , ( ) => {
643
+ const SCHEMA_OBJECT = {
644
+ fields : [ { name : 'ts' , type : 'TIMESTAMP' } ] ,
645
+ } as { fields : TableField [ ] } ;
646
+
647
+ sandbox . restore ( ) ; // restore BigQuery.timestamp call
648
+
649
+ const rows = {
650
+ raw : [
651
+ { f : [ { v : '-604800000000' } ] } , // negative value
652
+ { f : [ { v : '0' } ] } , // 0 value
653
+ { f : [ { v : '1000000' } ] } , // 1 sec after epoch
654
+ { f : [ { v : '1712609904434123' } ] } , // recent time
655
+ ] ,
656
+ expectedParsed : [
657
+ { ts : BigQuery . timestamp ( '1969-12-25T00:00:00.000Z' ) } ,
658
+ { ts : BigQuery . timestamp ( '1970-01-01T00:00:00Z' ) } ,
659
+ { ts : BigQuery . timestamp ( '1970-01-01T00:00:01Z' ) } ,
660
+ { ts : BigQuery . timestamp ( '2024-04-08T20:58:24.434123Z' ) } ,
661
+ ] ,
662
+ } ;
663
+
664
+ const mergedRows = BigQuery . mergeSchemaWithRows_ (
665
+ SCHEMA_OBJECT ,
666
+ rows . raw ,
667
+ { }
668
+ ) ;
669
+ mergedRows . forEach ( ( mergedRow : { } , i : number ) => {
670
+ assert . deepStrictEqual ( mergedRow , rows . expectedParsed [ i ] ) ;
671
+ } ) ;
672
+ } ) ;
673
+
642
674
it ( 'should wrap integers with option' , ( ) => {
643
675
const wrapIntegersBoolean = true ;
644
676
const wrapIntegersObject = { } ;
0 commit comments