apache/beam · error · UnsupportedOperationException

Data generator requires a defined SQL type. Beam type

Error message

Data generator requires a defined SQL type. Beam type '%s' on field '%s' is not supported.

What it means

Data generators produce values based on the field's SQL type (Calcite SqlTypeName). If CalciteUtils.toSqlTypeName cannot map the Beam field type to a SQL type, generation is impossible and an UnsupportedOperationException is thrown when the field generator is created.

Solutions

  1. Change the field to a supported SQL type (INT, BIGINT, DOUBLE, VARCHAR, TIMESTAMP, etc.).
  2. Remove the unsupported field from the datagen table schema.
  3. Upgrade Beam if the type was recently added and mapping support landed later.

Example fix

// before
Schema.Field.of("payload", Schema.FieldType.logicalType(null))
// after
Schema.Field.of("payload", Schema.FieldType.string)
Defensive patterns

Strategy: validation

Validate before calling

for (Schema.Field f : schema.getFields()) {
  if (CalciteUtils.toSqlTypeName(f.getType()) == null) {
    throw new IllegalArgumentException("Unsupported datagen field type: " + f.getName());
  }
}

Type guard

boolean hasSqlType(Schema.Field f) {
  try { return CalciteUtils.toSqlTypeName(f.getType()) != null; } catch (Exception e) { return false; }
}

Try / catch

try { createTable(...); } catch (UnsupportedOperationException e) { /* replace unsupported field type */ }

Prevention

When it happens

Trigger: Declaring a datagen table schema field with a Beam type that has no SQL equivalent (e.g. an exotic logical or nested/logical type) so toSqlTypeName returns null during createValueGeneratorForField.

Common situations: Using custom logical types in the DDL; schema defined programmatically with a type the SQL type mapping doesn't cover; Beam version where a type mapping is missing.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/97ce29c13ad3dacf. Report an issue: GitHub.

Appendix: source

Thrown at sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/provider/datagen/DataGeneratorRowFn.java:108

    FieldGenerator valueGenerator = createValueGeneratorForField(field);
    double nullRate = properties.path("fields." + fieldName + ".null-rate").asDouble(0.0);

    if (nullRate > 0) {
      return (index) ->
          ThreadLocalRandom.current().nextDouble() < nullRate
              ? null
              : valueGenerator.generate(index);
    }
    return valueGenerator;
  }

  private FieldGenerator createValueGeneratorForField(Schema.Field field) {
    String fieldName = field.getName();
    String kind = properties.path("fields." + fieldName + ".kind").asText("random");

    final SqlTypeName sqlTypeName = CalciteUtils.toSqlTypeName(field.getType());
    if (sqlTypeName == null) {
      throw new UnsupportedOperationException(
          "Data generator requires a defined SQL type. Beam type '"
              + field.getType().getTypeName()
              + "' on field '"
              + field.getName()
              + "' is not supported.");
    }

    if ("sequence".equalsIgnoreCase(kind)) {
      if (!SqlTypeName.INT_TYPES.contains(sqlTypeName)) {
        throw new IllegalArgumentException(
            String.format(
                "The 'sequence' generator for integers only supports integer types, but field '%s' is of type '%s'.",
                field.getName(), sqlTypeName));
      }

      JsonNode startNode = properties.path("fields." + fieldName + ".start");
      JsonNode endNode = properties.path("fields." + fieldName + ".end");

View on GitHub (pinned to 12126d8942)