@@ -196,8 +196,7 @@ describe("binary", (t) => {
196196 ) ;
197197
198198 const originalField = TEST_TABLE . schema . fields [ columnIndex ] ;
199- // declare it's not null
200- const originalVector = TEST_TABLE . getChildAt ( columnIndex ) as arrow . Vector ;
199+ const originalVector = TEST_TABLE . getChildAt ( columnIndex ) ! ;
201200 const fieldPtr = FFI_TABLE . schemaAddr ( columnIndex ) ;
202201 const field = parseField ( WASM_MEMORY . buffer , fieldPtr ) ;
203202
@@ -277,8 +276,7 @@ describe("string", (t) => {
277276 ) ;
278277
279278 const originalField = TEST_TABLE . schema . fields [ columnIndex ] ;
280- // declare it's not null
281- const originalVector = TEST_TABLE . getChildAt ( columnIndex ) as arrow . Vector ;
279+ const originalVector = TEST_TABLE . getChildAt ( columnIndex ) ! ;
282280 const fieldPtr = FFI_TABLE . schemaAddr ( columnIndex ) ;
283281 const field = parseField ( WASM_MEMORY . buffer , fieldPtr ) ;
284282
@@ -346,8 +344,7 @@ describe("boolean", (t) => {
346344 ) ;
347345
348346 const originalField = TEST_TABLE . schema . fields [ columnIndex ] ;
349- // declare it's not null
350- const originalVector = TEST_TABLE . getChildAt ( columnIndex ) as arrow . Vector ;
347+ const originalVector = TEST_TABLE . getChildAt ( columnIndex ) ! ;
351348 const fieldPtr = FFI_TABLE . schemaAddr ( columnIndex ) ;
352349 const field = parseField ( WASM_MEMORY . buffer , fieldPtr ) ;
353350
@@ -379,8 +376,7 @@ describe("null array", (t) => {
379376 ) ;
380377
381378 const originalField = TEST_TABLE . schema . fields [ columnIndex ] ;
382- // declare it's not null
383- const originalVector = TEST_TABLE . getChildAt ( columnIndex ) as arrow . Vector ;
379+ const originalVector = TEST_TABLE . getChildAt ( columnIndex ) ! ;
384380 const fieldPtr = FFI_TABLE . schemaAddr ( columnIndex ) ;
385381 const field = parseField ( WASM_MEMORY . buffer , fieldPtr ) ;
386382
@@ -412,8 +408,7 @@ describe("list array", (t) => {
412408 ) ;
413409
414410 const originalField = TEST_TABLE . schema . fields [ columnIndex ] ;
415- // declare it's not null
416- const originalVector = TEST_TABLE . getChildAt ( columnIndex ) as arrow . Vector ;
411+ const originalVector = TEST_TABLE . getChildAt ( columnIndex ) ! ;
417412 const fieldPtr = FFI_TABLE . schemaAddr ( columnIndex ) ;
418413 const field = parseField ( WASM_MEMORY . buffer , fieldPtr ) ;
419414
@@ -499,8 +494,7 @@ describe("extension array", (t) => {
499494 ) ;
500495
501496 const originalField = TEST_TABLE . schema . fields [ columnIndex ] ;
502- // declare it's not null
503- const originalVector = TEST_TABLE . getChildAt ( columnIndex ) as arrow . Vector ;
497+ const originalVector = TEST_TABLE . getChildAt ( columnIndex ) ! ;
504498 const fieldPtr = FFI_TABLE . schemaAddr ( columnIndex ) ;
505499 const field = parseField ( WASM_MEMORY . buffer , fieldPtr ) ;
506500
@@ -544,8 +538,7 @@ describe("extension array", (t) => {
544538// );
545539
546540// const originalField = TEST_TABLE.schema.fields[columnIndex];
547- // // declare it's not null
548- // const originalVector = TEST_TABLE.getChildAt(columnIndex) as arrow.Vector;
541+ // const originalVector = TEST_TABLE.getChildAt(columnIndex)!;
549542// const fieldPtr = FFI_TABLE.schemaAddr(columnIndex);
550543// const field = parseField(WASM_MEMORY.buffer, fieldPtr);
551544
@@ -572,8 +565,7 @@ describe("date32", (t) => {
572565 ) ;
573566
574567 const originalField = TEST_TABLE . schema . fields [ columnIndex ] ;
575- // declare it's not null
576- const originalVector = TEST_TABLE . getChildAt ( columnIndex ) as arrow . Vector ;
568+ const originalVector = TEST_TABLE . getChildAt ( columnIndex ) ! ;
577569 const fieldPtr = FFI_TABLE . schemaAddr ( columnIndex ) ;
578570 const field = parseField ( WASM_MEMORY . buffer , fieldPtr ) ;
579571
@@ -606,8 +598,7 @@ describe("date32", (t) => {
606598// );
607599
608600// const originalField = TEST_TABLE.schema.fields[columnIndex];
609- // // declare it's not null
610- // const originalVector = TEST_TABLE.getChildAt(columnIndex) as arrow.Vector;
601+ // const originalVector = TEST_TABLE.getChildAt(columnIndex)!;
611602// const fieldPtr = FFI_TABLE.schemaAddr(columnIndex);
612603// const field = parseField(WASM_MEMORY.buffer, fieldPtr);
613604
@@ -634,8 +625,7 @@ describe("duration", (t) => {
634625 ) ;
635626
636627 const originalField = TEST_TABLE . schema . fields [ columnIndex ] ;
637- // declare it's not null
638- const originalVector = TEST_TABLE . getChildAt ( columnIndex ) as arrow . Vector ;
628+ const originalVector = TEST_TABLE . getChildAt ( columnIndex ) ! ;
639629 const fieldPtr = FFI_TABLE . schemaAddr ( columnIndex ) ;
640630 const field = parseField ( WASM_MEMORY . buffer , fieldPtr ) ;
641631
@@ -667,8 +657,7 @@ describe("nullable int", (t) => {
667657 ) ;
668658
669659 const originalField = TEST_TABLE . schema . fields [ columnIndex ] ;
670- // declare it's not null
671- const originalVector = TEST_TABLE . getChildAt ( columnIndex ) as arrow . Vector ;
660+ const originalVector = TEST_TABLE . getChildAt ( columnIndex ) ! ;
672661 const fieldPtr = FFI_TABLE . schemaAddr ( columnIndex ) ;
673662 const field = parseField ( WASM_MEMORY . buffer , fieldPtr ) ;
674663
@@ -693,3 +682,67 @@ describe("nullable int", (t) => {
693682 it ( "copy=false" , ( ) => test ( false ) ) ;
694683 it ( "copy=true" , ( ) => test ( true ) ) ;
695684} ) ;
685+
686+ describe ( "dictionary encoded string" , ( t ) => {
687+ function test ( copy : boolean ) {
688+ let columnIndex = TEST_TABLE . schema . fields . findIndex (
689+ ( field ) => field . name == "dictionary_encoded_string"
690+ ) ;
691+
692+ const originalField = TEST_TABLE . schema . fields [ columnIndex ] ;
693+ const originalVector = TEST_TABLE . getChildAt ( columnIndex ) ! ;
694+ const fieldPtr = FFI_TABLE . schemaAddr ( columnIndex ) ;
695+ const field = parseField ( WASM_MEMORY . buffer , fieldPtr ) ;
696+
697+ expect ( field . name ) . toStrictEqual ( originalField . name ) ;
698+ expect ( field . typeId ) . toStrictEqual ( originalField . typeId ) ;
699+ expect ( field . nullable ) . toStrictEqual ( originalField . nullable ) ;
700+
701+ const arrayPtr = FFI_TABLE . arrayAddr ( 0 , columnIndex ) ;
702+ const wasmVector = parseVector (
703+ WASM_MEMORY . buffer ,
704+ arrayPtr ,
705+ field . type ,
706+ copy
707+ ) ;
708+
709+ for ( let i = 0 ; i < 3 ; i ++ ) {
710+ expect ( originalVector . get ( i ) ) . toStrictEqual ( wasmVector . get ( i ) ) ;
711+ }
712+ }
713+
714+ it ( "copy=false" , ( ) => test ( false ) ) ;
715+ it ( "copy=true" , ( ) => test ( true ) ) ;
716+ } ) ;
717+
718+ describe ( "dictionary encoded string (with nulls)" , ( t ) => {
719+ function test ( copy : boolean ) {
720+ let columnIndex = TEST_TABLE . schema . fields . findIndex (
721+ ( field ) => field . name == "dictionary_encoded_string_null"
722+ ) ;
723+
724+ const originalField = TEST_TABLE . schema . fields [ columnIndex ] ;
725+ const originalVector = TEST_TABLE . getChildAt ( columnIndex ) ! ;
726+ const fieldPtr = FFI_TABLE . schemaAddr ( columnIndex ) ;
727+ const field = parseField ( WASM_MEMORY . buffer , fieldPtr ) ;
728+
729+ expect ( field . name ) . toStrictEqual ( originalField . name ) ;
730+ expect ( field . typeId ) . toStrictEqual ( originalField . typeId ) ;
731+ expect ( field . nullable ) . toStrictEqual ( originalField . nullable ) ;
732+
733+ const arrayPtr = FFI_TABLE . arrayAddr ( 0 , columnIndex ) ;
734+ const wasmVector = parseVector (
735+ WASM_MEMORY . buffer ,
736+ arrayPtr ,
737+ field . type ,
738+ copy
739+ ) ;
740+
741+ for ( let i = 0 ; i < 3 ; i ++ ) {
742+ expect ( originalVector . get ( i ) ) . toStrictEqual ( wasmVector . get ( i ) ) ;
743+ }
744+ }
745+
746+ it ( "copy=false" , ( ) => test ( false ) ) ;
747+ it ( "copy=true" , ( ) => test ( true ) ) ;
748+ } ) ;
0 commit comments