You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "dqkqd (via GitHub)" <gi...@apache.org> on 2025/11/16 01:33:55 UTC

[PR] fix: update schema's data type for `LogicalPlan::Values` after placeholder substitution [datafusion]

dqkqd opened a new pull request, #18740:
URL: https://github.com/apache/datafusion/pull/18740

   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   - Closes #.
   
   ## Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   ## What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   ## Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   ## Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->
   


-- 
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-unsubscribe@datafusion.apache.org

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


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


Re: [PR] fix: update schema's data type for `LogicalPlan::Values` after placeholder substitution [datafusion]

Posted by "dqkqd (via GitHub)" <gi...@apache.org>.
dqkqd commented on code in PR #18740:
URL: https://github.com/apache/datafusion/pull/18740#discussion_r2532279937


##########
datafusion/expr/src/logical_plan/plan.rs:
##########
@@ -1472,13 +1472,24 @@ impl LogicalPlan {
                     Ok(transformed_expr.update_data(|expr| original_name.restore(expr)))
                 }
             })?
-            // always recompute the schema to ensure the changed in the schema's field should be
-            // poplulated to the plan's parent
-            .map_data(|plan| plan.recompute_schema())
+            .map_data(|plan| plan.update_schema_data_type())
         })
         .map(|res| res.data)
     }
 
+    /// Recompute schema fields' data type after replacing params, ensuring fields data type can be
+    /// updated according to the new parameters.

Review Comment:
   Thanks @martin-g. I will update it later today
   



-- 
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-unsubscribe@datafusion.apache.org

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


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


Re: [PR] fix: update schema's data type for `LogicalPlan::Values` after placeholder substitution [datafusion]

Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on PR #18740:
URL: https://github.com/apache/datafusion/pull/18740#issuecomment-3544568135

   Thanks @dqkqd  & @martin-g 


-- 
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-unsubscribe@datafusion.apache.org

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


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


Re: [PR] fix: update schema's data type for `LogicalPlan::Values` after placeholder substitution [datafusion]

Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g commented on code in PR #18740:
URL: https://github.com/apache/datafusion/pull/18740#discussion_r2531939146


##########
datafusion/expr/src/logical_plan/plan.rs:
##########
@@ -1472,13 +1472,24 @@ impl LogicalPlan {
                     Ok(transformed_expr.update_data(|expr| original_name.restore(expr)))
                 }
             })?
-            // always recompute the schema to ensure the changed in the schema's field should be
-            // poplulated to the plan's parent
-            .map_data(|plan| plan.recompute_schema())
+            .map_data(|plan| plan.update_schema_data_type())
         })
         .map(|res| res.data)
     }
 
+    /// Recompute schema fields' data type after replacing params, ensuring fields data type can be
+    /// updated according to the new parameters.

Review Comment:
   nit: I think the docstring could be more explicit why this method is needed. E.g. something like:
   ```
   /// Recomputes schema fields' data type after replacing params, ensuring fields' data type can be
   /// updated according to the new parameters. Unlike `recompute_schema()`, this method rebuilds
   /// VALUES plans entirely to properly infer types from literal values after placeholder substitution.
   ```
   This way the "FIXME" below could be removed.



##########
datafusion/expr/src/logical_plan/plan.rs:
##########
@@ -1472,13 +1472,24 @@ impl LogicalPlan {
                     Ok(transformed_expr.update_data(|expr| original_name.restore(expr)))
                 }
             })?
-            // always recompute the schema to ensure the changed in the schema's field should be
-            // poplulated to the plan's parent
-            .map_data(|plan| plan.recompute_schema())
+            .map_data(|plan| plan.update_schema_data_type())
         })
         .map(|res| res.data)
     }
 
+    /// Recompute schema fields' data type after replacing params, ensuring fields data type can be
+    /// updated according to the new parameters.

Review Comment:
   Or the idea of the "FIXME" is to move this logic to `recompute_schema()` one day ?! If YES then better file an issue for that



-- 
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-unsubscribe@datafusion.apache.org

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


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


Re: [PR] fix: update schema's data type for `LogicalPlan::Values` after placeholder substitution [datafusion]

Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey merged PR #18740:
URL: https://github.com/apache/datafusion/pull/18740


-- 
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-unsubscribe@datafusion.apache.org

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


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


Re: [PR] fix: update schema's data type for `LogicalPlan::Values` after placeholder substitution [datafusion]

Posted by "dqkqd (via GitHub)" <gi...@apache.org>.
dqkqd commented on code in PR #18740:
URL: https://github.com/apache/datafusion/pull/18740#discussion_r2535351745


##########
datafusion/expr/src/logical_plan/plan.rs:
##########
@@ -1472,13 +1472,24 @@ impl LogicalPlan {
                     Ok(transformed_expr.update_data(|expr| original_name.restore(expr)))
                 }
             })?
-            // always recompute the schema to ensure the changed in the schema's field should be
-            // poplulated to the plan's parent
-            .map_data(|plan| plan.recompute_schema())
+            .map_data(|plan| plan.update_schema_data_type())
         })
         .map(|res| res.data)
     }
 
+    /// Recompute schema fields' data type after replacing params, ensuring fields data type can be
+    /// updated according to the new parameters.

Review Comment:
   I updated the docstring, but I want to keep the comment to make it clear why `recompute_schema` shouldn't be called for `LogicalPlan::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-unsubscribe@datafusion.apache.org

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


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


Re: [PR] fix: update schema's data type for `LogicalPlan::Values` after placeholder substitution [datafusion]

Posted by "dqkqd (via GitHub)" <gi...@apache.org>.
dqkqd commented on PR #18740:
URL: https://github.com/apache/datafusion/pull/18740#issuecomment-3537513601

   @Jefffrey would you please review this.


-- 
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-unsubscribe@datafusion.apache.org

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


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