alamb commented on a change in pull request #1204:
URL: https://github.com/apache/arrow-datafusion/pull/1204#discussion_r741425291
##########
File path: datafusion/tests/sql.rs
##########
@@ -5385,3 +5385,47 @@ async fn query_nested_get_indexed_field() -> Result<()> {
assert_eq!(expected, actual);
Ok(())
}
+
+#[tokio::test]
+async fn query_nested_get_indexed_field_on_struct() -> Result<()> {
+ let mut ctx = ExecutionContext::new();
+ let nested_dt = DataType::List(Box::new(Field::new("item",
DataType::Int64, true)));
+ // Nested schema of { "some_struct": { "bar": [i64] } }
+ let struct_fields = vec![Field::new("bar", nested_dt.clone(), true)];
+ let schema = Arc::new(Schema::new(vec![Field::new(
+ "some_struct",
+ DataType::Struct(struct_fields.clone()),
+ false,
+ )]));
+
+ let builder = PrimitiveBuilder::<Int64Type>::new(3);
+ let nested_lb = ListBuilder::new(builder);
+ let mut sb = StructBuilder::new(struct_fields, vec![Box::new(nested_lb)]);
+ for int_vec in vec![vec![0, 1, 2, 3], vec![4, 5, 6, 7], vec![8, 9, 10,
11]] {
+ let lb = sb.field_builder::<ListBuilder<Int64Builder>>(0).unwrap();
+ for int in int_vec {
+ lb.values().append_value(int).unwrap();
+ }
+ lb.append(true).unwrap();
+ }
+ let data = RecordBatch::try_new(schema.clone(),
vec![Arc::new(sb.finish())])?;
+ let table = MemTable::try_new(schema, vec![vec![data]])?;
+ let table_a = Arc::new(table);
+
+ ctx.register_table("structs", table_a)?;
+
+ // Original column is micros, convert to millis and check timestamp
+ let sql = "SELECT some_struct[\"bar\"] as l0 FROM structs LIMIT 3";
Review comment:
this is so cool!
--
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]