@@ -14,6 +14,8 @@ use vortex::array::arrays::ConstantArray;
1414use vortex:: array:: arrays:: ConstantVTable ;
1515use vortex:: array:: arrays:: DictArray ;
1616use vortex:: array:: arrays:: PrimitiveArray ;
17+ use vortex:: array:: builtins:: ArrayBuiltins ;
18+ use vortex:: array:: mask:: MaskExecutor ;
1719use vortex:: array:: vectors:: VectorIntoArray ;
1820use vortex:: compute;
1921use vortex:: compute2:: take:: Take ;
@@ -186,7 +188,7 @@ pub(crate) fn new_vector_exporter_with_flatten(
186188 if let Some ( constant) = values. as_opt :: < ConstantVTable > ( ) {
187189 return constant:: new_exporter_with_mask (
188190 & ConstantArray :: new ( constant. scalar ( ) . clone ( ) , array. codes ( ) . len ( ) ) ,
189- array. codes ( ) . validity_mask ( ) ,
191+ array. codes ( ) . is_null ( ) ? . not ( ) ? . execute_mask ( session ) ? ,
190192 cache,
191193 ) ;
192194 }
@@ -299,19 +301,22 @@ impl<I: IntegerPType + AsPrimitive<u32>> ColumnExporter for DictVectorExporter<I
299301
300302#[ cfg( test) ]
301303mod tests {
304+ use vortex:: VortexSessionDefault ;
302305 use vortex:: array:: IntoArray ;
303306 use vortex:: array:: arrays:: ConstantArray ;
304307 use vortex:: array:: arrays:: DictArray ;
305308 use vortex:: array:: arrays:: PrimitiveArray ;
306309 use vortex:: buffer:: Buffer ;
307310 use vortex:: error:: VortexResult ;
311+ use vortex:: session:: VortexSession ;
308312
309313 use crate :: cpp;
310314 use crate :: duckdb:: DataChunk ;
311315 use crate :: duckdb:: LogicalType ;
312316 use crate :: exporter:: ColumnExporter ;
313317 use crate :: exporter:: ConversionCache ;
314318 use crate :: exporter:: dict:: new_exporter_with_flatten;
319+ use crate :: exporter:: dict:: new_vector_exporter_with_flatten;
315320 use crate :: exporter:: new_array_exporter;
316321
317322 pub ( crate ) fn new_exporter (
@@ -344,6 +349,54 @@ mod tests {
344349 ) ;
345350 }
346351
352+ #[ test]
353+ fn test_constant_dict_vector ( ) {
354+ let arr = DictArray :: new (
355+ PrimitiveArray :: from_option_iter ( [ None , Some ( 0u32 ) ] ) . into_array ( ) ,
356+ ConstantArray :: new ( 10 , 1 ) . into_array ( ) ,
357+ ) ;
358+
359+ let mut chunk = DataChunk :: new ( [ LogicalType :: new ( cpp:: duckdb_type:: DUCKDB_TYPE_INTEGER ) ] ) ;
360+
361+ let session = VortexSession :: default ( ) ;
362+ new_vector_exporter_with_flatten ( & arr, & ConversionCache :: default ( ) , & session, false )
363+ . unwrap ( )
364+ . export ( 0 , 2 , & mut chunk. get_vector ( 0 ) )
365+ . unwrap ( ) ;
366+ chunk. set_len ( 2 ) ;
367+
368+ assert_eq ! (
369+ format!( "{}" , String :: try_from( & chunk) . unwrap( ) ) ,
370+ r#"Chunk - [1 Columns]
371+ - FLAT INTEGER: 2 = [ NULL, 10]
372+ "#
373+ ) ;
374+ }
375+
376+ #[ test]
377+ fn test_constant_dict_vector_null ( ) {
378+ let arr = DictArray :: new (
379+ PrimitiveArray :: from_option_iter ( [ None :: < u32 > , None ] ) . into_array ( ) ,
380+ ConstantArray :: new ( 10 , 1 ) . into_array ( ) ,
381+ ) ;
382+
383+ let mut chunk = DataChunk :: new ( [ LogicalType :: new ( cpp:: duckdb_type:: DUCKDB_TYPE_INTEGER ) ] ) ;
384+
385+ let session = VortexSession :: default ( ) ;
386+ new_vector_exporter_with_flatten ( & arr, & ConversionCache :: default ( ) , & session, false )
387+ . unwrap ( )
388+ . export ( 0 , 2 , & mut chunk. get_vector ( 0 ) )
389+ . unwrap ( ) ;
390+ chunk. set_len ( 2 ) ;
391+
392+ assert_eq ! (
393+ format!( "{}" , String :: try_from( & chunk) . unwrap( ) ) ,
394+ r#"Chunk - [1 Columns]
395+ - CONSTANT INTEGER: 2 = [ NULL]
396+ "#
397+ ) ;
398+ }
399+
347400 #[ test]
348401 fn test_nullable_dict ( ) {
349402 let arr = DictArray :: new (
0 commit comments