RussellSpitzer commented on code in PR #11615: URL: https://github.com/apache/iceberg/pull/11615#discussion_r1852403873
########## spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/source/SparkScan.java: ########## @@ -248,6 +296,88 @@ protected Statistics estimateStatistics(Snapshot snapshot) { return new Stats(sizeInBytes, rowsCount, colStatsMap); } + private Map<Integer, Long> calculateNullCount( + Map<String, Map<Integer, Long>> distinctDataFilesNullCount) { + Map<Integer, Long> nullCount; + // get the null counts from the manifest file + nullCount = + distinctDataFilesNullCount.values().stream() // Stream<Map<Integer, Long>> + .flatMap( + innerMap -> + innerMap.entrySet().stream()) // Flatten to Stream<Map.Entry<Integer, Long>> + .collect( + Collectors.toMap( + Map.Entry::getKey, // Key is the column id + Map.Entry::getValue, + Long::sum, + HashMap::new)); + return nullCount; + } + + private Object toSparkType(Type type, Object value) { + switch (type.typeId()) { + case DECIMAL: + return Decimal.apply((BigDecimal) value); + default: + } + return value; + } + + // min/max are calculated for numeric, Date, and Timestamp only + private boolean isValidMinMaxType(Type type) { + switch (type.typeId()) { + case DATE: + case TIMESTAMP: + case INTEGER: + case LONG: + case FLOAT: + case DOUBLE: + case DECIMAL: + case BOOLEAN: + return true; + default: + return false; + } + } + + // extract min/max values from the manifests + private Map<Integer, Object> calculateMinMax( + boolean isMin, Map<String, Map<Integer, ByteBuffer>> distinctDataFilesBounds) { Review Comment: I'm not a big fan of parmeterizing "isMin", i'd probably just use two different functions that call a more generic version so that the code in the original calling location is clear and you don't have to know that "true" means "min" -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org