You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "Blizzara (via GitHub)" <gi...@apache.org> on 2024/05/22 15:33:23 UTC
[PR] Add support for Substrait Struct literals and type [datafusion]
Blizzara opened a new pull request, #10622:
URL: https://github.com/apache/datafusion/pull/10622
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
Closes #.
Extracted part of https://github.com/apache/datafusion/pull/10531 - not necessary part for it but somewhat related
Has some overlap with https://github.com/apache/datafusion/pull/10615, as both deal with container types - once one is merged, I'll update the other to resolve conflicts.
## Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
## What changes are included in this PR?
Adds support for converting from un-named DataFusion Struct ScalarValues into Substrait Struct Literals and back, as well as converting from Substrait Struct type into DF Struct type (other direction already existed).
Substrait doesn't contain names in its Struct fields. For e.g. initial schema, the names are provided separately. This PR only properly supports un-named structs - which in DataFusion get default field names of form "c0", "c1", ... Other structs can also be converted but they'll be renamed automatically into the default names.
The VirtualTable PR will then provide better support for named structs.
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
## Are these changes tested?
Adds round-trip unit tests
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
## Are there any user-facing changes?
More things are now supported, but I don't think Substrait support status is covered by documentation currently?
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
<!--
If there are any breaking changes to public APIs, please add the `api change` label.
-->
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Add support for Substrait Struct literals and type [datafusion]
Posted by "Blizzara (via GitHub)" <gi...@apache.org>.
Blizzara commented on PR #10622:
URL: https://github.com/apache/datafusion/pull/10622#issuecomment-2127396639
Thanks @jonahgao , that seems to work indeed. This is ready to merge by me :)
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Add support for Substrait Struct literals and type [datafusion]
Posted by "Blizzara (via GitHub)" <gi...@apache.org>.
Blizzara commented on PR #10622:
URL: https://github.com/apache/datafusion/pull/10622#issuecomment-2125102187
@jonahgao second extracted part :) this one has a bit of overlap with the list PR but I'm happy to fix conflicts once one of these is merged (order shouldn't matter)
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Add support for Substrait Struct literals and type [datafusion]
Posted by "Blizzara (via GitHub)" <gi...@apache.org>.
Blizzara commented on PR #10622:
URL: https://github.com/apache/datafusion/pull/10622#issuecomment-2126935198
> Thank you @Blizzara -- this looks good to me. I have one more test I suggested test, but I think we could do it as a follow on PR too.
>
> Please let me know if you would prefer to modify this PR or make a follow on.
>
> Thanks again for the contribution!
Thank you for the review! I added the null case here :)
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Add support for Substrait Struct literals and type [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #10622:
URL: https://github.com/apache/datafusion/pull/10622#issuecomment-2127703710
Thanks again @Blizzara and @jonahgao
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Add support for Substrait Struct literals and type [datafusion]
Posted by "Blizzara (via GitHub)" <gi...@apache.org>.
Blizzara commented on PR #10622:
URL: https://github.com/apache/datafusion/pull/10622#issuecomment-2127110699
Not sure what's up with the checks here - cargo check runs fine for me locally and I don't see how the errors would be related to my changes?
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Add support for Substrait Struct literals and type [datafusion]
Posted by "jonahgao (via GitHub)" <gi...@apache.org>.
jonahgao commented on PR #10622:
URL: https://github.com/apache/datafusion/pull/10622#issuecomment-2127227068
> Not sure what's up with the checks here - cargo check runs fine for me locally and I don't see how the errors would be related to my changes?
CI is attempting to merge the current PR into a problematic commit https://github.com/apache/datafusion/commit/d2f6faf56784867beafaa2ee88df37ffc3d20720
```sh
commit 90ed2f64c675f0a52114b8fcdfccef45fa258181 (grafted, HEAD, pull/10622/merge)
Author: Arttu <Bl...@users.noreply.github.com>
Date: Thu May 23 13:59:56 2024 +0200
Merge 84ccaa3361f64dc4a247487b43a57367734b9548 into d2f6faf56784867beafaa2ee88df37ffc3d20720
```
I am not sure if pushing a new commit to the current PR will fix it.
```sh
git commit --allow-empty -m "retry ci"
```
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Add support for Substrait Struct literals and type [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #10622:
URL: https://github.com/apache/datafusion/pull/10622#discussion_r1611490277
##########
datafusion/substrait/src/logical_plan/producer.rs:
##########
@@ -2125,6 +2141,15 @@ mod test {
),
)))?;
+ let struct_field_1 = Field::new("c0", DataType::Boolean, true);
+ let struct_field_2 = Field::new("c1", DataType::Int32, true);
+ round_trip_literal(
Review Comment:
I suggest one more test with null values too -- specifically something like
```rust
ScalarStructBuilder::new()
.with_scalar(struct_field_1, ScalarValue::Boolean(None))
.with_scalar(struct_field_2, ScalarValue::Int32(None))
.build()?,
```
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Add support for Substrait Struct literals and type [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #10622:
URL: https://github.com/apache/datafusion/pull/10622
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Add support for Substrait Struct literals and type [datafusion]
Posted by "Blizzara (via GitHub)" <gi...@apache.org>.
Blizzara commented on code in PR #10622:
URL: https://github.com/apache/datafusion/pull/10622#discussion_r1611570481
##########
datafusion/substrait/src/logical_plan/producer.rs:
##########
@@ -2125,6 +2141,15 @@ mod test {
),
)))?;
+ let struct_field_1 = Field::new("c0", DataType::Boolean, true);
+ let struct_field_2 = Field::new("c1", DataType::Int32, true);
+ round_trip_literal(
Review Comment:
Added (though incorporated into the existing test) in [84ccaa3](https://github.com/apache/datafusion/pull/10622/commits/84ccaa3361f64dc4a247487b43a57367734b9548)!
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Add support for Substrait Struct literals and type [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #10622:
URL: https://github.com/apache/datafusion/pull/10622#issuecomment-2127703510
> Not sure what's up with the checks here - cargo check runs fine for me locally and I don't see how the errors would be related to my changes?
I think this was a logical conflict that @phillipleblanc fixed earlier today in https://github.com/apache/datafusion/pull/10637 🙏
--
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-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org