apache/flink · error · UnsupportedOperationException

Key types if input KeyedStreams don't match: {} and {}.

Error message

Key types if input KeyedStreams don't match: {} and {}.

What it means

Error "Key types if input KeyedStreams don't match: {} and {}." thrown in apache/flink.

Source

Thrown at flink-datastream/src/main/java/org/apache/flink/datastream/impl/utils/StreamUtils.java:351

        TypeInformation<?> keyType = null;
        if (inputStream1 instanceof KeyedPartitionStreamImpl) {
            KeyedPartitionStreamImpl<?, IN1> keyedInput1 =
                    (KeyedPartitionStreamImpl<?, IN1>) inputStream1;

            keyType = keyedInput1.getKeyType();

            transform.setStateKeySelectors(keyedInput1.getKeySelector(), null);
            transform.setStateKeyType(keyType);
        }
        if (inputStream2 instanceof KeyedPartitionStreamImpl) {
            KeyedPartitionStreamImpl<?, IN2> keyedInput2 =
                    (KeyedPartitionStreamImpl<?, IN2>) inputStream2;

            TypeInformation<?> keyType2 = keyedInput2.getKeyType();

            if (keyType != null && !(keyType.canEqual(keyType2) && keyType.equals(keyType2))) {
                throw new UnsupportedOperationException(
                        "Key types if input KeyedStreams "
                                + "don't match: "
                                + keyType
                                + " and "
                                + keyType2
                                + ".");
            }

            transform.setStateKeySelectors(
                    transform.getStateKeySelector1(), keyedInput2.getKeySelector());

            // we might be overwriting the one that's already set, but it's the same
            transform.setStateKeyType(keyType2);
        }

        return transform;
    }

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Address the cause reported by the error message: Key types if input KeyedStreams don't match: the reported value and the reported value.
  2. Verify the inputs, configuration values, and classpath/dependency setup related to this operation, then retry.

Example fix

Correct the condition described ("Key types if input KeyedStreams don't match: the reported value and the reported value.") and rerun the job or command.

When it happens

Trigger: Triggered at runtime when the operation fails because: Key types if input KeyedStreams don't match: the reported value and the reported value.

Common situations: Commonly caused by misconfiguration, missing dependencies or files, unsupported types or operations, or invalid user input leading to: Key types if input KeyedStreams don't match: the reported value and the reported value.


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