pepijnve commented on code in PR #19431:
URL: https://github.com/apache/datafusion/pull/19431#discussion_r2637804725


##########
datafusion/functions-table/src/generate_series.rs:
##########
@@ -109,6 +133,59 @@ impl SeriesValue for i64 {
     fn display_value(&self) -> String {
         self.to_string()
     }
+
+    fn generate_array_for_series(
+        series_state: &mut GenericSeriesState<Self>,
+    ) -> Result<ArrayRef> {
+        let array: Int64Array = if series_state.step > 0 {
+            if series_state.include_end {
+                Int64Array::from_iter_values(
+                    (series_state.current..=series_state.end)
+                        .step_by(series_state.step as usize)
+                        .take(series_state.batch_size),
+                )
+            } else {
+                Int64Array::from_iter_values(
+                    (series_state.current..series_state.end)
+                        .step_by(series_state.step as usize)
+                        .take(series_state.batch_size),
+                )
+            }
+        } else {
+            // step < 0
+            let cur = series_state.current as i128;

Review Comment:
   Can the same effect be achieved using a reverse iterator like:
   
   ```
   (series_state.end..=series_state.current).rev()
   ```
   
   Depending on whether end is exclusive or not, you may have to offset it by 
one.



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