{"record":{"id":"e26ca9cff743c2a6","repo":"databendlabs/databend","slug":"failed-to-infer-billing-usage-daily-schema","errorCode":null,"errorMessage":"failed to infer billing_usage_daily schema","messagePattern":"failed to infer billing_usage_daily schema","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/query/service/src/table_functions/billing_usage_daily.rs","lineNumber":82,"sourceCode":"    args_parsed: BillingUsageDailyArgsParsed,\n    table_args: TableArgs,\n}\n\nimpl BillingUsageDailyTable {\n    pub fn create(\n        database_name: &str,\n        table_func_name: &str,\n        table_id: u64,\n        table_args: TableArgs,\n    ) -> Result<Arc<dyn TableFunction>> {\n        let args_parsed = BillingUsageDailyArgsParsed::parse(&table_args)?;\n        let table_info = TableInfo {\n            ident: TableIdent::new(table_id, 0),\n            desc: format!(\"'{}'.'{}'\", database_name, table_func_name),\n            name: String::from(\"billing_usage_daily\"),\n            meta: TableMeta {\n                schema: infer_table_schema(&billing_usage_daily_schema())\n                    .expect(\"failed to infer billing_usage_daily schema\"),\n                engine: String::from(table_func_name),\n                created_on: DateTime::from_timestamp(0, 0).unwrap(),\n                updated_on: DateTime::from_timestamp(0, 0).unwrap(),\n                ..Default::default()\n            },\n            ..Default::default()\n        };\n\n        Ok(Arc::new(Self {\n            table_info,\n            args_parsed,\n            table_args,\n        }))\n    }\n}\n\n#[async_trait::async_trait]\nimpl Table for BillingUsageDailyTable {","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/query/service/src/table_functions/billing_usage_daily.rs#L64-L100","documentation":"This panic occurs when infer_table_schema fails to build a valid schema from the hardcoded billing_usage_daily table function schema definition. Since the schema is static and expected to always be valid, the code uses expect and treats failure as an internal bug — the table function cannot be constructed without a schema.","triggerScenarios":"Creating or querying the billing_usage_daily(...) table function when infer_table_schema(&billing_usage_daily_schema()) returns Err, i.e. the DataSchema built by billing_usage_daily_schema() cannot be converted into a table schema.","commonSituations":"A code change to billing_usage_daily_schema() introducing an invalid/unsupported data type or duplicate field names; version mismatches where the schema definition no longer matches what infer_table_schema accepts; it should never fail in a correctly built release binary.","solutions":["Inspect the schema returned by billing_usage_daily_schema() for unsupported or malformed field types and fix the definition.","Verify the binary matches a supported release; a corrupted/partially built binary can break internal schema inference.","Report/fix upstream: the schema is static so the fix belongs in the source, not user configuration."],"exampleFix":"// before\nlet t = billing_usage_daily_type();\n// (field type not supported by infer_table_schema, e.g. a custom variant)\n// after\nlet t = TableDataType::String; // use a supported primitive type in billing_usage_daily_schema()","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// calling the schema inference in Rust integration code\nmatch infer_table_schema(&billing_usage_daily_schema()) {\n    Ok(schema) => { /* proceed */ }\n    Err(e) => log::error!(\"billing_usage_daily schema inference failed: {:?}\", e),\n}","preventionTips":["Keep the hardcoded schema limited to primitive supported TableDataTypes.","Add a unit test that runs infer_table_schema on billing_usage_daily_schema().","Avoid duplicate field names or custom type variants in static schemas.","Pin tested binary releases; this panic indicates a build/source bug, not user error."],"tags":["rust","panic","table-function","schema"],"backgroundTag":"schema-validation-failed","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"}