apache/flink · error · InvalidFieldReferenceException

Wildcard expressions are not allowed here.

Error message

Wildcard expressions are not allowed here.

What it means

Thrown by RowTypeInfo.getTypeAt(String) when the fieldExpression is exactly '*' or '_'. getTypeAt returns a single field's type, so wildcards are invalid. This is an InvalidFieldReferenceException.

Source

Thrown at flink-core/src/main/java/org/apache/flink/api/java/typeutils/RowTypeInfo.java:176

                } else {
                    throw new InvalidFieldReferenceException(
                            "Nested field expression \""
                                    + tail
                                    + "\" not possible on atomic type "
                                    + fieldType
                                    + ".");
                }
            }
        }
    }

    @Override
    public <X> TypeInformation<X> getTypeAt(String fieldExpression) {
        Matcher matcher = PATTERN_NESTED_FIELDS.matcher(fieldExpression);
        if (!matcher.matches()) {
            if (fieldExpression.equals(ExpressionKeys.SELECT_ALL_CHAR)
                    || fieldExpression.equals(ExpressionKeys.SELECT_ALL_CHAR_SCALA)) {
                throw new InvalidFieldReferenceException(
                        "Wildcard expressions are not allowed here.");
            } else {
                throw new InvalidFieldReferenceException(
                        "Invalid format of Row field expression \"" + fieldExpression + "\".");
            }
        }

        String field = matcher.group(1);

        Matcher intFieldMatcher = PATTERN_INT_FIELD.matcher(field);
        int fieldIndex;
        if (intFieldMatcher.matches()) {
            // field expression is an integer
            fieldIndex = Integer.valueOf(field);
        } else {
            fieldIndex = this.getFieldIndex(field);
        }
        // fetch the field type will throw exception if the index is illegal

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Do not pass '*' or '_' to getTypeAt. Use getFlatFields for wildcard selection.
  2. Filter wildcard expressions before calling getTypeAt.

Example fix

// before
rowType.getTypeAt("*");
// after
rowType.getFlatFields("*");
Defensive patterns

Strategy: validation

Validate before calling

void safeGetTypeAt(RowTypeInfo type, String expr) {
    if ("*".equals(expr) || "_".equals(expr)) {
        throw new IllegalArgumentException(
            "Use getFlatFields for wildcards");
    }
    type.getTypeAt(expr);
}

Prevention

When it happens

Trigger: Calling rowType.getTypeAt("*") or rowType.getTypeAt("_"). ExpressionKeys strips wildcards before calling getTypeAt (Keys.java:334-338), so this indicates direct API misuse.

Common situations: Programmatic code that forwards the same expression to both getFlatFields and getTypeAt without filtering wildcards. Rare in typical user code.

Related errors


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