gene-bordegaray commented on code in PR #20901:
URL: https://github.com/apache/datafusion/pull/20901#discussion_r2989874655
##########
datafusion/physical-expr-common/src/physical_expr.rs:
##########
@@ -618,6 +640,46 @@ pub fn snapshot_physical_expr_opt(
})
}
+/// Bind runtime-specific data into the given `PhysicalExpr`.
+///
+/// See the documentation of [`PhysicalExpr::bind_runtime`] for more details.
+///
+/// Runtime binding is applied once over the current expression tree.
+///
+/// # Returns
+///
+/// Returns a runtime-bound expression if any node required binding,
+/// otherwise returns the original expression.
+pub fn bind_runtime_physical_expr(
+ expr: Arc<dyn PhysicalExpr>,
+ context: &(dyn Any + Send + Sync),
+) -> Result<Arc<dyn PhysicalExpr>> {
+ bind_runtime_physical_expr_opt(expr, context).data()
+}
+
+/// Bind runtime-specific data into the given `PhysicalExpr`.
+///
+/// See the documentation of [`PhysicalExpr::bind_runtime`] for more details.
+///
+/// Runtime binding is applied once over the current expression tree.
+///
+/// # Returns
+///
+/// Returns a [`Transformed`] indicating whether any runtime binding happened,
+/// along with the resulting expression.
+pub fn bind_runtime_physical_expr_opt(
+ expr: Arc<dyn PhysicalExpr>,
+ context: &(dyn Any + Send + Sync),
+) -> Result<Transformed<Arc<dyn PhysicalExpr>>> {
+ expr.transform_up(|e| {
+ if let Some(bound) = e.bind_runtime(context)? {
+ Ok(Transformed::yes(bound))
Review Comment:
the main difference is snapshot is responsible for capturing the dynamic
state into a replacement expression while bind_runtime is it inject execution
specific characteristics into n expression.
I was previously using snapshot to do this work but was mentioned that it
felt like we were shoe-horning partitioning into dynamic expressions thus a
cleaner API with separate concerns would be a better apporach
--
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]