Jefffrey commented on code in PR #19335:
URL: https://github.com/apache/datafusion/pull/19335#discussion_r2621155616


##########
datafusion/functions-aggregate/src/first_last.rs:
##########
@@ -1075,6 +1087,18 @@ impl AggregateUDFImpl for LastValue {
         Ok(arg_types[0].clone())

Review Comment:
   Ditto



##########
datafusion/sqllogictest/test_files/metadata.slt:
##########
@@ -235,7 +235,56 @@ order by 1 asc nulls last;
 3 1
 NULL 1
 
+# Regression test: first_value should preserve metadata

Review Comment:
   I noticed for the existing regression tests in this file, they don't 
actually check metadata 🤔 
   
   
https://github.com/apache/datafusion/blob/58377bf2e30315438f6cff047874c3fac770f31e/datafusion/sqllogictest/test_files/metadata.slt#L63-L67
   
   With this new UDF we can look into updating those tests to be more similar 
to the ones introduced here



##########
datafusion/sqllogictest/src/test_context.rs:
##########
@@ -398,6 +398,58 @@ pub async fn register_metadata_tables(ctx: 
&SessionContext) {
     .unwrap();
 
     ctx.register_batch("table_with_metadata", batch).unwrap();
+
+    // Register the get_metadata UDF for testing metadata preservation
+    ctx.register_udf(ScalarUDF::from(GetMetadataUdf::new()));
+}
+
+/// UDF to extract metadata from a field for testing purposes
+/// Usage: get_metadata(expr, 'key') -> returns the metadata value or NULL
+#[derive(Debug, PartialEq, Eq, Hash)]
+struct GetMetadataUdf {

Review Comment:
   I wonder if this is useful enough to introduce as a function to datafusion 
itself, instead of being only in SLT? 🤔 



##########
datafusion/functions-aggregate/src/first_last.rs:
##########
@@ -137,6 +137,18 @@ impl AggregateUDFImpl for FirstValue {
         Ok(arg_types[0].clone())

Review Comment:
   Ideally we should have `return_type` return an internal error instead of 
leaving it implemented if we use `return_field` now



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