use crate::{errors::ExecutorError, limits::MAX_MEMORY_BYTES};
pub const MAX_JOIN_RESULT_ROWS: usize = 100_000_000;
pub fn check_cross_join_size_limit(
left_count: usize,
right_count: usize,
) -> Result<(), ExecutorError> {
let estimated_result_rows = left_count.saturating_mul(right_count);
if estimated_result_rows > MAX_JOIN_RESULT_ROWS {
let estimated_bytes = estimated_result_rows.saturating_mul(100);
return Err(ExecutorError::MemoryLimitExceeded {
used_bytes: estimated_bytes,
max_bytes: MAX_MEMORY_BYTES,
});
}
Ok(())
}