apache/flink · error · PbCodegenException

Unsupported protobuf simple type:

Error message

Unsupported protobuf simple type: 

What it means

PbCodegenSimpleDeserializer switches on the protobuf FieldDescriptor.JavaType; the default branch throws when the java type is not one of the handled simple kinds. Since simple deserializers are only built for non-message, non-repeated fields, hitting this means an unexpected java type (e.g. a MESSAGE or ENUM landing in the wrong branch) — usually a version/bug artifact or an inconsistent type dispatch upstream.

Source

Thrown at flink-formats/flink-protobuf/src/main/java/org/apache/flink/formats/protobuf/deserialize/PbCodegenSimpleDeserializer.java:81

                if (logicalType.getTypeRoot() == LogicalTypeRoot.CHAR
                        || logicalType.getTypeRoot() == LogicalTypeRoot.VARCHAR) {
                    appender.appendLine(
                            resultVar
                                    + " = BinaryStringData.fromString("
                                    + pbObjectCode
                                    + ".toString())");
                } else if (logicalType.getTypeRoot() == LogicalTypeRoot.TINYINT
                        || logicalType.getTypeRoot() == LogicalTypeRoot.SMALLINT
                        || logicalType.getTypeRoot() == LogicalTypeRoot.INTEGER
                        || logicalType.getTypeRoot() == LogicalTypeRoot.BIGINT) {
                    appender.appendLine(resultVar + " = " + pbObjectCode + ".getNumber()");
                } else {
                    throw new PbCodegenException(
                            "Illegal type for protobuf enum, only char/vachar/int/bigint is supported");
                }
                break;
            default:
                throw new PbCodegenException(
                        "Unsupported protobuf simple type: " + fd.getJavaType());
        }
        return appender.code();
    }
}

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Check the message text: it prints fd.getJavaType() — find that field in the .proto and compare with the DDL column type.
  2. Recompile/regenerate the Java proto classes and ensure the DDL matches the current field kinds (message fields need ROW(...) columns).
  3. Align flink-protobuf and protobuf-java versions with the Flink distribution.
  4. If types genuinely match, report a JIRA with the schema — the dispatch should not have routed here.

Example fix

// proto: message Outer { Inner inner = 1; }
-- before
inner INT,
-- after
inner ROW<...>
Defensive patterns

Strategy: validation

Validate before calling

if (fd.getJavaType() == FieldDescriptor.JavaType.MESSAGE || fd.getJavaType() == FieldDescriptor.JavaType.ENUM) {
    // must be routed to row/enum deserializer, not simple
    assert !(PbFormatUtils.isSimpleType(type)) : "misrouted field " + fd.getName();
}

Try / catch

try {
    deserializer = PbCodegenDeserializeFactory.getPbCodegenDes(fd, type, ctx);
} catch (PbCodegenException e) {
    throw new RuntimeException("Field '" + fd.getFullName() + "' javaType=" + fd.getJavaType(), e);
}

Prevention

When it happens

Trigger: A proto field whose JavaType is MESSAGE reaching the simple deserializer because PbFormatUtils.isSimpleType wrongly classified the Flink type; new protobuf runtime java types not covered by this switch in older flink-protobuf versions.

Common situations: Schema drift between the table schema and the compiled proto message class (e.g. field changed from scalar to message in a newer proto class while the DDL stayed scalar); using mismatched flink-protobuf and protobuf-java versions.

Related errors


AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14). Data as JSON: /api/errors/ec62f316fdce069d. Report an issue: GitHub.