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

Preserve Element Name in ScalarValue::List #2450

Closed
tustvold opened this issue May 5, 2022 · 8 comments · Fixed by #2893
Closed

Preserve Element Name in ScalarValue::List #2450

tustvold opened this issue May 5, 2022 · 8 comments · Fixed by #2893
Labels
enhancement New feature or request

Comments

@tustvold
Copy link
Contributor

tustvold commented May 5, 2022

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

ScalarValue::List lacks the ability to preserve the name of its element which prevents round-tripping it correctly

Describe the solution you'd like

ScalarValue::List should store a Box<Field> instead, much like ScalarValue::Struct

@tustvold tustvold added the enhancement New feature or request label May 5, 2022
@tustvold tustvold self-assigned this May 5, 2022
@comphead
Copy link
Contributor

Hi @tustvold is it to be consistent with arrow Datatype::List()

    /// A list of some logical data type with variable length.
    List(Box<Field>),

@tustvold
Copy link
Contributor Author

Yup precisely, when I took a stab at this previously I had to hack around apache/arrow-rs#1649 which was a bit meh.

Let me know if you want to pick one or both of these issues up, as that would be awesome.

@tustvold tustvold removed their assignment May 18, 2022
@comphead
Copy link
Contributor

I can try with this one.

@comphead
Copy link
Contributor

@tustvold Protobuf serde is expected to pass the entire field value, not just datatype like it was before?

@comphead
Copy link
Contributor

@tustvold for the test, which was before. This represents roundtrip for the list

            ScalarValue::List(
                Some(vec![
                    ScalarValue::Float32(Some(-213.1)),
                    ScalarValue::Float32(None),
                    ScalarValue::Float32(Some(5.5)),
                    ScalarValue::Float32(Some(2.0)),
                    ScalarValue::Float32(Some(1.0)),
                ]),
                Box::new(DataType::List(new_box_field(
                    "level1",
                    DataType::Float32,
                    true,
                ))),

Do you expect after change it has to be

           ScalarValue::List(
                Some(vec![
                    ScalarValue::Float32(Some(-213.1)),
                    ScalarValue::Float32(None),
                    ScalarValue::Float32(Some(5.5)),
                    ScalarValue::Float32(Some(2.0)),
                    ScalarValue::Float32(Some(1.0)),
                ]),
                new_box_field("level1", DataType::Float32, true),
            ),

or

           ScalarValue::List(
                Some(vec![
                    ScalarValue::Float32(Some(-213.1)),
                    ScalarValue::Float32(None),
                    ScalarValue::Float32(Some(5.5)),
                    ScalarValue::Float32(Some(2.0)),
                    ScalarValue::Float32(Some(1.0)),
                ]),
                new_box_field("item", DataType::List(new_box_field("level1", DataType::Float32, true)), true),
            ),

@tustvold
Copy link
Contributor Author

The latter, you will need to both specify the name of the lists element, and its nullability

@comphead
Copy link
Contributor

The latter, you will need to both specify the name of the lists element, and its nullability

Thanks @tustvold for the quick reply. I was confused because we have the test like

            ScalarValue::List(None, new_box_field("item", DataType::Boolean, true)),

which also looks like list of primitives but with other datatype provided

@tustvold
Copy link
Contributor Author

This will be a breaking change, and will require updating said tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants