apache/flink · error · PbCodegenException

Unsupported data type in schema:

Error message

Unsupported data type in schema: 

What it means

PbCodegenSimpleSerializer's switch on the Flink type root has a default branch that throws for any type not handled (the message includes the type). This fires at codegen time when a column's LogicalTypeRoot has no protobuf serialization mapping — e.g. type roots added by newer Flink versions or exotic types used on a simple proto field.

Source

Thrown at flink-formats/flink-protobuf/src/main/java/org/apache/flink/formats/protobuf/serialize/PbCodegenSimpleSerializer.java:114

                    appender.begin("if(null == " + enumValueDescVar + "){");
                    // choose the first enum element as default value if such value is invalid enum
                    appender.appendLine(resultVar + " = " + enumTypeStr + ".values()[0]");
                    appender.end("}");
                    appender.begin("else{");
                    // choose the exact enum value
                    appender.appendLine(
                            resultVar + " = " + enumTypeStr + ".valueOf(" + enumValueDescVar + ")");
                    appender.end("}");
                } else {
                    appender.appendLine(resultVar + " = " + fromVar);
                }
                return appender.code();
            case VARBINARY:
            case BINARY:
                appender.appendLine(resultVar + " = ByteString.copyFrom(" + flinkObjectCode + ")");
                return appender.code();
            default:
                throw new PbCodegenException("Unsupported data type in schema: " + type);
        }
    }
}

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Use the type in the exception to find the column; cast it in the SELECT/DDL to a supported root (INT, BIGINT, VARCHAR, BOOLEAN, FLOAT, DOUBLE, VARBINARY, DECIMAL, DATE, TIME, TIMESTAMP, CHAR).
  2. Remove the column from the sink projection.
  3. If the type should be supported, check for an upstream fix or file a JIRA in flink-formats/flink-protobuf.

Example fix

-- before
SELECT id, tags FROM src;  -- tags MULTISET<STRING>
-- after
SELECT id, MAP_KEYS(tags) AS tag_array FROM src;  -- ARRAY<STRING>
Defensive patterns

Strategy: validation

Validate before calling

switch (type.getTypeRoot()) {
    case MULTISET: case STRUCTURED_TYPE: case DISTINCT_TYPE: case RAW: case SYMBOL:
        throw new IllegalArgumentException("Not protobuf-serializable: " + type);
    // else ok
}

Prevention

When it happens

Trigger: A sink column with a type root outside the supported set (e.g. MULTISET, STRUCTURED_TYPE, DISTINCT_TYPE, SYMBOL, untime-window types) mapped to a proto scalar field.

Common situations: Schema evolution in catalogs introducing new type roots; DDLs that worked on one Flink version failing after upgrade because a type became representable but not protobuf-mappable.

Related errors


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