@@ -36,9 +36,7 @@ macro_rules! convert_array_values_to_cells {
3636 ( $rows: expr, $arr: expr, $typ: ty) => {
3737 if let Some ( a) = $arr. as_any( ) . downcast_ref:: <$typ>( ) {
3838 for i in 0 ..$rows. len( ) {
39- let cell = Cell :: from( a. value( i) . to_string( ) )
40- . bg( tailwind:: BLACK )
41- . fg( tailwind:: WHITE ) ;
39+ let cell = Cell :: from( a. value( i) . to_string( ) ) ;
4240 $rows[ i] . push( cell) ;
4341 }
4442 }
@@ -49,9 +47,7 @@ macro_rules! convert_binary_array_values_to_cells {
4947 ( $rows: expr, $arr: expr, $typ: ty) => {
5048 if let Some ( a) = $arr. as_any( ) . downcast_ref:: <$typ>( ) {
5149 for i in 0 ..$rows. len( ) {
52- let cell = Cell :: from( format!( "{:?}" , a. value( i) ) )
53- . bg( tailwind:: BLACK )
54- . fg( tailwind:: WHITE ) ;
50+ let cell = Cell :: from( format!( "{:?}" , a. value( i) ) ) ;
5551 $rows[ i] . push( cell) ;
5652 }
5753 }
@@ -71,11 +67,7 @@ pub fn record_batch_to_table_header_cells(record_batch: &RecordBatch) -> Vec<Cel
7167
7268pub fn create_row_number_cells ( record_batch : & RecordBatch ) -> Vec < Cell < ' _ > > {
7369 let cells: Vec < Cell > = ( 0 ..record_batch. num_rows ( ) )
74- . map ( |i| {
75- Cell :: new ( i. to_string ( ) )
76- . bg ( tailwind:: BLACK )
77- . fg ( tailwind:: WHITE )
78- } )
70+ . map ( |i| Cell :: new ( i. to_string ( ) ) )
7971 . collect ( ) ;
8072 cells
8173}
@@ -263,16 +255,8 @@ mod tests {
263255 header_cells,
264256 vec![
265257 Cell :: new( "#" ) . bg( tailwind:: ORANGE . c300) . fg( tailwind:: BLACK ) ,
266- Cell :: new( "a" )
267- . bg( tailwind:: BLACK )
268- . fg( tailwind:: WHITE )
269- . bg( tailwind:: ORANGE . c300)
270- . fg( tailwind:: BLACK ) ,
271- Cell :: new( "b" )
272- . bg( tailwind:: BLACK )
273- . fg( tailwind:: WHITE )
274- . bg( tailwind:: ORANGE . c300)
275- . fg( tailwind:: BLACK )
258+ Cell :: new( "a" ) . bg( tailwind:: ORANGE . c300) . fg( tailwind:: BLACK ) ,
259+ Cell :: new( "b" ) . bg( tailwind:: ORANGE . c300) . fg( tailwind:: BLACK )
276260 ]
277261 ) ;
278262 }
@@ -284,170 +268,89 @@ mod tests {
284268 let batch = RecordBatch :: try_from_iter ( vec ! [ ( "a" , a) ] ) . unwrap ( ) ;
285269 let table_cells = record_batch_to_table_row_cells ( & batch) . unwrap ( ) ;
286270 let expected = vec ! [
287- vec![
288- Cell :: new( "0" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
289- Cell :: new( "a" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
290- ] ,
291- vec![
292- Cell :: new( "1" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
293- Cell :: new( "b" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
294- ] ,
295- vec![
296- Cell :: new( "2" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
297- Cell :: new( "c" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
298- ] ,
271+ vec![ Cell :: new( "0" ) , Cell :: new( "a" ) ] ,
272+ vec![ Cell :: new( "1" ) , Cell :: new( "b" ) ] ,
273+ vec![ Cell :: new( "2" ) , Cell :: new( "c" ) ] ,
299274 ] ;
300275 assert_eq ! ( table_cells, expected) ;
301276
302277 let a: ArrayRef = Arc :: new ( Int8Array :: from ( vec ! [ 1 , 2 , 3 ] ) ) ;
303278 let batch = RecordBatch :: try_from_iter ( vec ! [ ( "a" , a) ] ) . unwrap ( ) ;
304279 let a_table_cells = record_batch_to_table_row_cells ( & batch) . unwrap ( ) ;
305280 let expected = vec ! [
306- vec![
307- Cell :: new( "0" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
308- Cell :: new( "1" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
309- ] ,
310- vec![
311- Cell :: new( "1" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
312- Cell :: new( "2" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
313- ] ,
314- vec![
315- Cell :: new( "2" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
316- Cell :: new( "3" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
317- ] ,
281+ vec![ Cell :: new( "0" ) , Cell :: new( "1" ) ] ,
282+ vec![ Cell :: new( "1" ) , Cell :: new( "2" ) ] ,
283+ vec![ Cell :: new( "2" ) , Cell :: new( "3" ) ] ,
318284 ] ;
319285 assert_eq ! ( a_table_cells, expected) ;
320286
321287 let a: ArrayRef = Arc :: new ( Int16Array :: from ( vec ! [ 1 , 2 , 3 ] ) ) ;
322288 let batch = RecordBatch :: try_from_iter ( vec ! [ ( "a" , a) ] ) . unwrap ( ) ;
323289 let a_table_cells = record_batch_to_table_row_cells ( & batch) . unwrap ( ) ;
324290 let expected = vec ! [
325- vec![
326- Cell :: new( "0" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
327- Cell :: new( "1" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
328- ] ,
329- vec![
330- Cell :: new( "1" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
331- Cell :: new( "2" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
332- ] ,
333- vec![
334- Cell :: new( "2" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
335- Cell :: new( "3" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
336- ] ,
291+ vec![ Cell :: new( "0" ) , Cell :: new( "1" ) ] ,
292+ vec![ Cell :: new( "1" ) , Cell :: new( "2" ) ] ,
293+ vec![ Cell :: new( "2" ) , Cell :: new( "3" ) ] ,
337294 ] ;
338295 assert_eq ! ( a_table_cells, expected) ;
339296
340297 let a: ArrayRef = Arc :: new ( Int32Array :: from ( vec ! [ 1 , 2 , 3 ] ) ) ;
341298 let batch = RecordBatch :: try_from_iter ( vec ! [ ( "a" , a) ] ) . unwrap ( ) ;
342299 let a_table_cells = record_batch_to_table_row_cells ( & batch) . unwrap ( ) ;
343300 let expected = vec ! [
344- vec![
345- Cell :: new( "0" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
346- Cell :: new( "1" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
347- ] ,
348- vec![
349- Cell :: new( "1" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
350- Cell :: new( "2" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
351- ] ,
352- vec![
353- Cell :: new( "2" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
354- Cell :: new( "3" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
355- ] ,
301+ vec![ Cell :: new( "0" ) , Cell :: new( "1" ) ] ,
302+ vec![ Cell :: new( "1" ) , Cell :: new( "2" ) ] ,
303+ vec![ Cell :: new( "2" ) , Cell :: new( "3" ) ] ,
356304 ] ;
357305 assert_eq ! ( a_table_cells, expected) ;
358306
359307 let a: ArrayRef = Arc :: new ( Int64Array :: from ( vec ! [ 1 , 2 , 3 ] ) ) ;
360308 let batch = RecordBatch :: try_from_iter ( vec ! [ ( "a" , a) ] ) . unwrap ( ) ;
361309 let a_table_cells = record_batch_to_table_row_cells ( & batch) . unwrap ( ) ;
362310 let expected = vec ! [
363- vec![
364- Cell :: new( "0" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
365- Cell :: new( "1" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
366- ] ,
367- vec![
368- Cell :: new( "1" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
369- Cell :: new( "2" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
370- ] ,
371- vec![
372- Cell :: new( "2" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
373- Cell :: new( "3" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
374- ] ,
311+ vec![ Cell :: new( "0" ) , Cell :: new( "1" ) ] ,
312+ vec![ Cell :: new( "1" ) , Cell :: new( "2" ) ] ,
313+ vec![ Cell :: new( "2" ) , Cell :: new( "3" ) ] ,
375314 ] ;
376315 assert_eq ! ( a_table_cells, expected) ;
377316
378317 let a: ArrayRef = Arc :: new ( UInt8Array :: from ( vec ! [ 1 , 2 , 3 ] ) ) ;
379318 let batch = RecordBatch :: try_from_iter ( vec ! [ ( "a" , a) ] ) . unwrap ( ) ;
380319 let a_table_cells = record_batch_to_table_row_cells ( & batch) . unwrap ( ) ;
381320 let expected = vec ! [
382- vec![
383- Cell :: new( "0" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
384- Cell :: new( "1" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
385- ] ,
386- vec![
387- Cell :: new( "1" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
388- Cell :: new( "2" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
389- ] ,
390- vec![
391- Cell :: new( "2" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
392- Cell :: new( "3" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
393- ] ,
321+ vec![ Cell :: new( "0" ) , Cell :: new( "1" ) ] ,
322+ vec![ Cell :: new( "1" ) , Cell :: new( "2" ) ] ,
323+ vec![ Cell :: new( "2" ) , Cell :: new( "3" ) ] ,
394324 ] ;
395325 assert_eq ! ( a_table_cells, expected) ;
396326
397327 let a: ArrayRef = Arc :: new ( UInt16Array :: from ( vec ! [ 1 , 2 , 3 ] ) ) ;
398328 let batch = RecordBatch :: try_from_iter ( vec ! [ ( "a" , a) ] ) . unwrap ( ) ;
399329 let a_table_cells = record_batch_to_table_row_cells ( & batch) . unwrap ( ) ;
400330 let expected = vec ! [
401- vec![
402- Cell :: new( "0" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
403- Cell :: new( "1" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
404- ] ,
405- vec![
406- Cell :: new( "1" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
407- Cell :: new( "2" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
408- ] ,
409- vec![
410- Cell :: new( "2" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
411- Cell :: new( "3" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
412- ] ,
331+ vec![ Cell :: new( "0" ) , Cell :: new( "1" ) ] ,
332+ vec![ Cell :: new( "1" ) , Cell :: new( "2" ) ] ,
333+ vec![ Cell :: new( "2" ) , Cell :: new( "3" ) ] ,
413334 ] ;
414335 assert_eq ! ( a_table_cells, expected) ;
415336
416337 let a: ArrayRef = Arc :: new ( UInt32Array :: from ( vec ! [ 1 , 2 , 3 ] ) ) ;
417338 let batch = RecordBatch :: try_from_iter ( vec ! [ ( "a" , a) ] ) . unwrap ( ) ;
418339 let a_table_cells = record_batch_to_table_row_cells ( & batch) . unwrap ( ) ;
419340 let expected = vec ! [
420- vec![
421- Cell :: new( "0" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
422- Cell :: new( "1" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
423- ] ,
424- vec![
425- Cell :: new( "1" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
426- Cell :: new( "2" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
427- ] ,
428- vec![
429- Cell :: new( "2" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
430- Cell :: new( "3" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
431- ] ,
341+ vec![ Cell :: new( "0" ) , Cell :: new( "1" ) ] ,
342+ vec![ Cell :: new( "1" ) , Cell :: new( "2" ) ] ,
343+ vec![ Cell :: new( "2" ) , Cell :: new( "3" ) ] ,
432344 ] ;
433345 assert_eq ! ( a_table_cells, expected) ;
434346
435347 let a: ArrayRef = Arc :: new ( UInt64Array :: from ( vec ! [ 1 , 2 , 3 ] ) ) ;
436348 let batch = RecordBatch :: try_from_iter ( vec ! [ ( "a" , a) ] ) . unwrap ( ) ;
437349 let a_table_cells = record_batch_to_table_row_cells ( & batch) . unwrap ( ) ;
438350 let expected = vec ! [
439- vec![
440- Cell :: new( "0" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
441- Cell :: new( "1" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
442- ] ,
443- vec![
444- Cell :: new( "1" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
445- Cell :: new( "2" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
446- ] ,
447- vec![
448- Cell :: new( "2" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
449- Cell :: new( "3" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
450- ] ,
351+ vec![ Cell :: new( "0" ) , Cell :: new( "1" ) ] ,
352+ vec![ Cell :: new( "1" ) , Cell :: new( "2" ) ] ,
353+ vec![ Cell :: new( "2" ) , Cell :: new( "3" ) ] ,
451354 ] ;
452355 assert_eq ! ( a_table_cells, expected) ;
453356 }
@@ -459,21 +362,9 @@ mod tests {
459362 let batch = RecordBatch :: try_from_iter ( vec ! [ ( "a" , a) , ( "b" , b) ] ) . unwrap ( ) ;
460363 let a_table_cells = record_batch_to_table_row_cells ( & batch) . unwrap ( ) ;
461364 let expected = vec ! [
462- vec![
463- Cell :: new( "0" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
464- Cell :: new( "1" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
465- Cell :: new( "a" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
466- ] ,
467- vec![
468- Cell :: new( "1" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
469- Cell :: new( "2" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
470- Cell :: new( "b" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
471- ] ,
472- vec![
473- Cell :: new( "2" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
474- Cell :: new( "3" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
475- Cell :: new( "c" ) . bg( tailwind:: BLACK ) . fg( tailwind:: WHITE ) ,
476- ] ,
365+ vec![ Cell :: new( "0" ) , Cell :: new( "1" ) , Cell :: new( "a" ) ] ,
366+ vec![ Cell :: new( "1" ) , Cell :: new( "2" ) , Cell :: new( "b" ) ] ,
367+ vec![ Cell :: new( "2" ) , Cell :: new( "3" ) , Cell :: new( "c" ) ] ,
477368 ] ;
478369 assert_eq ! ( a_table_cells, expected) ;
479370 }
0 commit comments