mnpw opened a new issue, #5843:
URL: https://github.com/apache/arrow-rs/issues/5843
**Describe the bug**
`Schema::try_merge` should be able to merge List(<any> data type) and
List(Null data type)
**To Reproduce**
```rust
use serde_json::json;
let o_1 = vec![
json!({"a": [1,2,3]}),
json!({"a": [4,5,6]}),
];
let o_2 = vec![
json!({"a": []}),
json!({"a": []}),
];
let o_3 = vec![
json!({"a": []}),
json!({"a": [7,8,9]}),
];
let schema_1 =
arrow_json::reader::infer_json_schema_from_iterator(o_1.iter().map(Ok)).unwrap();
println!("{:?}", schema_1);
// Schema { fields: [Field { name: "a", data_type: List(Field { name:
"item", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false,
metadata: {} }), nullable: true, dict_id: 0, dict_is_ordered: false, metadata:
{} }], metadata: {} }
let schema_2 =
arrow_json::reader::infer_json_schema_from_iterator(o_2.iter().map(Ok)).unwrap();
println!("{:?}", schema_2);
// Schema { fields: [Field { name: "a", data_type: List(Field { name:
"item", data_type: Null, nullable: true, dict_id: 0, dict_is_ordered: false,
metadata: {} }), nullable: true, dict_id: 0, dict_is_ordered: false, metadata:
{} }], metadata: {} }
let schema_3 =
arrow_json::reader::infer_json_schema_from_iterator(o_3.iter().map(Ok)).unwrap();
println!("{:?}", schema_3);
// Schema { fields: [Field { name: "a", data_type: List(Field { name:
"item", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false,
metadata: {} }), nullable: true, dict_id: 0, dict_is_ordered: false, metadata:
{} }], metadata: {} }
let merged = Schema::try_merge([schema_1, schema_2, schema_3]);
println!("{:?}", merged)
// Err(SchemaError("Fail to merge schema field 'a' because the from
data_type = List(Field { name: \"item\", data_type: Null, nullable: true,
dict_id: 0, dict_is_ordered: false, metadata: {} }) does not equal List(Field {
name: \"item\", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered:
false, metadata: {} })"))
```
**Expected behavior**
Merge of List(<any> data type) and List(Null) should be possible
```rust
let merged = Schema::try_merge([schema_1, schema_2, schema_3]);
println!("{:?}", merged)
// Ok(Schema { fields: [Field { name: "a", data_type: List(Field { name:
"item", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false,
metadata: {} }), nullable: true, dict_id: 0, dict_is_ordered: false, metadata:
{} }], metadata: {} })
```
**Additional context**
N/A
--
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]