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

feat: Support Map type in Substrait conversions #11129

Merged
merged 2 commits into from
Jun 27, 2024

Conversation

Blizzara
Copy link
Contributor

Which issue does this PR close?

Closes #.

Rationale for this change

We don't currently support Map types in the Substrait consumer/producer at all. As Map type isn't yet implemented for ScalarValue (#11128), we cannot support Map literals, but we can still enable Map types.

I'm not sure how useful the Map type is w/o the literal support, but I already wrote this code so might as well add it 😅

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

This only supports Map _type_, not Map literals,
since Map isn't yet implemented in ScalarValue
(apache#11128)
@Blizzara Blizzara marked this pull request as ready for review June 27, 2024 07:55
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks (again) @Blizzara

It seems like @goldmedal is working on Map ScalarValue support in #11128 --
#11128 (comment)

So while you are right that this likely isn't super useful on its own, I think it is a step forward towards more full featured map spport

@@ -2316,6 +2337,19 @@ mod test {
Field::new_list_field(DataType::Int32, true).into(),
))?;

round_trip_type(DataType::Map(
Field::new_struct(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can also add a test using Field::new_map: https://docs.rs/arrow/latest/arrow/datatypes/struct.Field.html#method.new_map

we could do it in a follow on PR too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Field::new_map is a bit annoying as it creates a map field directly, rather than the inner field of a map.. would be nice to have something like new_list_field but for map, but Arrow doesn't have it.

Anyways I could replace this block or add another one with

        round_trip_type(
            Field::new_map(
                "map",
                "entries",
                Field::new("key", DataType::Utf8, false).into(),
                Field::new("value", DataType::Int32, true).into(),
                false,
                false,
            )
            .data_type()
            .to_owned(),
        )?;

frankly I don't know if it adds much value, but I'm fine either way - do you have a preference?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't think it is valuable let's not use it

@alamb alamb merged commit f58df32 into apache:main Jun 27, 2024
23 checks passed
@alamb
Copy link
Contributor

alamb commented Jun 27, 2024

Thanks again @Blizzara

@Blizzara Blizzara deleted the avo/substrait-map-type branch June 28, 2024 07:12
findepi pushed a commit to findepi/datafusion that referenced this pull request Jul 16, 2024
* feat: Support Map type in Substrait conversions

This only supports Map _type_, not Map literals,
since Map isn't yet implemented in ScalarValue
(apache#11128)

* fix clippy
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants