simicd commented on code in PR #8939: URL: https://github.com/apache/arrow-datafusion/pull/8939#discussion_r1461149704
########## datafusion/sqllogictest/test_files/select.slt: ########## @@ -496,15 +496,265 @@ ProjectionExec: expr=[c1@0 >= 2 AND c1@0 <= 3 as select_between_data.c1 BETWEEN --MemoryExec: partitions=1, partition_sizes=[1] -# TODO: query_get_indexed_field +###### +# Query indexed field +###### -# TODO: query_nested_get_indexed_field +statement ok +CREATE TABLE indexed_fields +AS VALUES +(make_array(1, 2, 3), 'a'), +(make_array(4, 5, 6), 'b'), +(make_array(7, 8, 9), 'c'); + +query ?T +SELECT * FROM indexed_fields; +---- +[1, 2, 3] a +[4, 5, 6] b +[7, 8, 9] c + +query I +SELECT column1[1] as i0 FROM indexed_fields LIMIT 3; +---- +1 +4 +7 + + +###### +# Query nested indexed field +###### + +statement ok +CREATE TABLE nested_indexed_fields +AS VALUES +(make_array(make_array(0, 1), make_array(2, 3), make_array(3, 4)), 'a'), +(make_array(make_array(5, 6), make_array(7, 8), make_array(9, 10)), 'b'), +(make_array(make_array(11, 12), make_array(13, 14), make_array(15, 16)), 'c'); + +query ?T +SELECT * FROM nested_indexed_fields; +---- +[[0, 1], [2, 3], [3, 4]] a +[[5, 6], [7, 8], [9, 10]] b +[[11, 12], [13, 14], [15, 16]] c + +query ? +SELECT column1[1] as i0 FROM nested_indexed_fields LIMIT 3; +---- +[0, 1] +[5, 6] +[11, 12] + +query I +SELECT column1[1][1] as i0 FROM nested_indexed_fields LIMIT 3; +---- +0 +5 +11 + +###### +# Query nested indexed field on struct +###### + +statement ok +CREATE TABLE nested_structs_data +AS VALUES +(make_array(0, 1, 2, 3), 'a'), +(make_array(4, 5, 6, 7), 'b'), +(make_array(8, 9, 10, 11), 'c'); + +statement ok +CREATE TABLE nested_structs AS SELECT struct(column1) AS some_struct FROM nested_structs_data; + +query ? +SELECT some_struct['c0'] as l0 FROM nested_structs LIMIT 3; Review Comment: Is there a way to create a struct with named fields other than c0, c1, ... in SQL? The original test called it `bar`, I couldn't find anywhere in the documentation or the code a way to name `c0` differently. Original test: https://github.com/apache/arrow-datafusion/blob/0116e2a9b4a3ed4491802e19195769b96b7a971a/datafusion/core/tests/sql/select.rs#L149-L150 -- 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]
