From 6159883286a3c27459ea5a10dcb7d4044c97801d Mon Sep 17 00:00:00 2001 From: jackylee Date: Mon, 10 Aug 2026 10:30:36 +0800 Subject: [PATCH] fix(table): reject row ranges for format tables at read construction --- crates/paimon/src/table/format_read_builder.rs | 7 +++++++ crates/paimon/src/table/read_builder.rs | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/crates/paimon/src/table/format_read_builder.rs b/crates/paimon/src/table/format_read_builder.rs index 4360d041..a2b6f81f 100644 --- a/crates/paimon/src/table/format_read_builder.rs +++ b/crates/paimon/src/table/format_read_builder.rs @@ -127,6 +127,13 @@ impl<'a> FormatReadBuilder<'a> { } pub(crate) fn new_read(&self) -> Result> { + // Fail closed here as well as in `FormatTableScan::plan`, so a caller that + // goes straight to `new_read` cannot silently read unfiltered rows. + if self.row_ranges.is_some() { + return Err(crate::Error::Unsupported { + message: "Row ranges are not supported for format tables".to_string(), + }); + } let core_options = self.table.schema().core_options(); core_options.ensure_read_authorized()?; let read_type = match self.resolve_read_type()? { diff --git a/crates/paimon/src/table/read_builder.rs b/crates/paimon/src/table/read_builder.rs index cce6838e..41a8f19d 100644 --- a/crates/paimon/src/table/read_builder.rs +++ b/crates/paimon/src/table/read_builder.rs @@ -819,6 +819,15 @@ mod tests { assert!( matches!(error, crate::Error::Unsupported { ref message } if message.contains("format tables")) ); + + // `new_read` must reject too: a caller that skips planning would otherwise + // read every row instead of the requested ranges. + let mut builder = table.new_read_builder(); + builder.with_row_ranges(Vec::new()); + let error = builder.new_read().unwrap_err(); + assert!( + matches!(error, crate::Error::Unsupported { ref message } if message.contains("format tables")) + ); } fn dv_pk_table(table_path: &str, merge_engine: &str) -> Table {