bvolpato commented on code in PR #26035:
URL: https://github.com/apache/datafusion/pull/26035#discussion_r4239748065


##########
datafusion/substrait/src/logical_plan/producer/rel/read_rel.rs:
##########
@@ -108,6 +108,34 @@ pub fn from_table_scan(
                 advanced_extension: None,
             })),
         }))),
+    });
+
+    // ReadRel cannot represent pushed-down offsets or limits. Keep them with
+    // the scan, even when there is no parent Limit or a Projection separates 
it.
+    if scan.skip.is_none() && scan.fetch.is_none() {
+        return Ok(read);
+    }
+    let empty_schema = Arc::new(DFSchema::empty());
+    let offset_mode = scan
+        .skip
+        .map(|skip| producer.handle_expr(&lit(skip as i64), &empty_schema))
+        .transpose()?
+        .map(Box::new)
+        .map(fetch_rel::OffsetMode::OffsetExpr);
+    let count_mode = scan
+        .fetch
+        .map(|fetch| producer.handle_expr(&lit(fetch as i64), &empty_schema))

Review Comment:
   nonblocking: could we handle scan counts above `i64::MAX` before this cast? 
Optimizing `SELECT * FROM t LIMIT 9223372036854775807 OFFSET 1` against a 
MemTable sets `scan.fetch` to `9223372036854775808`. I reproduced the roundtrip 
failing with `LIMIT must be >= 0, '-9223372036854775808' was provided`, while 
the original plan and base producer succeed.



-- 
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]

Reply via email to