huaxingao commented on code in PR #10659:
URL: https://github.com/apache/iceberg/pull/10659#discussion_r1680162221
##########
spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/source/SparkScan.java:
##########
@@ -175,7 +181,25 @@ public Statistics estimateStatistics() {
protected Statistics estimateStatistics(Snapshot snapshot) {
// its a fresh table, no data
if (snapshot == null) {
- return new Stats(0L, 0L);
+ return new Stats(0L, 0L, Maps.newHashMap());
+ }
+
+ Map<NamedReference, ColumnStatistics> map = Maps.newHashMap();
+
+ if (readConf.enableColumnStats()) {
+ List<StatisticsFile> files = table.statisticsFiles();
+ if (!files.isEmpty()) {
+ List<BlobMetadata> metadataList = (files.get(0)).blobMetadata();
+
+ for (BlobMetadata blobMetadata : metadataList) {
+ long ndv = Long.parseLong(blobMetadata.properties().get("ndv"));
Review Comment:
I have added the code to check null and empty value. It's probably too
strict to throw Exception if the value is null or empty String. I log a DEBUG
message instead.
Is there an agreed type for `org.apache.iceberg.BlobMetadata#type`? If yes,
I will add a check.
##########
spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/source/TestSparkScan.java:
##########
@@ -97,6 +117,36 @@ public static Object[][] parameters() {
};
}
+ @BeforeAll
Review Comment:
Removed and added `withSQLConf`
##########
spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkSQLProperties.java:
##########
@@ -90,4 +90,8 @@ private SparkSQLProperties() {}
public static final String EXECUTOR_CACHE_LOCALITY_ENABLED =
"spark.sql.iceberg.executor-cache.locality.enabled";
public static final boolean EXECUTOR_CACHE_LOCALITY_ENABLED_DEFAULT = false;
+
+ // Controls whether column statistics are enabled when estimating statistics
Review Comment:
Changed to `// Controls whether to calculate column statistics and report
them to Spark`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]