public static TRowSet toTRowSet(
            TProtocolVersion version, ResolvedSchema schema, List<RowData> data) {
        for (RowData row : data) {
            if (row.getRowKind() != RowKind.INSERT) {
                throw new UnsupportedOperationException(
                        "HiveServer2 Endpoint only supports to serialize the INSERT-ONLY RowData.");
            }
        }

        List<RowData.FieldGetter> fieldGetters = new ArrayList<>();
        for (int i = 0; i < schema.getColumnCount(); i++) {
            fieldGetters.add(
                    RowData.createFieldGetter(
                            schema.getColumnDataTypes().get(i).getLogicalType(), i));
        }

        List<LogicalType> fieldTypes =
                schema.getColumnDataTypes().stream()
                        .map(DataType::getLogicalType)
                        .collect(Collectors.toList());
        if (version.getValue() < HIVE_CLI_SERVICE_PROTOCOL_V6.getVersion().getValue()) {
            return toRowBasedSet(fieldTypes, fieldGetters, data);
        } else {
            return toColumnBasedSet(fieldTypes, fieldGetters, data);
        }
    }
@Test
    public void testSerializeRowDataWithRowKind() {
        for (RowKind kind :
                Arrays.asList(RowKind.UPDATE_BEFORE, RowKind.UPDATE_AFTER, RowKind.DELETE)) {
            assertThatThrownBy(
                            () ->
                                    toTRowSet(
                                            HIVE_CLI_SERVICE_PROTOCOL_V5,
                                            ResolvedSchema.of(
                                                    Column.physical("f0", DataTypes.INT())),
                                            Collections.singletonList(
                                                    GenericRowData.ofKind(kind, 1))))
                    .satisfies(
                            anyCauseMatches(
                                    UnsupportedOperationException.class,
                                    "HiveServer2 Endpoint only supports to serialize the INSERT-ONLY RowData."));
        }
    }