gabotechs commented on code in PR #15869: URL: https://github.com/apache/datafusion/pull/15869#discussion_r2066875639
########## datafusion/substrait/tests/cases/substrait_validations.rs: ########## @@ -61,16 +61,41 @@ mod tests { let proto_plan = read_json("tests/testdata/test_plans/simple_select.substrait.json"); // this is the exact schema of the Substrait plan - let df_schema = - vec![("a", DataType::Int32, false), ("b", DataType::Int32, true)]; + let df_schema = vec![ + ("a", DataType::Int32, false), + ("b", DataType::Int32, true), + ( + "c", + DataType::Map( + Arc::new(Field::new_struct( + "entries", + Fields::from(vec![ + Field::new("key", DataType::Utf8, false), + Field::new_struct( + "value", + Fields::from(vec![Field::new( + "d", + DataType::Utf8, + true, + )]), + true, + ), + ]), + true, + )), + false, + ), + true, + ), + ]; let ctx = generate_context_with_table("DATA", df_schema)?; let plan = from_substrait_plan(&ctx.state(), &proto_plan).await?; assert_snapshot!( plan, @r#" - Projection: DATA.a, DATA.b + Projection: DATA.a, DATA.b, DATA.c TableScan: DATA Review Comment: Thanks for the tests! I think it might be worth to expand a bit on them, as they are only testing the new functionality partially. For example, I could replace the code committed in [datafusion/substrait/src/logical_plan/consumer.rs](https://github.com/apache/datafusion/pull/15869/files#diff-474e53672159d74dae38992a914a74eba81b8350ebe161f11d755f06414ed7b4R1012-R1044) with just the following: ```rust ... DataType::Map(inner, _) => match inner.data_type() { DataType::Struct(key_and_value) if key_and_value.len() == 2 => { *name_idx += 1; Ok(field.clone()) } _ => substrait_err!("Map fields must contain a Struct with exactly 2 fields"), }, ... ``` And make the test green, even though the code is wrong. Maybe @Blizzara or @westonpace can give a bit more insights about how to better test this. -- 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-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org