{"record":{"id":"cbaf0adffaccd1c0","repo":"influxdata/influxdb","slug":"should-have-gotten-a-stringarray","errorCode":null,"errorMessage":"should have gotten a StringArray","messagePattern":"should have gotten a StringArray","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/partition/src/traits/record_batch.rs","lineNumber":36,"sourceCode":"        debug_assert!(PartitioningColumn::is_valid(self, idx));\n        match self.data_type() {\n            DataType::Utf8 => self\n                .as_any()\n                .downcast_ref::<StringArray>()\n                .map(|col_data| col_data.value(idx)),\n            DataType::Dictionary(key, value)\n                if key.as_ref() == &DataType::Int32 && value.as_ref() == &DataType::Utf8 =>\n            {\n                let dict = self\n                    .as_any()\n                    .downcast_ref::<DictionaryArray<Int32Type>>()\n                    .expect(\"should have gotten a DictionaryArray\");\n\n                let values = dict\n                    .values()\n                    .as_any()\n                    .downcast_ref::<StringArray>()\n                    .expect(\"should have gotten a StringArray\");\n                Some(values.value(dict.key(idx)?))\n            }\n            _ => None,\n        }\n    }\n\n    fn get_tag_value<'a>(&'a self, tag_identity_key: &'a Self::TagIdentityKey) -> Option<&'a str> {\n        Some(tag_identity_key)\n    }\n\n    fn type_description(&self) -> String {\n        self.data_type().to_string()\n    }\n}\n\nimpl Batch for RecordBatch {\n    type Column = Arc<dyn Array>;\n","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/partition/src/traits/record_batch.rs#L18-L54","documentation":"expect(\"should have gotten a StringArray\") panic in get_tag_identity_key: after successfully downcasting to DictionaryArray<Int32Type>, the code downcasts dict.values() to StringArray because the schema promised Utf8 dictionary values. If the dictionary's value array is not a StringArray (e.g. LargeStringArray or BinaryArray), the downcast returns None and expect panics.","triggerScenarios":"A dictionary column whose values are LargeUtf8/Binary/other rather than Utf8, while the schema-level DataType guard matched Dictionary(Int32, Utf8) — i.e. schema and physical value array disagree, or the guard is bypassed by a differently typed value array.","commonSituations":"Data written by a producer using LargeStringArray-backed dictionaries, arrow-rs upgrades changing default value types, or fixtures building dictionaries with non-string values.","solutions":["Confirm the dictionary's values() array is a StringArray (Utf8) before downcasting","Handle the None case gracefully: return None or map to an error instead of expect()","Normalize ingestion so tag dictionaries always use Utf8 value arrays","Add a schema check that rejects Dictionary types whose values are not Utf8"],"exampleFix":"// before\n.expect(\"should have gotten a StringArray\");\n// after\n.ok_or_else(|| TimeColumnError::UnexpectedType(\"StringArray\".into()))?;","handlingStrategy":"type-guard","validationCode":"// rust\nfn dict_values_are_utf8(dict: &DictionaryArray<Int32Type>) -> bool {\n    dict.values().as_any().downcast_ref::<StringArray>().is_some()\n}","typeGuard":"// rust\nfn as_string_values<'a>(dict: &'a DictionaryArray<Int32Type>) -> Option<&'a StringArray> {\n    dict.values().as_any().downcast_ref::<StringArray>()\n}","tryCatchPattern":"let values = dict.values().as_any().downcast_ref::<StringArray>()\n    .ok_or(TimeColumnError::UnexpectedType(\"expected Utf8 dictionary values\"))?;","preventionTips":["Reject Dictionary schemas whose value type is not Utf8 at schema validation","Normalize LargeUtf8/Binary dictionary values to Utf8 during ingestion","Pin arrow-rs versions to avoid silent default type changes"],"tags":["rust","panic","downcast","arrow","string-array"],"backgroundTag":"type-mismatch","analyzedSha":"06200ef96ba82c5f6727e5038a83af8e722c6875","analyzedAt":"2026-09-19T12:55:30.003Z","contentChangedAt":"2026-09-19T12:55:30.003Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}