risingwavelabs/risingwave · error

internal_get_channel_delta_stats expects 0 or 2 arguments

Error message

internal_get_channel_delta_stats expects 0 or 2 arguments

What it means

Guard in the table_function_to_internal_get_channel_delta_stats rule: internal_get_channel_delta_stats accepts either 0 arguments (service defaults) or exactly 2 (at_time and time_offset); any other argument count, including 1, fails rule application with this error.

Solutions

  1. Call with either no arguments: `internal_get_channel_delta_stats()`,
  2. or with exactly two int64 arguments: `internal_get_channel_delta_stats(at_time, time_offset)`.
  3. Check the function's documented signature before calling.
  4. If a one-argument form is needed, request the feature or use the two-argument form with a zero offset.

Example fix

-- before
SELECT * FROM internal_get_channel_delta_stats(60);
-- after
SELECT * FROM internal_get_channel_delta_stats(60, 0);
Defensive patterns

Strategy: validation

Validate before calling

-- Valid arities only
SELECT * FROM internal_get_channel_delta_stats();
SELECT * FROM internal_get_channel_delta_stats(3600, 0);

Try / catch

// Build-plan errors surface at query time; validate arg count client-side
if args.len() != 0 && args.len() != 2 {
    eprintln!("internal_get_channel_delta_stats expects 0 or 2 arguments");
}

Prevention

When it happens

Trigger: Invoking the table function with 1 argument or 3+ arguments, e.g. `internal_get_channel_delta_stats(60)`.

Common situations: Users assuming a single relative-offset form exists, or copy-pasting signatures from other internal table functions.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of risingwavelabs/risingwave@6469eb736d (2026-09-11). Data as JSON: /api/errors/bf06f21020d1baf6. Report an issue: GitHub.

Appendix: source

Thrown at src/frontend/src/optimizer/rule/table_function_to_internal_get_channel_delta_stats.rs:103

            Field::new("backpressure_rate", DataType::Float64),
            Field::new("recv_throughput", DataType::Float64),
            Field::new("send_throughput", DataType::Float64),
        ];

        // Extract parameters if provided
        let (at_time, time_offset) = match table_function.args.len() {
            0 => (None, None), // No default, let the service handle it
            2 => {
                let at_expr = &table_function.args[0];
                let offset_expr = &table_function.args[1];

                let at_time = expr_impl_to_u64_fn(at_expr)?;
                let time_offset = expr_impl_to_u64_fn(offset_expr)?;

                (at_time, time_offset)
            }
            _ => {
                bail!("internal_get_channel_delta_stats expects 0 or 2 arguments");
            }
        };

        // Create a LogicalGetChannelDeltaStats node with the extracted parameters
        let plan = LogicalGetChannelDeltaStats::new(ctx, Schema::new(fields), at_time, time_offset);
        Ok(plan.into())
    }
}

impl TableFunctionToInternalGetChannelDeltaStatsRule {
    pub fn create() -> BoxedRule {
        Box::new(TableFunctionToInternalGetChannelDeltaStatsRule {})
    }
}

View on GitHub (pinned to 6469eb736d)