andygrove commented on code in PR #1756:
URL: https://github.com/apache/datafusion-comet/pull/1756#discussion_r2098863135


##########
native/core/src/execution/planner.rs:
##########
@@ -1108,6 +1108,44 @@ impl PhysicalPlanner {
                     .map(|expr| self.create_expr(expr, 
Arc::clone(&required_schema)))
                     .collect();
 
+                let default_values: Option<HashMap<usize, ScalarValue>> = if 
!scan
+                    .default_values
+                    .is_empty()
+                {
+                    // We have default values. Extract the two lists (same 
length) of values and
+                    // indexes in the schema, and then create a HashMap to use 
in the SchemaMapper.
+                    let default_values: Vec<ScalarValue> = scan
+                        .default_values
+                        .iter()
+                        .map(|expr| {
+                            let literal = self
+                                .create_expr(expr, 
Arc::clone(&required_schema))
+                                .unwrap();
+                            literal
+                                .as_any()
+                                .downcast_ref::<DataFusionLiteral>()
+                                .ok_or_else(|| {
+                                    GeneralError("Expected literal of default 
value.".to_string())
+                                })
+                                .map(|literal| literal.value().clone())
+                                .unwrap()
+                        })
+                        .collect::<Vec<ScalarValue>>();

Review Comment:
   nit: we can avoid unwrap here:
   
   ```suggestion
                       let default_values: Result<Vec<ScalarValue>, 
DataFusionError> = scan
                           .default_values
                           .iter()
                           .map(|expr| {
                               let literal = self.create_expr(expr, 
Arc::clone(&required_schema))?;
                               let df_literal = literal
                                   .as_any()
                                   .downcast_ref::<DataFusionLiteral>()
                                   .ok_or_else(|| {
                                   GeneralError("Expected literal of default 
value.".to_string())
                               })?;
                               Ok(df_literal.value().clone())
                           })
                           .collect();
                       let default_values = default_values?;
   ```



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