@@ -17,6 +17,7 @@ use vortex_array::stream::ArrayStreamExt;
1717use vortex_array:: validity:: Validity ;
1818use vortex_array:: { Array , ArrayRef , IntoArray , ToCanonical } ;
1919use vortex_buffer:: { Buffer , ByteBufferMut , buffer} ;
20+ use vortex_dict:: { DictEncoding , DictVTable } ;
2021use vortex_dtype:: PType :: I32 ;
2122use vortex_dtype:: { DType , DecimalDType , Nullability , PType , StructFields } ;
2223use vortex_error:: VortexResult ;
@@ -1183,3 +1184,26 @@ async fn test_into_tokio_array_stream() -> VortexResult<()> {
11831184
11841185 Ok ( ( ) )
11851186}
1187+
1188+ #[ test]
1189+ fn test_array_stream_no_double_dict_encode ( ) -> VortexResult < ( ) > {
1190+ let num_vals = 2048 ;
1191+ let mut values = Vec :: < i64 > :: with_capacity ( num_vals) ;
1192+ values. extend ( iter:: repeat_n ( 0 , num_vals / 2 ) ) ;
1193+ values. extend ( iter:: repeat_n ( 1 , num_vals / 2 ) ) ;
1194+
1195+ let array = PrimitiveArray :: from_iter ( values) . into_array ( ) ;
1196+ let buf = VortexWriteOptions :: default ( ) . write_blocking ( Vec :: new ( ) , array. to_array_stream ( ) ) ?;
1197+ let file = VortexOpenOptions :: in_memory ( ) . open ( buf) ?;
1198+ let read_array = file. scan ( ) ?. into_array_iter ( ) ?. read_all ( ) ?;
1199+
1200+ let dict = read_array
1201+ . as_opt :: < DictVTable > ( )
1202+ . expect ( "expected root to be dictionary" ) ;
1203+ assert_ne ! (
1204+ dict. codes( ) . encoding( ) . id( ) ,
1205+ DictEncoding . id( ) ,
1206+ "dictionary codes should not be dictionary encoded"
1207+ ) ;
1208+ Ok ( ( ) )
1209+ }
0 commit comments