tisonkun commented on code in PR #10392:
URL: https://github.com/apache/datafusion/pull/10392#discussion_r1617977560


##########
datafusion/sql/src/expr/mod.rs:
##########
@@ -215,11 +216,28 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
                         _ => (expr, false),
                     }
                 }
+
                 let expr =
-                    self.sql_expr_to_logical_expr(*obj, schema, 
planner_context)?;
+                    self.sql_expr_to_logical_expr(*expr, schema, 
planner_context)?;
+
+                let indexes = match *subscript {
+                    Subscript::Index { index } => vec![index],
+                    Subscript::Slice { lower_bound, upper_bound } => {
+                        let mut indexes = vec![];
+                        if let Some(lower_bound) = lower_bound {
+                            indexes.push(lower_bound);
+                        }
+                        if let Some(upper_bound) = upper_bound {
+                            indexes.push(upper_bound);
+                        }
+                        indexes
+                    }
+                };

Review Comment:
   For `make_array(1, 2, 3)[1:2]`, previous AST:
   
   ```
   ArrayIndex {
   obj: ...,
   indexes: [
       JsonAccess {
           left: Value(Number("1", false)),
           operator: Colon,
           right: Value(Number("2", false)),
       },
   ],
   }
   ```
   
   new AST:
   
   ```
   Subscript {
   expr: ...,
   subscript: Slice {
       lower_bound: Some(Value(Number("1", false))),
       upper_bound: Some(Value(Number("2", false))),
   },
   }
   ```



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to