Skip to content

Commit f7e7a9e

Browse files
committed
codex review
1 parent d7e9b31 commit f7e7a9e

3 files changed

Lines changed: 331 additions & 34 deletions

File tree

src/aggregation/agg_data.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -762,19 +762,24 @@ fn build_multi_terms_node(
762762
let missing_key_elem = if let Some(missing) = &field_def.missing {
763763
match missing {
764764
Key::Str(missing_str) => {
765-
match columns.iter().position(|(_, ct)| *ct == ColumnType::Str) {
766-
Some(idx) => {
765+
match (
766+
columns.iter().position(|(_, ct)| *ct == ColumnType::Str),
767+
str_dict_column.as_ref(),
768+
) {
769+
(Some(idx), Some(str_dict_column)) => {
767770
match str_dict_column
768-
.as_ref()
769-
.unwrap()
770771
.dictionary()
771772
.term_ord(missing_str.as_bytes())?
772773
{
773774
Some(ord) => Some(KeyElem::new(idx as u32, ord)),
774775
None => Some(KeyElem::synthetic_missing()),
775776
}
776777
}
777-
None => Some(KeyElem::synthetic_missing()),
778+
// Either no `Str` column was found, or the `Str` entry in `columns` is
779+
// only the empty shim `get_all_ff_reader_or_empty` produces when the
780+
// field has no dictionary at all (`str_dict_column` is `None` in that
781+
// case) -- there is no dictionary to resolve `missing_str` against.
782+
_ => Some(KeyElem::synthetic_missing()),
778783
}
779784
}
780785
_ => {
@@ -864,6 +869,8 @@ fn get_term_agg_accessors(
864869
field_name: &str,
865870
missing: &Option<Key>,
866871
) -> crate::Result<Vec<(Column<u64>, ColumnType)>> {
872+
// `terms` and `multi_terms` both explicitly reject `Bytes` columns downstream, which needs
873+
// to actually see them as a real column (rather than the empty shim below) to do so.
867874
let allowed_column_types = [
868875
ColumnType::I64,
869876
ColumnType::U64,
@@ -872,6 +879,7 @@ fn get_term_agg_accessors(
872879
ColumnType::DateTime,
873880
ColumnType::Bool,
874881
ColumnType::IpAddr,
882+
ColumnType::Bytes,
875883
];
876884

877885
// In case the column is empty we want the shim column to match the missing type

0 commit comments

Comments
 (0)