apache/beam · error · RuntimeException

Unexpected type {}

Error message

Unexpected type {}

What it means

selectIntoRowWithQualifiers copies values into an output row by qualifier kind; the switch over qualifier.getKind() has a default arm that throws when the kind is not one it can copy (e.g. nested ARRAY/MAP qualifiers it doesn't handle).

Source

Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/utils/SelectHelpers.java:411

                  entry.getValue(),
                  selectValueBuilder,
                  fieldAccessDescriptor,
                  nestedInputType,
                  nestedOutputType);

              Row valueBeforeDistribution = selectValueBuilder.build();
              for (int i = 0; i < nestedSchema.getFieldCount(); ++i) {
                selectedMaps.get(i).put(entry.getKey(), valueBeforeDistribution.getValue(i));
              }
            }
          }
          for (Map aMap : selectedMaps) {
            output.addValue(aMap);
          }
          break;
        }
      default:
        throw new RuntimeException("Unexpected type " + qualifier.getKind());
    }
  }

  /**
   * This policy keeps all levels of a name. Every field name in the path to a given field is
   * concated with _ characters.
   */
  public static final SerializableFunction<List<String>, String> CONCAT_FIELD_NAMES =
      l -> {
        return String.join("_", l);
      };

  /**
   * This policy keeps the raw nested field name. If two differently-nested fields have the same
   * name, flattening will fail with this policy.
   */
  public static final SerializableFunction<List<String>, String> KEEP_NESTED_NAME =
      l -> {

View on GitHub (pinned to 12126d8942)

Solutions

  1. Rewrite the selection to avoid the unsupported nesting level (select the parent field instead of drilling into the container).
  2. Change the schema so the field in question uses a supported kind (primitive, row, or supported list/map).
  3. Upgrade Beam — newer versions add handling for more qualifier kinds in SelectHelpers.
  4. Pre-transform the data into rows before the select so the path contains only row qualifiers.

Example fix

// before
Row out = SelectHelpers.selectIntoRow(row, schema, FieldAccessDescriptor.withFieldNames("tags[0]")); // unsupported qualifier kind
// after
Row out = SelectHelpers.selectIntoRow(row, schema, FieldAccessDescriptor.withFieldNames("tags"));
Defensive patterns

Strategy: validation

Validate before calling

// ensure selected field paths only traverse ROW qualifiers
for (String path : selectedFieldNames) {
  Schema.FieldType t = schema.getField(path).getType();
  if (t.getTypeName() == Schema.TypeName.ARRAY || t.getTypeName() == Schema.TypeName.MAP)
    throw new IllegalArgumentException("Path traverses unsupported container qualifier: " + path);
}

Type guard

boolean rowOnlyPath(Schema schema, String field) {
  Schema.FieldType t = schema.getField(field).getType();
  return t.getTypeName() == Schema.TypeName.ROW || t.getTypeName().isPrimitiveType();
}

Try / catch

try {
  return SelectHelpers.selectIntoRow(row, outSchema, descriptor);
} catch (RuntimeException e) {
  if (e.getMessage() != null && e.getMessage().startsWith("Unexpected type")) {
    throw new IllegalArgumentException("Unsupported qualifier kind in select; simplify field path", e);
  }
  throw e;
}

Prevention

When it happens

Trigger: Invoked from selectIntoRow when a selected field path traverses a container whose qualifier kind has no copy branch (unsupported nested collection kind during row materialization).

Common situations: Selecting deeply nested fields in arrays/maps where an intermediate level's type kind is not among the kinds the copier implements; typically hit after schema changes or with exotic field types.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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