risingwavelabs/risingwave · error · SinkError
ENCODE BYTES requires the column to be of type BYTEA, but go
Error message
ENCODE BYTES requires the column to be of type BYTEA, but got type {} What it means
The value encoder for BYTES found exactly one column (the count check passed) but that column is not BYTEA. Only bytea columns can be passed through as raw encoded bytes, so any other type is rejected.
Source
Thrown at src/connector/src/sink/formatter/mod.rs:247
schema_ref.data_type
)))
}
}
// This is being used as a value encoder
None => {
// Ensure the schema has exactly one column and it's of type BYTEA
if params.schema.len() != 1 {
return Err(SinkError::Config(anyhow!(
"ENCODE BYTES requires exactly one column, got {} columns",
params.schema.len()
)));
}
let field = ¶ms.schema.fields[0];
if let DataType::Bytea = field.data_type {
Ok(BytesEncoder::new(params.schema, 0))
} else {
Err(SinkError::Config(anyhow!(
"ENCODE BYTES requires the column to be of type BYTEA, but got type {}",
field.data_type
)))
}
}
}
}
}
impl EncoderBuild for TextEncoder {
async fn build(params: EncoderParams<'_>, pk_indices: Option<Vec<usize>>) -> Result<Self> {
let (pk_index, schema_ref) = ensure_only_one_pk("TEXT", ¶ms, &pk_indices)?;
match &schema_ref.data_type() {
DataType::Varchar
| DataType::Boolean
| DataType::Int16
| DataType::Int32
| DataType::Int64View on GitHub (pinned to 6469eb736d)
Solutions
- Cast the column to bytea in the sink query
- Ensure the payload column is declared BYTEA
- Switch to value_encode='json' if you want automatic serialization
Example fix
// before CREATE SINK s AS SELECT id FROM t WITH (value_encode = 'bytes'); // after CREATE SINK s AS SELECT id::bytea AS id FROM t WITH (value_encode = 'bytes');
Defensive patterns
Strategy: validation
Validate before calling
if value_encode == "bytes" && schema.fields[0].data_type != DataType::Bytea {
return Err("value encode bytes requires a bytea column");
} Type guard
fn is_bytea(f: &Field) -> bool { f.data_type == DataType::Bytea } Prevention
- Cast the payload column to bytea in the sink SELECT
- Verify column type with DESC before configuring value encode
When it happens
Trigger: VALUE ENCODE BYTES with a single-column schema whose type is not DataType::Bytea — e.g. SELECT id FROM t WITH (value_encode='bytes').
Common situations: Assuming the encoder will serialize an INT/VARCHAR/JSON column into bytes automatically; writing sink SQL that selects one non-bytea column.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- The key encode is BYTES, but the primary key column {} has t
- The key encode is TEXT, but the primary key column {} has ty
- HTTP sink url column must be varchar, got {:?}
- HTTP sink payload column must be varchar or jsonb, got {:?}
- unexpected url column type, expected varchar
AI-assisted analysis of risingwavelabs/risingwave@6469eb736d (2026-09-11).
Data as JSON: /api/errors/61894a44f2e330af.
Report an issue: GitHub.