{"record":{"id":"783de2786e0975cf","repo":"risingwavelabs/risingwave","slug":"expected-int64-got","errorCode":null,"errorMessage":"expected int64, got {:?}","messagePattern":"expected int64, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/frontend/src/optimizer/rule/table_function_to_internal_get_channel_delta_stats.rs","lineNumber":52,"sourceCode":"        .cast_implicit(&DataType::Int64)?\n        .try_fold_const()\n    {\n        Some(Ok(value)) => {\n            let Some(scalar) = value else {\n                return Ok(None);\n            };\n            match scalar {\n                ScalarImpl::Int64(value) => {\n                    if value < 0 {\n                        Err(anyhow::anyhow!(\n                            \"time parameter cannot be negative, got {}\",\n                            value\n                        ))\n                    } else {\n                        Ok(Some(value as u64))\n                    }\n                }\n                _ => Err(anyhow::anyhow!(\"expected int64, got {:?}\", scalar)),\n            }\n        }\n        Some(Err(err)) => Err(anyhow!(err).context(\"failed to fold constant\")),\n        None => Err(anyhow::anyhow!(\"expression must be a constant value\")),\n    }\n}\n\n/// Transform the `internal_get_channel_delta_stats()` table function\n/// into a plan graph which will return channel statistics from the dashboard API.\n/// It will return channel stats with `upstream_fragment_id` and `downstream_fragment_id` as primary key.\npub struct TableFunctionToInternalGetChannelDeltaStatsRule {}\nimpl FallibleRule<Logical> for TableFunctionToInternalGetChannelDeltaStatsRule {\n    fn apply(&self, plan: PlanRef) -> ApplyResult<PlanRef> {\n        let logical_table_function: &LogicalTableFunction = plan.as_logical_table_function()?;\n        if logical_table_function.table_function().function_type\n            != TableFunctionType::InternalGetChannelDeltaStats\n        {\n            return ApplyResult::NotApplicable;","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/frontend/src/optimizer/rule/table_function_to_internal_get_channel_delta_stats.rs#L34-L70","documentation":"`expr_impl_to_u64_fn` only accepts Int64 scalar constants for time parameters. When constant folding yields a scalar of any other type (e.g. Int32, Decimal, Timestamp), it errors with `expected int64, got {scalar:?}`.","triggerScenarios":"Passing a constant argument of non-Int64 type to `internal_get_channel_delta_stats`, such as an integer literal typed as Int32, a decimal, or a string.","commonSituations":"Users passing raw numeric literals that the frontend infers as Int32, or casting to the wrong type; also passing quoted strings like '60'.","solutions":["Cast the argument to BIGINT: `internal_get_channel_delta_stats(60::bigint, 0::bigint)`.","Avoid string or decimal arguments; use plain int64 literals.","Adjust the expression so it folds to an Int64 scalar.","Check the function signature and supply arguments in the expected types."],"exampleFix":"-- before\nSELECT * FROM internal_get_channel_delta_stats('60', '0');\n-- after\nSELECT * FROM internal_get_channel_delta_stats(60::bigint, 0::bigint);","handlingStrategy":"validation","validationCode":"-- Cast arguments to BIGINT before calling\nSELECT * FROM internal_get_channel_delta_stats(60::bigint, 0::bigint);","typeGuard":"fn require_int64(s: &ScalarImpl) -> Option<i64> {\n    match s { ScalarImpl::Int64(v) => Some(*v), _ => None }\n}","tryCatchPattern":"match expr_impl_to_u64_fn(expr) {\n    Ok(v) => /* proceed */,\n    Err(e) => eprintln!(\"arg type error: {e:#}\"),\n}","preventionTips":["Always write int64 literals or use ::bigint casts","Never pass strings or decimals to the function","Check inferred literal types in EXPLAIN before use"],"tags":["rust","optimizer","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}