You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "Weijun-H (via GitHub)" <gi...@apache.org> on 2023/11/28 13:44:55 UTC
[PR] Add support for parsing FixedSizeList type [arrow-datafusion]
Weijun-H opened a new pull request, #8344:
URL: https://github.com/apache/arrow-datafusion/pull/8344
## 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 #8343
## 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?
<!--
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?
<!--
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?
<!--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add support for FixedSizeList type in `arrow_cast`, hashing [arrow-datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #8344:
URL: https://github.com/apache/arrow-datafusion/pull/8344#discussion_r1457948336
##########
datafusion/sqllogictest/test_files/arrow_typeof.slt:
##########
@@ -384,4 +384,35 @@ LargeList(Field { name: "item", data_type: Int64, nullable: true, dict_id: 0, di
query T
select arrow_typeof(arrow_cast(make_array([1, 2, 3]), 'LargeList(LargeList(Int64))'));
----
-LargeList(Field { name: "item", data_type: LargeList(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: {} })
\ No newline at end of file
+LargeList(Field { name: "item", data_type: LargeList(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: {} })
+
+## FixedSizeList
+
+query ?
+select arrow_cast(null, 'FixedSizeList(1, Int64)');
+----
+NULL
+
+#TODO: arrow-rs doesn't support it yet
Review Comment:
Shouldn't we be casting `[1]` (not `1`)?
##########
datafusion/common/src/hash_utils.rs:
##########
@@ -267,6 +268,38 @@ where
Ok(())
}
+fn hash_fixed_list_array(
Review Comment:
I didn't see any test coverage for this new code -- e.g. either unit tests for hashing or a higher level test like `GROUP BY <FixedListArray>`
Can you either ensure this code is tested somehow, or else perhaps move the hash support to a different PR so we can merge the `arrow_cast` support ?
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add support for parsing FixedSizeList type [arrow-datafusion]
Posted by "Weijun-H (via GitHub)" <gi...@apache.org>.
Weijun-H commented on PR #8344:
URL: https://github.com/apache/arrow-datafusion/pull/8344#issuecomment-1837155317
> I wonder why this PR is waiting for the next arrow release (arrow `50.0.0`?)
Because it just update the support cast from List/LargeList to FixedList @alamb
https://github.com/apache/arrow-rs/blob/df69ef57d055453c399fa925ad315d19211d7ab2/arrow-cast/src/cast.rs#L808-L815
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add support for FixedSizeList type in `arrow_cast`, hashing [arrow-datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #8344:
URL: https://github.com/apache/arrow-datafusion/pull/8344
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add support for parsing FixedSizeList type [arrow-datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #8344:
URL: https://github.com/apache/arrow-datafusion/pull/8344#issuecomment-1837464802
I see -- so while this code doesn't directly depend on the arrow release, it won't be very helpful until that support released. Makes sense to me. Thank you @Weijun-H
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add support for parsing FixedSizeList type in `arrow_cast` [arrow-datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #8344:
URL: https://github.com/apache/arrow-datafusion/pull/8344#issuecomment-1892116225
❤️
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add support for parsing FixedSizeList type [arrow-datafusion]
Posted by "Weijun-H (via GitHub)" <gi...@apache.org>.
Weijun-H commented on PR #8344:
URL: https://github.com/apache/arrow-datafusion/pull/8344#issuecomment-1829877737
stall until the next arrow-rs (50.0)
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add support for FixedSizeList type in `arrow_cast`, hashing [arrow-datafusion]
Posted by "Weijun-H (via GitHub)" <gi...@apache.org>.
Weijun-H commented on code in PR #8344:
URL: https://github.com/apache/arrow-datafusion/pull/8344#discussion_r1458223635
##########
datafusion/common/src/hash_utils.rs:
##########
@@ -546,6 +583,30 @@ mod tests {
assert_eq!(hashes[2], hashes[3]);
}
+ #[test]
+ // Tests actual values of hashes, which are different if forcing collisions
+ #[cfg(not(feature = "force_hash_collisions"))]
+ fn create_hashes_for_fixed_size_list_arrays() {
+ let data = vec![
+ Some(vec![Some(0), Some(1), Some(2)]),
+ None,
+ Some(vec![Some(3), None, Some(5)]),
+ Some(vec![Some(3), None, Some(5)]),
+ None,
+ Some(vec![Some(0), Some(1), Some(2)]),
+ ];
+ let list_array =
+ Arc::new(FixedSizeListArray::from_iter_primitive::<Int32Type, _, _>(
+ data, 3,
+ )) as ArrayRef;
+ let random_state = RandomState::with_seeds(0, 0, 0, 0);
+ let mut hashes = vec![0; list_array.len()];
+ create_hashes(&[list_array], &random_state, &mut hashes).unwrap();
+ assert_eq!(hashes[0], hashes[5]);
+ assert_eq!(hashes[1], hashes[4]);
+ assert_eq!(hashes[2], hashes[3]);
+ }
+
Review Comment:
a unit test for the hash function.
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add support for FixedSizeList type in `arrow_cast`, hashing [arrow-datafusion]
Posted by "Weijun-H (via GitHub)" <gi...@apache.org>.
Weijun-H commented on code in PR #8344:
URL: https://github.com/apache/arrow-datafusion/pull/8344#discussion_r1458219694
##########
datafusion/sqllogictest/test_files/arrow_typeof.slt:
##########
@@ -384,4 +384,35 @@ LargeList(Field { name: "item", data_type: Int64, nullable: true, dict_id: 0, di
query T
select arrow_typeof(arrow_cast(make_array([1, 2, 3]), 'LargeList(LargeList(Int64))'));
----
-LargeList(Field { name: "item", data_type: LargeList(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: {} })
\ No newline at end of file
+LargeList(Field { name: "item", data_type: LargeList(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: {} })
+
+## FixedSizeList
+
+query ?
+select arrow_cast(null, 'FixedSizeList(1, Int64)');
+----
+NULL
+
+#TODO: arrow-rs doesn't support it yet
Review Comment:
I noticed that the List supports casting from UTF8 to List with a single size. Therefore, I think FixedSizeList should also support it.
```
select arrow_cast('1', 'LargeList(Int64)');
----
[1]
```
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org