risingwavelabs/risingwave · error · SinkError
no value find in sink schema, index is 0
Error message
no value find in sink schema, index is 0
What it means
When the sink has no primary key columns (`pk_indices` is empty), the formatter derives the document id/key from the first schema field. If the sink schema has zero fields (so `fields().get(0)` is None), construction fails with 'no value find in sink schema, index is 0'.
Source
Thrown at src/connector/src/sink/elasticsearch_opensearch/elasticsearch_opensearch_formatter.rs:57
pub mem_size_b: usize,
pub routing_column: Option<String>,
}
impl ElasticSearchOpenSearchFormatter {
pub fn new(
pk_indices: Vec<usize>,
schema: &Schema,
delimiter: Option<String>,
index_column: Option<usize>,
index: Option<String>,
routing_column: Option<usize>,
) -> Result<Self> {
let key_format = if pk_indices.is_empty() {
let name = &schema
.fields()
.get(0)
.ok_or_else(|| {
SinkError::ElasticSearchOpenSearch(anyhow!(
"no value find in sink schema, index is 0"
))
})?
.name;
format!("{{{}}}", name)
} else if pk_indices.len() == 1 {
let index = *pk_indices.get(0).unwrap();
let name = &schema
.fields()
.get(index)
.ok_or_else(|| {
SinkError::ElasticSearchOpenSearch(anyhow!(
"no value find in sink schema, index is {:?}",
index
))
})?
.name;
format!("{{{}}}", name)View on GitHub (pinned to 6469eb736d)
Solutions
- Ensure the sink schema has at least one column before creating the sink
- Define a primary key on the sink so pk_indices is non-empty
- Fix the upstream query so it selects at least one column
- If this occurs with a valid schema, it indicates a planner/connector bug — file an issue
Example fix
// before CREATE SINK s FROM empty_view WITH (connector='elasticsearch'); -- empty_view has 0 columns // after CREATE SINK s FROM mv_with_columns WITH (connector='elasticsearch', primary_key = 'id');
Defensive patterns
Strategy: validation
Validate before calling
fn check_schema_non_empty(schema: &Schema) -> Result<(), String> {
if schema.fields().is_empty() {
Err("sink schema has no columns; at least one is required".into())
} else {
Ok(())
}
} Prevention
- Never create sinks from empty schemas; verify the upstream query selects columns
- Define a primary key so document ids come from pk columns
- Treat an empty-schema sink reaching the formatter as a bug and report it
When it happens
Trigger: Creating an Elasticsearch/OpenSearch sink whose schema is empty (no columns) while `pk_indices` is empty; the formatter's `new` falls into the empty-pk branch and cannot read field 0.
Common situations: Programmatically constructed sink with an empty schema, connector bug producing a schema-less sink, degenerate SELECT producing no columns.
Related errors
- Cannot find {}
- no value find in sink schema, index is {:?}
- If you want to use upsert, please set the keysType of doris
- Can't find data
- Cannot find {}
AI-assisted analysis of risingwavelabs/risingwave@6469eb736d (2026-09-11).
Data as JSON: /api/errors/2f579053ee036c79.
Report an issue: GitHub.