@@ -22,6 +22,7 @@ use pyo3::IntoPyObjectExt;
2222use pyo3:: prelude:: * ;
2323
2424use crate :: common:: df_schema:: PyDFSchema ;
25+ use crate :: expr:: PyExpr ;
2526use crate :: expr:: logical_node:: LogicalNode ;
2627use crate :: sql:: logical:: PyLogicalPlan ;
2728
@@ -64,19 +65,23 @@ impl Display for PyLimit {
6465
6566#[ pymethods]
6667impl PyLimit {
67- // NOTE: Upstream now has expressions for skip and fetch
68- // TODO: Do we still want to expose these?
69- // REF: https://github.com/apache/datafusion/pull/12836
70-
71- // /// Retrieves the skip value for this `Limit`
72- // fn skip(&self) -> usize {
73- // self.limit.skip
74- // }
68+ // Retrieves the skip expression for this `Limit`, if any.
69+ //
70+ // `LIMIT`/`OFFSET` were changed upstream to support arbitrary
71+ // expressions (not just constants), see
72+ // https://github.com/apache/datafusion/pull/13028. Callers that expect
73+ // a simple literal (the common case, e.g. `OFFSET 5`) should evaluate
74+ // the returned `PyExpr` via `Expr.python_value()`.
75+ fn skip ( & self ) -> PyResult < Option < PyExpr > > {
76+ Ok ( self . limit . skip . as_deref ( ) . cloned ( ) . map ( PyExpr :: from) )
77+ }
7578
76- // /// Retrieves the fetch value for this `Limit`
77- // fn fetch(&self) -> Option<usize> {
78- // self.limit.fetch
79- // }
79+ // Retrieves the fetch expression for this `Limit`, if any.
80+ //
81+ // See the note on `skip` above regarding expression-based limits.
82+ fn fetch ( & self ) -> PyResult < Option < PyExpr > > {
83+ Ok ( self . limit . fetch . as_deref ( ) . cloned ( ) . map ( PyExpr :: from) )
84+ }
8085
8186 /// Retrieves the input `LogicalPlan` to this `Limit` node
8287 fn input ( & self ) -> PyResult < Vec < PyLogicalPlan > > {
0 commit comments