@Override
    public void processElement(StreamRecord<E> element) throws Exception {
        final E externalRecord = element.getValue();

        final Object internalRecord;
        try {
            internalRecord = converter.toInternal(externalRecord);
        } catch (Exception e) {
            throw new FlinkRuntimeException(
                    String.format(
                            "Error during input conversion from external DataStream API to "
                                    + "internal Table API data structures. Make sure that the "
                                    + "provided data types that configure the converters are "
                                    + "correctly declared in the schema. Affected record:\n%s",
                            externalRecord),
                    e);
        }

        final RowData payloadRowData;
        if (requiresWrapping) {
            final GenericRowData wrapped = new GenericRowData(RowKind.INSERT, 1);
            wrapped.setField(0, internalRecord);
            payloadRowData = wrapped;
        } else {
            // top-level records must not be null and will be skipped
            if (internalRecord == null) {
                return;
            }
            payloadRowData = (RowData) internalRecord;
        }

        final RowKind kind = payloadRowData.getRowKind();

        if (isInsertOnly && kind != RowKind.INSERT) {
            throw new FlinkRuntimeException(
                    String.format(
                            "Error during input conversion. Conversion expects insert-only "
                                    + "records but DataStream API record contains: %s",
                            kind));
        }

        if (!produceRowtimeMetadata) {
            output.collect(outRecord.replace(payloadRowData));
            return;
        }

        if (!element.hasTimestamp()) {
            throw new FlinkRuntimeException(
                    "Could not find timestamp in DataStream API record. "
                            + "Make sure that timestamps have been assigned before and "
                            + "the event-time characteristic is enabled.");
        }

        final GenericRowData rowtimeRowData = new GenericRowData(1);
        rowtimeRowData.setField(0, TimestampData.fromEpochMillis(element.getTimestamp()));

        final JoinedRowData joinedRowData = new JoinedRowData(kind, payloadRowData, rowtimeRowData);

        output.collect(outRecord.replace(joinedRowData));
    }
@Test
    public void testInvalidEventTime() {
        final InputConversionOperator<Row> operator =
                new InputConversionOperator<>(
                        createConverter(DataTypes.ROW(DataTypes.FIELD("f", DataTypes.INT()))),
                        false,
                        true,
                        false,
                        true);
        assertThatThrownBy(
                        () ->
                                operator.processElement(
                                        new StreamRecord<>(Row.ofKind(RowKind.INSERT, 12))))
                .satisfies(
                        anyCauseMatches(
                                FlinkRuntimeException.class,
                                "Could not find timestamp in DataStream API record."));
    }