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


##########
datafusion/expr/src/expr.rs:
##########
@@ -2701,6 +2785,20 @@ fn rewrite_placeholder(expr: &mut Expr, other: &Expr, 
schema: &DFSchema) -> Resu
     Ok(())
 }
 
+/// Sets the [`DataType`] of a [`Placeholder`] expression if it is currently 
`None`.
+///
+/// This is used during placeholder type inference to assign a specific data 
type
+/// to untyped placeholders based on context (e.g., the expected type from a 
function signature).
+fn rewrite_placeholder_type(expr: &mut Expr, dt: &DataType) -> Result<()> {
+    if let Expr::Placeholder(Placeholder { id: _, field }) = expr
+        && field.is_none()
+        && !dt.is_null()
+    {
+        *field = Some(Arc::new(Field::new("", dt.clone(), true)));

Review Comment:
   Using the empty string here as the name of the field is appropriate, but we 
do get a subtle difference in behaviour compared to `rewrite_placeholder`. 
There the result of `Expr::to_field` is used verbatim, which may result in e.g. 
the name of column popping up in the placeholder. Would it be preferable to 
either always use the empty string of the id of the placeholder as field name 
in `rewrite_placeholder` as well?



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