You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2024/11/13 15:35:28 UTC

Re: [PR] Convert nth_value builtIn function to User Defined Window Function [datafusion]

alamb commented on code in PR #13201:
URL: https://github.com/apache/datafusion/pull/13201#discussion_r1840604599


##########
datafusion/physical-plan/Cargo.toml:
##########
@@ -70,6 +70,7 @@ tokio = { workspace = true }
 [dev-dependencies]
 criterion = { version = "0.5", features = ["async_futures"] }
 datafusion-functions-aggregate = { workspace = true }
+datafusion-functions-window = { workspace = true }

Review Comment:
   some day I hope we can remove these dependencies (so we can make testing `physical-plan` faster, but not a part of this PR



##########
datafusion/physical-plan/src/windows/mod.rs:
##########
@@ -241,14 +171,29 @@ fn create_udwf_window_expr(
         .map(|arg| arg.data_type(input_schema))
         .collect::<Result<_>>()?;
 
-    Ok(Arc::new(WindowUDFExpr {
+    let udwf_expr = Arc::new(WindowUDFExpr {
         fun: Arc::clone(fun),
         args: args.to_vec(),
         input_types,
         name,
         is_reversed: false,
         ignore_nulls,
-    }))
+    });
+
+    // Early validation of input expressions
+    // We create a partition evaluator because in the user-defined window
+    // implementation this is where code for parsing input expressions
+    // exist. The benefits are:
+    // - If any of the input expressions are invalid we catch them early

Review Comment:
   💯  for these comments that explain the rationale



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