@VisibleForTesting
    RowData createRowData(RowType rowType, Map<String, String> partitionSpec) {
        GenericRowData rowData = new GenericRowData(rowType.getFieldCount());
        for (int i = 0; i < rowType.getFieldCount(); ++i) {
            String value = partitionSpec.get(dynamicFilterPartitionKeys.get(i));
            LogicalType fieldType = rowType.getTypeAt(i);
            Object convertedValue =
                    HivePartitionUtils.restorePartitionValueFromType(
                            hiveShim, value, rowType.getTypeAt(i), defaultPartitionName);
            // Note: also modify supported types if the switch is modified.
            switch (rowType.getTypeAt(i).getTypeRoot()) {
                case TINYINT:
                case SMALLINT:
                case INTEGER:
                case BIGINT:
                    // No further process is necessary.
                    break;
                case CHAR:
                case VARCHAR:
                    convertedValue = StringData.fromString((String) convertedValue);
                    break;
                case DATE:
                    convertedValue =
                            LocalDateConverter.INSTANCE.toInternal((LocalDate) convertedValue);
                    break;
                case TIMESTAMP_WITHOUT_TIME_ZONE:
                    convertedValue =
                            new LocalDateTimeConverter(9)
                                    .toInternal((LocalDateTime) convertedValue);
                    break;
                default:
                    throw new UnsupportedOperationException(
                            "Unsupported type for dynamic filtering:" + rowType.getTypeAt(i));
            }
            if (!fieldType.isNullable() && convertedValue == null) {
                return null;
            }
            rowData.setField(i, convertedValue);
        }
        return rowData;
    }
@Test
    void testCreateRowSupportedTypes() {
        List<Tuple3<LogicalType, Object, String>> testTypeValues = new ArrayList<>();
        testTypeValues.add(new Tuple3<>(new IntType(), 42, "42"));
        testTypeValues.add(new Tuple3<>(new BigIntType(), 9876543210L, "9876543210"));
        testTypeValues.add(new Tuple3<>(new SmallIntType(), (short) 41, "41"));
        testTypeValues.add(new Tuple3<>(new TinyIntType(), (byte) 40, "40"));
        testTypeValues.add(new Tuple3<>(new VarCharType(), StringData.fromString("1234"), "1234"));
        testTypeValues.add(new Tuple3<>(new CharType(), StringData.fromString("7"), "7"));
        testTypeValues.add(
                new Tuple3<>(
                        new DateType(),
                        LocalDateConverter.INSTANCE.toInternal(LocalDate.of(2022, 2, 22)),
                        "2022-2-22"));
        testTypeValues.add(
                new Tuple3<>(
                        new TimestampType(9),
                        new LocalDateTimeConverter(9)
                                .toInternal(LocalDateTime.of(2022, 2, 22, 22, 2, 20, 20222022)),
                        "2022-2-22 22:02:20.020222022"));

        // Default partition values
        testTypeValues.add(
                new Tuple3<>(
                        new VarCharType(),
                        StringData.fromString(HiveConf.ConfVars.DEFAULTPARTITIONNAME.defaultStrVal),
                        HiveConf.ConfVars.DEFAULTPARTITIONNAME.defaultStrVal));
        testTypeValues.add(
                new Tuple3<>(
                        new IntType(), null, HiveConf.ConfVars.DEFAULTPARTITIONNAME.defaultStrVal));

        RowType rowType =
                RowType.of(testTypeValues.stream().map(t -> t.f0).toArray(LogicalType[]::new));
        List<String> keys = new ArrayList<>();
        Map<String, String> spec = new HashMap<>();
        for (int i = 0; i < testTypeValues.size(); i++) {
            keys.add(String.valueOf(i));
            spec.put(String.valueOf(i), testTypeValues.get(i).f2);
        }
        HiveSourceDynamicFileEnumerator enumerator =
                createTestEnumerator(keys, Collections.emptyList());

        RowData result = enumerator.createRowData(rowType, spec);

        for (int i = 0; i < testTypeValues.size(); i++) {
            LogicalType type = testTypeValues.get(i).f0;
            Object expected = testTypeValues.get(i).f1;
            FieldGetter getter = RowData.createFieldGetter(type, i);
            assertThat(getter.getFieldOrNull(result))
                    .withFailMessage(
                            () ->
                                    "Mismatching row type "
                                            + type
                                            + ", expected:"
                                            + expected
                                            + ", actual:"
                                            + getter.getFieldOrNull(result))
                    .isEqualTo(testTypeValues.get(i).f1);
        }
    }