alamb commented on code in PR #19335: URL: https://github.com/apache/datafusion/pull/19335#discussion_r2623998142
########## 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 +query IT +select first_value(id order by id asc nulls last), get_metadata(first_value(id order by id asc nulls last), 'metadata_key') +from table_with_metadata; +---- +1 the id field + +# Regression test: last_value should preserve metadata +query IT +select last_value(id order by id asc nulls first), get_metadata(last_value(id order by id asc nulls first), 'metadata_key') +from table_with_metadata; +---- +3 the id field +# Regression test: DISTINCT ON should preserve metadata (uses first_value internally) +query ITTT +select distinct on (id) id, get_metadata(id, 'metadata_key'), name, get_metadata(name, 'metadata_key') +from table_with_metadata order by id asc nulls last; +---- +1 the id field NULL the name field +3 the id field baz the name field +NULL the id field bar the name field + +# Regression test: DISTINCT should preserve metadata +query ITTT +with res AS ( + select distinct id, name from table_with_metadata +) +select id, get_metadata(id, 'metadata_key'), name, get_metadata(name, 'metadata_key') +from res +order by id asc nulls last; +---- +1 the id field NULL the name field +3 the id field baz the name field +NULL the id field bar the name field + +# Regression test: grouped columns should preserve metadata +query ITTT +with res AS ( + select name, count(*), id + from table_with_metadata + group by id, name +) +select id, get_metadata(id, 'metadata_key'), name, get_metadata(name, 'metadata_key') +from res +order by id asc nulls last, name asc nulls last +---- +1 the id field NULL the name field +3 the id field baz the name field +NULL the id field bar the name field Review Comment: > What would happen if a non-existing column is passed as a first argument of the get_metadata() udf I think it should probably error like any other query that tries to access a undefined column -- 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]
