{"record":{"id":"8091d137ed7da000","repo":"influxdata/influxdb","slug":"should-be-registered","errorCode":null,"errorMessage":"should be registered","messagePattern":"should be registered","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/query_functions/src/gapfill.rs","lineNumber":413,"sourceCode":"    }))\n});\n\n#[cfg(test)]\nmod test {\n    use arrow::array::{ArrayRef, Float64Array, TimestampNanosecondArray};\n    use arrow::record_batch::RecordBatch;\n    use datafusion::common::assert_contains;\n    use datafusion::error::Result;\n    use datafusion::prelude::{Expr, SessionContext, col};\n    use datafusion::scalar::ScalarValue;\n    use datafusion_util::lit_timestamptz_nano;\n    use schema::TIME_DATA_TIMEZONE;\n    use std::sync::Arc;\n\n    fn date_bin_gapfill(stride: Expr, source: Expr, origin: Expr) -> Expr {\n        crate::registry()\n            .udf(super::DATE_BIN_GAPFILL_UDF_NAME)\n            .expect(\"should be registered\")\n            .call(vec![stride, source, origin])\n    }\n\n    fn lit_interval_milliseconds(v: i64) -> Expr {\n        Expr::Literal(ScalarValue::new_interval_mdn(0, 0, v * 1_000_000), None)\n    }\n\n    #[tokio::test]\n    async fn date_bin_gapfill_errs() -> Result<()> {\n        let times = Arc::new(\n            TimestampNanosecondArray::from(vec![Some(1000)])\n                .with_timezone_opt(TIME_DATA_TIMEZONE()),\n        );\n        let rb = RecordBatch::try_from_iter(vec![(\"time\", times as ArrayRef)])?;\n        let ctx = SessionContext::new();\n        ctx.register_batch(\"t\", rb).unwrap();\n\n        let df = ctx.table(\"t\").await?.select(vec![date_bin_gapfill(","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/query_functions/src/gapfill.rs#L395-L431","documentation":"A test helper in gapfill.rs looks up the DATE_BIN_GAPFILL UDF by name in the function registry via `crate::registry().udf(super::DATE_BIN_GAPFILL_UDF_NAME).expect(\"should be registered\")`. The panic means the date_bin_gapfill UDF was not found in the registry when the helper built its expression — i.e. the UDF was never registered or its name constant changed.","triggerScenarios":"Calling the `date_bin_gapfill(stride, source, origin)` test helper before/without registering the gapfill UDFs, or after renaming DATE_BIN_GAPFILL_UDF_NAME so registry lookup returns None.","commonSituations":"Developers removing the UDF registration (e.g. during a refactor or feature-gating with cfg attributes), renaming the UDF constant, or constructing the registry without gapfill functions hit this in tests.","solutions":["Check that `crate::registry()` registers all gapfill UDFs (date_bin_gapfill, locf, interpolate) unconditionally or for the test cfg.","Verify DATE_BIN_GAPFILL_UDF_NAME matches the name passed to registry.register_udf.","Reproduce with `cargo test -p query_functions gapfill` and print the registry's UDF names if unsure."],"exampleFix":"// before\nfn date_bin_gapfill(stride: Expr, source: Expr, origin: Expr) -> Expr {\n    crate::registry().udf(super::DATE_BIN_GAPFILL_UDF_NAME).expect(\"should be registered\")...\n}\n// after (ensure registration first, e.g. in test setup)\nlet funcs = crate::all_default_functions();\nassert!(funcs.iter().any(|f| f.name() == super::DATE_BIN_GAPFILL_UDF_NAME), \"date_bin_gapfill not registered\");","handlingStrategy":"validation","validationCode":"let udf = crate::registry().udf(super::DATE_BIN_GAPFILL_UDF_NAME)\n    .unwrap_or_else(|| panic!(\"{} should be registered\", super::DATE_BIN_GAPFILL_UDF_NAME));","typeGuard":"fn registered(reg: &dyn FunctionRegistry, name: &str) -> bool {\n    reg.udf(name).is_ok()\n}","tryCatchPattern":"match crate::registry().udf(super::DATE_BIN_GAPFILL_UDF_NAME) {\n    Ok(udf) => udf.call(vec![stride, source, origin]),\n    Err(e) => panic!(\"date_bin_gapfill should be registered: {e}\"),\n}","preventionTips":["Register gapfill UDFs in a single place invoked by all registry constructors","Add a test asserting every UDF name constant resolves in the registry","Avoid renaming UDF constants without grepping registry registrations"],"tags":["rust","test-panic","registry","udf-not-registered"],"backgroundTag":"resource-not-found","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"}