@Override
    public int inferParallelism(Context dynamicParallelismContext) {
        FileEnumerator fileEnumerator;
        List<HiveTablePartition> partitions;
        if (dynamicFilterPartitionKeys != null) {
            fileEnumerator =
                    new HiveSourceDynamicFileEnumerator.Provider(
                                    tablePath.getFullName(),
                                    dynamicFilterPartitionKeys,
                                    partitionBytes,
                                    hiveVersion,
                                    jobConfWrapper)
                            .create();
            if (dynamicParallelismContext.getDynamicFilteringInfo().isPresent()) {
                DynamicFilteringInfo dynamicFilteringInfo =
                        dynamicParallelismContext.getDynamicFilteringInfo().get();
                if (dynamicFilteringInfo instanceof DynamicFilteringEvent) {
                    ((HiveSourceDynamicFileEnumerator) fileEnumerator)
                            .setDynamicFilteringData(
                                    ((DynamicFilteringEvent) dynamicFilteringInfo).getData());
                }
            }
            partitions = ((HiveSourceDynamicFileEnumerator) fileEnumerator).getFinalPartitions();
        } else {
            fileEnumerator = getEnumeratorFactory().create();
            partitions = ((HiveSourceFileEnumerator) fileEnumerator).getPartitions();
        }

        return new HiveDynamicParallelismInferenceFactory(
                        tablePath,
                        jobConfWrapper.conf(),
                        dynamicParallelismContext.getParallelismInferenceUpperBound())
                .create()
                .infer(
                        () ->
                                HiveSourceFileEnumerator.getNumFiles(
                                        partitions, jobConfWrapper.conf()),
                        () ->
                                HiveSourceFileEnumerator.createInputSplits(
                                                0, partitions, jobConfWrapper.conf(), true)
                                        .size())
                .limit(limit);
    }
@Test
    void testDynamicParallelismInferenceWithLimit() throws Exception {
        ObjectPath tablePath = new ObjectPath("default", "hiveTbl2");
        createTable(tablePath, hiveCatalog, true);

        HiveSource<RowData> hiveSource =
                createHiveSourceWithPartition(tablePath, new Configuration(), 1L, null);

        // test inferred parallelism less than maxParallelism
        DynamicParallelismInference.Context context =
                genDynamicParallelismContext(10, Collections.emptyList());
        assertThat(hiveSource.inferParallelism(context)).isEqualTo(1);

        hiveCatalog.dropTable(tablePath, false);
    }