{"record":{"id":"0bc6858aad85fe50","repo":"cube-js/cube","slug":"can-t-compare-to","errorCode":null,"errorMessage":"Can't compare {:?} to {:?}","messagePattern":"Can't compare (.+?) to (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rust/cubestore/cubestore/src/table/data.rs","lineNumber":135,"sourceCode":"    }\n    Ordering::Equal\n}\n\npub fn cmp_same_types(l: &TableValueR, r: &TableValueR) -> Ordering {\n    match (l, r) {\n        (TableValueR::Null, TableValueR::Null) => Ordering::Equal,\n        (TableValueR::Null, _) => Ordering::Less,\n        (_, TableValueR::Null) => Ordering::Greater,\n        (TableValueR::String(a), TableValueR::String(b)) => a.cmp(b),\n        (TableValueR::Int(a), TableValueR::Int(b)) => a.cmp(b),\n        (TableValueR::Int96(a), TableValueR::Int96(b)) => a.cmp(b),\n        (TableValueR::Decimal(a), TableValueR::Decimal(b)) => a.cmp(b),\n        (TableValueR::Decimal96(a), TableValueR::Decimal96(b)) => a.cmp(b),\n        (TableValueR::Float(a), TableValueR::Float(b)) => a.cmp(b),\n        (TableValueR::Bytes(a), TableValueR::Bytes(b)) => a.cmp(b),\n        (TableValueR::Timestamp(a), TableValueR::Timestamp(b)) => a.cmp(b),\n        (TableValueR::Boolean(a), TableValueR::Boolean(b)) => a.cmp(b),\n        (a, b) => panic!(\"Can't compare {:?} to {:?}\", a, b),\n    }\n}\n\n#[macro_export]\nmacro_rules! match_column_type {\n    ($t: expr, $matcher: ident) => {{\n        use datafusion::arrow::array::*;\n        let t = $t;\n        match t {\n            ColumnType::String => $matcher!(String, StringBuilder, String),\n            ColumnType::Int => $matcher!(Int, Int64Builder, Int),\n            ColumnType::Int96 => $matcher!(Int96, Decimal128Builder, Int96),\n            ColumnType::Bytes => $matcher!(Bytes, BinaryBuilder, Bytes),\n            ColumnType::HyperLogLog(_) => $matcher!(HyperLogLog, BinaryBuilder, Bytes),\n            ColumnType::Timestamp => $matcher!(Timestamp, TimestampMicrosecondBuilder, Timestamp),\n            ColumnType::Boolean => $matcher!(Boolean, BooleanBuilder, Boolean),\n            // scale and precision are used when creating but not when appending, hence underscore here.\n            ColumnType::Decimal { scale: _scale, precision: _precision } => {","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/rust/cubestore/cubestore/src/table/data.rs#L117-L153","documentation":"CubeStore panics when cmp_same_types is asked to compare two TableValueR values whose variants differ (e.g. Int vs String). The match arms only handle same-type pairs; any mixed-type pair falls to the catch-all arm. It indicates a column-type mismatch, usually corrupt or mislabeled data in a partition/row key.","triggerScenarios":"Comparing values from columns with inconsistent logical types, e.g. a sort/partition key column whose stored values don't match the declared column type, or comparing a Decimal against a Timestamp during row-key (cmp_row_key) evaluation.","commonSituations":"Importing CSV data where a column's inferred/declared type differs from actual values; schema changes on an existing pre-aggregation/partition; bugs in query planning that compare key columns of different tables.","solutions":["Verify the column's declared type matches the actual data in the source (e.g. all ints, no strings) and re-import the affected table/partition","Drop and rebuild affected pre-aggregations/partitions after correcting the schema","Check for NaN or unexpected values (e.g. null-ish sentinels) in key columns used for sorting","If reproducible, file a bug with the query and schema — mixed-type comparison should be prevented earlier by planning"],"exampleFix":"// before (ingest with mismatched type)\n// column 'ts' declared Timestamp, CSV contains '2024-01-01' as quoted string in some rows\n// after\n// normalize values on import so stored variant matches the column type","handlingStrategy":"validation","validationCode":"fn validate_column_types(types: &[ColumnType]) -> Result<(), String> {\n    types.iter().try_for_each(|t| match t {\n        ColumnType::Int | ColumnType::Float | ColumnType::String | ColumnType::Decimal | ColumnType::Timestamp | ColumnType::Boolean => Ok(()),\n        other => Err(format!(\"unsupported column type {:?}\", other)),\n    })\n}","typeGuard":"fn same_variant(a: &TableValueR, b: &TableValueR) -> bool {\n    std::mem::discriminant(a) == std::mem::discriminant(b)\n}","tryCatchPattern":null,"preventionTips":["Keep declared column types consistent with source data; validate before import","Rebuild partitions after any schema change","Avoid comparing key columns across tables with different types"],"tags":["cubestore","panic","type-mismatch","comparison"],"backgroundTag":"type-mismatch-panic","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}