()
| 2208 | |
| 2209 | #[test] |
| 2210 | fn test_with_fetch_basic_preservation() { |
| 2211 | // Test that column statistics and byte size are preserved (as inexact) when applying fetch |
| 2212 | let original_stats = Statistics { |
| 2213 | num_rows: Precision::Exact(1000), |
| 2214 | total_byte_size: Precision::Exact(8000), |
| 2215 | column_statistics: vec![ |
| 2216 | ColumnStatistics { |
| 2217 | null_count: Precision::Exact(10), |
| 2218 | max_value: Precision::Exact(ScalarValue::Int32(Some(100))), |
| 2219 | min_value: Precision::Exact(ScalarValue::Int32(Some(0))), |
| 2220 | sum_value: Precision::Exact(ScalarValue::Int32(Some(5050))), |
| 2221 | distinct_count: Precision::Exact(50), |
| 2222 | byte_size: Precision::Exact(4000), |
| 2223 | }, |
| 2224 | ColumnStatistics { |
| 2225 | null_count: Precision::Exact(20), |
| 2226 | max_value: Precision::Exact(ScalarValue::Int64(Some(200))), |
| 2227 | min_value: Precision::Exact(ScalarValue::Int64(Some(10))), |
| 2228 | sum_value: Precision::Exact(ScalarValue::Int64(Some(10100))), |
| 2229 | distinct_count: Precision::Exact(75), |
| 2230 | byte_size: Precision::Exact(8000), |
| 2231 | }, |
| 2232 | ], |
| 2233 | }; |
| 2234 | |
| 2235 | // Apply fetch of 100 rows (10% of original) |
| 2236 | let result = original_stats.clone().with_fetch(Some(100), 0, 1).unwrap(); |
| 2237 | |
| 2238 | // Check num_rows |
| 2239 | assert_eq!(result.num_rows, Precision::Exact(100)); |
| 2240 | |
| 2241 | // Check total_byte_size is computed as sum of scaled column byte_size values |
| 2242 | // Column 1: 4000 * 0.1 = 400, Column 2: 8000 * 0.1 = 800, Sum = 1200 |
| 2243 | assert_eq!(result.total_byte_size, Precision::Inexact(1200)); |
| 2244 | |
| 2245 | // Check column statistics are preserved but marked as inexact |
| 2246 | assert_eq!(result.column_statistics.len(), 2); |
| 2247 | |
| 2248 | // First column |
| 2249 | assert_eq!( |
| 2250 | result.column_statistics[0].null_count, |
| 2251 | Precision::Inexact(10) |
| 2252 | ); |
| 2253 | assert_eq!( |
| 2254 | result.column_statistics[0].max_value, |
| 2255 | Precision::Inexact(ScalarValue::Int32(Some(100))) |
| 2256 | ); |
| 2257 | assert_eq!( |
| 2258 | result.column_statistics[0].min_value, |
| 2259 | Precision::Inexact(ScalarValue::Int32(Some(0))) |
| 2260 | ); |
| 2261 | assert_eq!( |
| 2262 | result.column_statistics[0].sum_value, |
| 2263 | Precision::Inexact(ScalarValue::Int32(Some(5050))) |
| 2264 | ); |
| 2265 | assert_eq!( |
| 2266 | result.column_statistics[0].distinct_count, |
| 2267 | Precision::Inexact(50) |
nothing calls this directly
no test coverage detected
searching dependent graphs…