()
| 466 | |
| 467 | #[test] |
| 468 | fn dict_encode_with_nulls() { |
| 469 | let schema = ColumnarSchema::new(vec![ColumnDef::nullable("tag", ColumnType::String)]) |
| 470 | .expect("valid"); |
| 471 | |
| 472 | let mut mt = ColumnarMemtable::new(&schema); |
| 473 | mt.append_row(&[Value::String("foo".into())]) |
| 474 | .expect("append"); |
| 475 | mt.append_row(&[Value::Null]).expect("append null"); |
| 476 | mt.append_row(&[Value::String("bar".into())]) |
| 477 | .expect("append"); |
| 478 | mt.append_row(&[Value::Null]).expect("append null"); |
| 479 | |
| 480 | mt.try_dict_encode_columns(DICT_ENCODE_MAX_CARDINALITY); |
| 481 | |
| 482 | let (_schema, columns, _row_count) = mt.drain(); |
| 483 | match &columns[0] { |
| 484 | ColumnData::DictEncoded { |
| 485 | ids, |
| 486 | valid, |
| 487 | dictionary, |
| 488 | .. |
| 489 | } => { |
| 490 | assert_eq!(ids.len(), 4); |
| 491 | let v = valid.as_ref().expect("nullable column has validity bitmap"); |
| 492 | assert_eq!(v.len(), 4); |
| 493 | assert!(v[0]); |
| 494 | assert!(!v[1]); |
| 495 | assert!(v[2]); |
| 496 | assert!(!v[3]); |
| 497 | assert_eq!(dictionary.len(), 2); |
| 498 | } |
| 499 | _ => panic!("expected DictEncoded"), |
| 500 | } |
| 501 | } |
| 502 | } |
nothing calls this directly
no test coverage detected