{"record":{"id":"e89ee3a7204ffcbf","repo":"databendlabs/databend","slug":"internal-error-entered-unreachable-code-e89ee3","errorCode":null,"errorMessage":"internal error: entered unreachable code","messagePattern":"internal error: entered unreachable code","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/query/storages/common/table_meta/src/meta/v2/segment.rs","lineNumber":260,"sourceCode":"            VIRTUAL_COLUMN_INT16_TYPE => VirtualColumnPhysicalType::Number(NumberDataType::Int16),\n            VIRTUAL_COLUMN_INT32_TYPE => VirtualColumnPhysicalType::Number(NumberDataType::Int32),\n            VIRTUAL_COLUMN_FLOAT64_TYPE => {\n                VirtualColumnPhysicalType::Number(NumberDataType::Float64)\n            }\n            VIRTUAL_COLUMN_FLOAT32_TYPE => {\n                VirtualColumnPhysicalType::Number(NumberDataType::Float32)\n            }\n            VIRTUAL_COLUMN_STRING_TYPE => VirtualColumnPhysicalType::String,\n            VIRTUAL_COLUMN_BINARY_TYPE => VirtualColumnPhysicalType::Binary,\n            VIRTUAL_COLUMN_DATE_TYPE => VirtualColumnPhysicalType::Date,\n            VIRTUAL_COLUMN_TIMESTAMP_TYPE => VirtualColumnPhysicalType::Timestamp,\n            VIRTUAL_COLUMN_TIMESTAMP_TZ_TYPE => VirtualColumnPhysicalType::TimestampTz,\n            VIRTUAL_COLUMN_INTERVAL_TYPE => VirtualColumnPhysicalType::Interval,\n            VIRTUAL_COLUMN_EXTENDED_TYPE => self\n                .extended_physical_type\n                .clone()\n                .expect(\"extended virtual column type is missing\"),\n            _ => unreachable!(),\n        }\n    }\n}\n\n/// Retained path frequencies for one source variant column in a block.\n#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, FrozenAPI)]\npub struct VirtualColumnPathStatistics {\n    /// `(segment-local virtual path id, saturated value_count)` pairs.\n    pub path_counts: Vec<(ColumnId, u32)>,\n    /// Whether every observed non-direct path for this source is represented in\n    /// `path_counts`. Direct paths are intentionally represented only by\n    /// `VirtualBlockMeta.virtual_column_metas`; false means producer-side\n    /// truncation omitted some non-direct paths.\n    pub path_statistics_complete: bool,\n}\n\n/// Path frequencies for one source variant column before segment-local path ids\n/// are assigned. Each pair is `(canonical_path, saturated value_count)`.","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/query/storages/common/table_meta/src/meta/v2/segment.rs#L242-L278","documentation":"VirtualColumnMeta::physical_type maps a stored physical-type tag constant to a VirtualColumnPhysicalType, and panics with unreachable! on an unknown tag (or expect-fails when the extended type payload is missing). Indicates virtual column metadata on disk uses a tag this binary does not understand, or extended-type metadata is incomplete.","triggerScenarios":"Reading a segment containing virtual column metadata whose type tag is none of the known VIRTUAL_COLUMN_*_TYPE constants, or a VIRTUAL_COLUMN_EXTENDED_TYPE entry whose extended_physical_type field is None.","commonSituations":"Version skew: newer Databend wrote new virtual column physical types (e.g. new extended types) and an older binary reads the segment; partially written/corrupted segment metadata.","solutions":["Upgrade to a Databend version that supports the virtual column physical type in the metadata","Inspect the segment's virtual column meta to identify the unknown tag value","Rebuild virtual column metadata (re-run virtual column computation) for the affected table","For developers: replace unreachable! with an error carrying the tag, and validate extended_physical_type at write time"],"exampleFix":"// before\n_ => unreachable!(),\n// after\nunknown => Err(ErrorCode::StorageOther(format!(\n    \"unknown virtual column physical type tag {unknown:#x}; upgrade Databend\"\n))),","handlingStrategy":"fallback","validationCode":"// rust: check the virtual column tag is recognized before use\nconst KNOWN_TAGS: &[u8] = &[VIRTUAL_COLUMN_NULLABLE_TYPE, VIRTUAL_COLUMN_TIMESTAMP_TZ_TYPE,\n    VIRTUAL_COLUMN_INTERVAL_TYPE, VIRTUAL_COLUMN_EXTENDED_TYPE];\nassert!(KNOWN_TAGS.contains(&tag), \"unknown virtual column tag\");","typeGuard":"fn is_known_virtual_tag(tag: u8) -> bool {\n    matches!(tag, VIRTUAL_COLUMN_NULLABLE_TYPE | VIRTUAL_COLUMN_TIMESTAMP_TZ_TYPE\n        | VIRTUAL_COLUMN_INTERVAL_TYPE | VIRTUAL_COLUMN_EXTENDED_TYPE)\n}","tryCatchPattern":"let pty = std::panic::catch_unwind(|| meta.physical_type())\n    .map_err(|_| \"unsupported virtual column physical type; upgrade Databend\")?;","preventionTips":["Keep reader and writer versions in sync for virtual column features","Recompute virtual columns after upgrades or schema changes","Validate extended_physical_type is present when writing EXTENDED tags"],"tags":["rust","panic","virtual-column","metadata","segment"],"backgroundTag":"invalid-enum-value","analyzedSha":"288d84d76e20a2f8f7173bda9691eb6ece301aa9","analyzedAt":"2026-09-11T11:29:36.208Z","contentChangedAt":"2026-09-11T11:29:36.208Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}