quickwit-oss/tantivy · error
unexpected type {:?}. This should not happen
Error message
unexpected type {:?}. This should not happen What it means
In the composite aggregation's histogram source, the value-to-float conversion only handles U64, I64, DateTime and F64 column types. Any other type (Str, Bytes, Bool, IpAddr) reaching visit is an internal bug — the source was expected to be a numeric fast field — so it panics with 'unexpected type ... This should not happen'.
Source
Thrown at src/aggregation/bucket/composite/collector.rs:568
}
self.sub_level_values.push(InternalValueRepr::new_term(
value,
accessor_idx as u8,
current_level_source.order(),
));
let still_on_after_key = matches_after_key_type
&& current_level_accessors.after_key.equals(value);
self.visit(source_idx + 1, is_on_after_key && still_on_after_key)?;
self.sub_level_values.pop();
}
CompositeAggregationSource::Histogram(source) => {
let float_value = match accessor.column_type {
ColumnType::U64 => value as f64,
ColumnType::I64 => i64::from_u64(value) as f64,
ColumnType::DateTime => i64::from_u64(value) as f64 / 1_000_000.,
ColumnType::F64 => f64::from_u64(value),
_ => {
panic!(
"unexpected type {:?}. This should not happen",
accessor.column_type
)
}
};
let bucket_index = (float_value / source.interval).floor() as i64;
let bucket_value = i64::to_u64(bucket_index);
if is_on_after_key {
let should_skip = match current_level_source.order() {
Order::Asc => current_level_accessors.after_key.gt(bucket_value),
Order::Desc => current_level_accessors.after_key.lt(bucket_value),
};
if should_skip {
continue;
}
}
self.sub_level_values.push(InternalValueRepr::new_histogram(
bucket_value,View on GitHub (pinned to b5d8deb80c)
Solutions
- Ensure the histogram source field is a numeric or date fast field in the schema (u64/i64/f64/date).
- Validate the aggregation request against the schema at query build time and reject non-numeric histogram sources.
- If the schema looks correct, this is an internal accessor-resolution bug — report it with the schema and query.
Example fix
// before
CompositeAggregationSource::Histogram(h)
// after — validate before building the collector
match schema.get_field(name).map(|f| schema.get_field_entry(f).field_type()) {
Some(t) if t.is_numeric() || matches!(t, FieldType::Date(_)) => {},
_ => return Err(InvalidArgument("histogram source requires numeric/date field")),
} Defensive patterns
Strategy: validation
Validate before calling
match accessor.column_type {
ColumnType::U64 | ColumnType::I64 | ColumnType::F64 | ColumnType::DateTime => Ok(()),
other => Err(format!("histogram requires numeric/date, got {:?}", other)),
} Type guard
fn is_numeric_or_date(t: &ColumnType) -> bool {
matches!(t, ColumnType::U64 | ColumnType::I64 | ColumnType::F64 | ColumnType::DateTime)
} Prevention
- Validate schema field type matches the aggregation source kind before running the query
- Keep histogram sources on numeric/date fast fields
- Re-validate mappings after any schema change
When it happens
Trigger: Visiting a histogram composite source whose accessor.column_type is not one of U64/I64/DateTime/F64 — e.g. the field resolved to a Str/Bytes/Bool/IpAddr fast field but was declared as a histogram (numeric) source.
Common situations: Field type mismatch between schema and aggregation request (requesting a histogram over a text/keyword field); schema migration changed a numeric field to keyword; a bug in accessor type resolution passing the wrong accessor.
Related errors
- unsupported
- interval not precomputed for date histogram source
- unsupported
- null must be handled separately
- dictionary missing for str accessor
AI-assisted analysis of quickwit-oss/tantivy@b5d8deb80c (2026-09-05).
Data as JSON: /api/errors/c9f271d6eae7d177.
Report an issue: GitHub.