Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concatenating dictionaries that have nulls in them yields strange results #6302

Closed
westonpace opened this issue Aug 24, 2024 · 0 comments · Fixed by #7144
Closed

Concatenating dictionaries that have nulls in them yields strange results #6302

westonpace opened this issue Aug 24, 2024 · 0 comments · Fixed by #7144
Labels

Comments

@westonpace
Copy link
Member

Describe the bug
If I concatenate two dictionaries that have nulls in the dictionary (not the indices) then I sometimes get garbage back.

To Reproduce

    #[test]
    pub fn test_dict_concat_two() {
        let keys1 = UInt16Array::from_iter_values(vec![2, 2]);
        let keys2 = UInt16Array::from_iter_values(vec![1]);
        let dict1 = StringArray::from(vec![Some("a"), Some("b"), None]);
        let dict2 = StringArray::from(vec![Some("c"), Some("d"), None]);

        let arr1 = DictionaryArray::new(keys1, Arc::new(dict1));
        let arr2 = DictionaryArray::new(keys2, Arc::new(dict2));

        println!("{:?}", arr1);
        println!("{:?}", arr2);
        let combined = arrow_select::concat::concat(&[&arr1, &arr2]).unwrap();
        println!("{:?}", combined);

        let expected = StringArray::from(vec![None, None, Some("d")]);
        let actual = arrow_cast::cast(combined.as_ref(), &DataType::LargeUtf8).unwrap();

        assert_eq!(actual.as_ref(), &expected);
    }

Expected behavior
The test in the reproduction passes.

Additional context
The output from the test is:

DictionaryArray {keys: PrimitiveArray<UInt16>
[
  2,
  2,
] values: StringArray
[
  "a",
  "b",
  null,
]}

DictionaryArray {keys: PrimitiveArray<UInt16>
[
  1,
] values: StringArray
[
  "c",
  "d",
  null,
]}

DictionaryArray {keys: PrimitiveArray<UInt16>
[
  0,
  0,
  0,
] values: StringArray
[
  "d",
]}

thread 'data::tests::test_dict_concat_two' panicked at rust/lance-encoding/src/data.rs:1179:9:
assertion `left == right` failed
  left: LargeStringArray
[
  "d",
  "d",
  "d",
]
 right: StringArray
[
  null,
  null,
  "d",
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant