Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spark: Use correct statistics file in SparkScan::estimateStatistics(Snapshot) #12482

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wypoon
Copy link
Contributor

@wypoon wypoon commented Mar 8, 2025

This fixes a bug in SparkScan::estimateStatistics(Snapshot).
Table::statisticsFiles() returns a List<StatisticsFile>. We need to get the StatisticsFile with the snapshotId of the Snapshot for use in estimating the statistics.
I modified an existing test so that it fails without the fix and passes with it.

Table::statisticsFiles() returns a List. We need to get the StatisticsFile
with the snapshotId of the Snapshot.
@github-actions github-actions bot added the spark label Mar 8, 2025

Map<String, Long> expectedNDV = Maps.newHashMap();
expectedNDV.put("id", 6L);
withSQLConf(reportColStatsEnabled, () -> checkColStatisticsReported(scan, 6L, expectedNDV));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test is parameterized with three parameters. When run on its own without the fix, from one to three cases will fail. The reason some of the time the correct StatisticsFile appears as the first in the List is that when TableMetadata is built (

statisticsFiles.values().stream().flatMap(List::stream).collect(Collectors.toList()),
), the List is built from a Map and the order of the entries depend on the hashing of the snapshotId (which is random).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant