You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "universalmind303 (via GitHub)" <gi...@apache.org> on 2024/02/21 19:29:32 UTC

[PR] feat: add support for fixed list wildcard in type signature [arrow-datafusion]

universalmind303 opened a new pull request, #9312:
URL: https://github.com/apache/arrow-datafusion/pull/9312

   ## 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 https://github.com/apache/arrow-datafusion/issues/9139
   
   ## Rationale for this change
   better support for working with fixed size lists is needed
   <!--
    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] feat: add support for fixed list wildcard in type signature [arrow-datafusion]

Posted by "universalmind303 (via GitHub)" <gi...@apache.org>.
universalmind303 commented on PR #9312:
URL: https://github.com/apache/arrow-datafusion/pull/9312#issuecomment-1979096142

   test failures seem unrelated. I get same errors on main 


-- 
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] feat: add support for fixed list wildcard in type signature [arrow-datafusion]

Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on PR #9312:
URL: https://github.com/apache/arrow-datafusion/pull/9312#issuecomment-1962271571

   If I understand correctly, it should pass the test like
   
   ```rust
           let inner = Arc::new(Field::new("item", DataType::Int32, false));
           let current_types = vec![
               DataType::FixedSizeList(inner.clone(), 2), // able to coerce for any size
           ];
           let signature = Signature::exact(vec![
               DataType::FixedSizeList(inner.clone(), FIXED_SIZE_LIST_WILDCARD),
           ], Volatility::Stable);
           let coerced_data_types = data_types(&current_types, &signature).unwrap();
           assert_eq!(coerced_data_types, current_types);
   ```


-- 
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] feat: add support for fixed list wildcard in type signature [arrow-datafusion]

Posted by "universalmind303 (via GitHub)" <gi...@apache.org>.
universalmind303 commented on PR #9312:
URL: https://github.com/apache/arrow-datafusion/pull/9312#issuecomment-1961393357

   > arrow cast does not support to casting to wildcard size, after `coerce_from` the original size info is lost, how do you process the wildcard size instead
   
   I think i actually had this switched around. 
   
   `FixedSizeList(_, FIXED_SIZE_LIST_WILDCARD))` should coerce to `FixedSizeList(_, size))` not the other way around. 


-- 
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] feat: add support for fixed list wildcard in type signature [arrow-datafusion]

Posted by "universalmind303 (via GitHub)" <gi...@apache.org>.
universalmind303 commented on PR #9312:
URL: https://github.com/apache/arrow-datafusion/pull/9312#issuecomment-1978910390

   @jayzhan211 it should be ready for review now.
   
   also @gruuya thanks for the suggestions. That snippet seems to get all tests to pass!


-- 
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] feat: add support for fixed list wildcard in type signature [arrow-datafusion]

Posted by "gruuya (via GitHub)" <gi...@apache.org>.
gruuya commented on code in PR #9312:
URL: https://github.com/apache/arrow-datafusion/pull/9312#discussion_r1513303884


##########
datafusion/expr/src/type_coercion/functions.rs:
##########
@@ -492,4 +515,77 @@ mod tests {
 
         Ok(())
     }
+
+    #[test]
+    fn test_fixed_list_wildcard_coerce() -> Result<()> {
+        let inner = Arc::new(Field::new("item", DataType::Int32, false));
+        let current_types = vec![
+            DataType::FixedSizeList(inner.clone(), 2), // able to coerce for any size
+        ];
+
+        let signature = Signature::exact(
+            vec![DataType::FixedSizeList(
+                inner.clone(),
+                FIXED_SIZE_LIST_WILDCARD,
+            )],
+            Volatility::Stable,
+        );
+
+        let coerced_data_types = data_types(&current_types, &signature).unwrap();
+        assert_eq!(coerced_data_types, current_types);
+
+        // make sure it can't coerce to a different size
+        let signature = Signature::exact(
+            vec![DataType::FixedSizeList(inner.clone(), 3)],
+            Volatility::Stable,
+        );
+        let coerced_data_types = data_types(&current_types, &signature);
+        assert!(coerced_data_types.is_err());

Review Comment:
   This is a good assert, though what i had in mind is that it probably wouldn't work for `current_types = vec![DataType::FixedSizeList(inner.clone(), 3)]`, even though in that case it should, right?



-- 
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] feat: add support for fixed list wildcard in type signature [arrow-datafusion]

Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on PR #9312:
URL: https://github.com/apache/arrow-datafusion/pull/9312#issuecomment-1960847047

   Shouldn't fixed size list be converted to list? @universalmind303 Is there any example / test that shows the need.


-- 
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] feat: add support for fixed list wildcard in type signature [arrow-datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #9312:
URL: https://github.com/apache/arrow-datafusion/pull/9312


-- 
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] feat: add support for fixed list wildcard in type signature [arrow-datafusion]

Posted by "universalmind303 (via GitHub)" <gi...@apache.org>.
universalmind303 commented on code in PR #9312:
URL: https://github.com/apache/arrow-datafusion/pull/9312#discussion_r1513417716


##########
datafusion/expr/src/type_coercion/functions.rs:
##########
@@ -492,4 +515,77 @@ mod tests {
 
         Ok(())
     }
+
+    #[test]
+    fn test_fixed_list_wildcard_coerce() -> Result<()> {
+        let inner = Arc::new(Field::new("item", DataType::Int32, false));
+        let current_types = vec![
+            DataType::FixedSizeList(inner.clone(), 2), // able to coerce for any size
+        ];
+
+        let signature = Signature::exact(
+            vec![DataType::FixedSizeList(
+                inner.clone(),
+                FIXED_SIZE_LIST_WILDCARD,
+            )],
+            Volatility::Stable,
+        );
+
+        let coerced_data_types = data_types(&current_types, &signature).unwrap();
+        assert_eq!(coerced_data_types, current_types);
+
+        // make sure it can't coerce to a different size
+        let signature = Signature::exact(
+            vec![DataType::FixedSizeList(inner.clone(), 3)],
+            Volatility::Stable,
+        );
+        let coerced_data_types = data_types(&current_types, &signature);
+        assert!(coerced_data_types.is_err());

Review Comment:
   so like making sure the same type works? 
   
   ```rs
           let current_types = vec![
               DataType::FixedSizeList(inner.clone(), 2), // able to coerce for any size
           ];
   
           // make sure it works with the same type.
           let signature = Signature::exact(
               vec![DataType::FixedSizeList(inner.clone(), 2)],
               Volatility::Stable,
           );
           let coerced_data_types = data_types(&current_types, &signature).unwrap();
           assert_eq!(coerced_data_types, current_types);
   ```



-- 
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] feat: add support for fixed list wildcard in type signature [arrow-datafusion]

Posted by "gruuya (via GitHub)" <gi...@apache.org>.
gruuya commented on code in PR #9312:
URL: https://github.com/apache/arrow-datafusion/pull/9312#discussion_r1501357779


##########
datafusion/expr/src/type_coercion/functions.rs:
##########
@@ -372,13 +374,20 @@ fn coerced_from<'a>(
         List(_) if matches!(type_from, FixedSizeList(_, _)) => Some(type_into.clone()),
 
         // Only accept list and largelist with the same number of dimensions unless the type is Null.
-        // List or LargeList with different dimensions should be handled in TypeSignature or other places before this.
+        // List or LargeList with different dimensions should be handled in TypeSignature or other places before this
         List(_) | LargeList(_)
             if datafusion_common::utils::base_type(type_from).eq(&Null)
                 || list_ndims(type_from) == list_ndims(type_into) =>
         {
             Some(type_into.clone())
         }
+        // should be able to coerce wildcard fixed size list to non wildcard fixed size list
+        FixedSizeList(_, _)
+            if matches!(type_from, FixedSizeList(_, FIXED_SIZE_LIST_WILDCARD))
+                && list_ndims(type_from) == list_ndims(type_into) =>

Review Comment:
   Maybe there should even be a check for all nested types, which will cover the base case as well (and the ndims check I think?)
   ```rust
   FixedSizeList(f_into, FIXED_SIZE_LIST_WILDCARD) => match type_from {
       FixedSizeList(f_from, size_from)
           if coerced_from(f_into.data_type(), f_from.data_type())
               == Some(f_into.data_type().clone()) =>
       {
           Some(FixedSizeList(f_into.clone(), *size_from))
       }
       _ => None,
   },
   ```
   (with @jayzhan211 fix too)
   
   EDIT: This does not really handle swapping the wildcard size in any nested `FixedSizeList`s



-- 
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] feat: add support for fixed list wildcard in type signature [arrow-datafusion]

Posted by "gruuya (via GitHub)" <gi...@apache.org>.
gruuya commented on PR #9312:
URL: https://github.com/apache/arrow-datafusion/pull/9312#issuecomment-1979698762

   Yup, looks good!


-- 
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] feat: add support for fixed list wildcard in type signature [arrow-datafusion]

Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on PR #9312:
URL: https://github.com/apache/arrow-datafusion/pull/9312#issuecomment-1978265745

   Feel free to ping me if it is ready for review


-- 
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] feat: add support for fixed list wildcard in type signature [arrow-datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #9312:
URL: https://github.com/apache/arrow-datafusion/pull/9312#issuecomment-1979675125

   @gruuya  do you think this PR is good to go?


-- 
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] feat: add support for fixed list wildcard in type signature [arrow-datafusion]

Posted by "gruuya (via GitHub)" <gi...@apache.org>.
gruuya commented on code in PR #9312:
URL: https://github.com/apache/arrow-datafusion/pull/9312#discussion_r1501368655


##########
datafusion/expr/src/type_coercion/functions.rs:
##########
@@ -372,13 +374,20 @@ fn coerced_from<'a>(
         List(_) if matches!(type_from, FixedSizeList(_, _)) => Some(type_into.clone()),
 
         // Only accept list and largelist with the same number of dimensions unless the type is Null.
-        // List or LargeList with different dimensions should be handled in TypeSignature or other places before this.
+        // List or LargeList with different dimensions should be handled in TypeSignature or other places before this
         List(_) | LargeList(_)
             if datafusion_common::utils::base_type(type_from).eq(&Null)
                 || list_ndims(type_from) == list_ndims(type_into) =>
         {
             Some(type_into.clone())
         }
+        // should be able to coerce wildcard fixed size list to non wildcard fixed size list
+        FixedSizeList(_, _)
+            if matches!(type_from, FixedSizeList(_, FIXED_SIZE_LIST_WILDCARD))
+                && list_ndims(type_from) == list_ndims(type_into) =>

Review Comment:
   Ok got a bit nerd-sniped here it seems, but I think the following actually handles the nested `FixedSizeLists` too:
   ```rust
   FixedSizeList(f_into, FIXED_SIZE_LIST_WILDCARD) => match type_from {
       FixedSizeList(f_from, size_from) => {
           match coerced_from(f_into.data_type(), f_from.data_type()) {
               Some(data_type) if &data_type != f_into.data_type() => {
                   let new_field =
                       Arc::new(f_into.as_ref().clone().with_data_type(data_type));
                   Some(FixedSizeList(new_field, *size_from))
               }
               Some(_) => Some(FixedSizeList(f_into.clone(), *size_from)),
               _ => None,
           }
       }
       _ => None,
   },
   ```
   
   The following test passes (as does the one by @jayzhan211 ):
   ```rust
   #[test]
   fn test_nested_wildcard_fixed_size_lists() -> Result<()> {
       let type_into = DataType::FixedSizeList(
           Arc::new(Field::new(
               "item",
               DataType::FixedSizeList(
                   Arc::new(Field::new("item", DataType::Int32, false)),
                   FIXED_SIZE_LIST_WILDCARD,
               ),
               false,
           )),
           FIXED_SIZE_LIST_WILDCARD,
       );
   
       let type_from = DataType::FixedSizeList(
           Arc::new(Field::new(
               "item",
               DataType::FixedSizeList(
                   Arc::new(Field::new("item", DataType::Int8, false)),
                   4,
               ),
               false,
           )),
           3,
       );
   
       assert_eq!(
           coerced_from(&type_into, &type_from),
           Some(DataType::FixedSizeList(
               Arc::new(Field::new(
                   "item",
                   DataType::FixedSizeList(
                       Arc::new(Field::new("item", DataType::Int32, false)),
                       4,
                   ),
                   false,
               )),
               3,
           ))
       );
   
       Ok(())
   }
   ```



-- 
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] feat: add support for fixed list wildcard in type signature [arrow-datafusion]

Posted by "gruuya (via GitHub)" <gi...@apache.org>.
gruuya commented on code in PR #9312:
URL: https://github.com/apache/arrow-datafusion/pull/9312#discussion_r1513426860


##########
datafusion/expr/src/type_coercion/functions.rs:
##########
@@ -492,4 +515,77 @@ mod tests {
 
         Ok(())
     }
+
+    #[test]
+    fn test_fixed_list_wildcard_coerce() -> Result<()> {
+        let inner = Arc::new(Field::new("item", DataType::Int32, false));
+        let current_types = vec![
+            DataType::FixedSizeList(inner.clone(), 2), // able to coerce for any size
+        ];
+
+        let signature = Signature::exact(
+            vec![DataType::FixedSizeList(
+                inner.clone(),
+                FIXED_SIZE_LIST_WILDCARD,
+            )],
+            Volatility::Stable,
+        );
+
+        let coerced_data_types = data_types(&current_types, &signature).unwrap();
+        assert_eq!(coerced_data_types, current_types);
+
+        // make sure it can't coerce to a different size
+        let signature = Signature::exact(
+            vec![DataType::FixedSizeList(inner.clone(), 3)],
+            Volatility::Stable,
+        );
+        let coerced_data_types = data_types(&current_types, &signature);
+        assert!(coerced_data_types.is_err());

Review Comment:
   Yes, exactly.



-- 
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] feat: add support for fixed list wildcard in type signature [arrow-datafusion]

Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on PR #9312:
URL: https://github.com/apache/arrow-datafusion/pull/9312#issuecomment-1960878717

   arrow cast does not support to cast to wildcard size, after coerce_from, how do you process the wildcard size?


-- 
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] feat: add support for fixed list wildcard in type signature [arrow-datafusion]

Posted by "gruuya (via GitHub)" <gi...@apache.org>.
gruuya commented on code in PR #9312:
URL: https://github.com/apache/arrow-datafusion/pull/9312#discussion_r1501357779


##########
datafusion/expr/src/type_coercion/functions.rs:
##########
@@ -372,13 +374,20 @@ fn coerced_from<'a>(
         List(_) if matches!(type_from, FixedSizeList(_, _)) => Some(type_into.clone()),
 
         // Only accept list and largelist with the same number of dimensions unless the type is Null.
-        // List or LargeList with different dimensions should be handled in TypeSignature or other places before this.
+        // List or LargeList with different dimensions should be handled in TypeSignature or other places before this
         List(_) | LargeList(_)
             if datafusion_common::utils::base_type(type_from).eq(&Null)
                 || list_ndims(type_from) == list_ndims(type_into) =>
         {
             Some(type_into.clone())
         }
+        // should be able to coerce wildcard fixed size list to non wildcard fixed size list
+        FixedSizeList(_, _)
+            if matches!(type_from, FixedSizeList(_, FIXED_SIZE_LIST_WILDCARD))
+                && list_ndims(type_from) == list_ndims(type_into) =>

Review Comment:
   Maybe there should even be a check for all nested types, which will cover the base case as well (and the ndims check I think?)
   ```rust
   FixedSizeList(f_into, FIXED_SIZE_LIST_WILDCARD)
       if matches!(type_from, FixedSizeList(f_from, size_from))
           && coerced_from(f_into, f_from) == Some(f_into) => Some(FixedSizeList(f_into, size_from))
   ```
   (with @jayzhan211 fix too)



-- 
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] feat: add support for fixed list wildcard in type signature [arrow-datafusion]

Posted by "gruuya (via GitHub)" <gi...@apache.org>.
gruuya commented on code in PR #9312:
URL: https://github.com/apache/arrow-datafusion/pull/9312#discussion_r1501357779


##########
datafusion/expr/src/type_coercion/functions.rs:
##########
@@ -372,13 +374,20 @@ fn coerced_from<'a>(
         List(_) if matches!(type_from, FixedSizeList(_, _)) => Some(type_into.clone()),
 
         // Only accept list and largelist with the same number of dimensions unless the type is Null.
-        // List or LargeList with different dimensions should be handled in TypeSignature or other places before this.
+        // List or LargeList with different dimensions should be handled in TypeSignature or other places before this
         List(_) | LargeList(_)
             if datafusion_common::utils::base_type(type_from).eq(&Null)
                 || list_ndims(type_from) == list_ndims(type_into) =>
         {
             Some(type_into.clone())
         }
+        // should be able to coerce wildcard fixed size list to non wildcard fixed size list
+        FixedSizeList(_, _)
+            if matches!(type_from, FixedSizeList(_, FIXED_SIZE_LIST_WILDCARD))
+                && list_ndims(type_from) == list_ndims(type_into) =>

Review Comment:
   Maybe there should even be a check for all nested types, which will cover the base case as well (and the ndims check I think?)
   ```rust
   FixedSizeList(f_into, _)
       if matches!(type_from, FixedSizeList(f_from, FIXED_SIZE_LIST_WILDCARD))
           && coerced_from(f_into, f_from) == Some(f_into) =>
   ```



-- 
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] feat: add support for fixed list wildcard in type signature [arrow-datafusion]

Posted by "gruuya (via GitHub)" <gi...@apache.org>.
gruuya commented on code in PR #9312:
URL: https://github.com/apache/arrow-datafusion/pull/9312#discussion_r1501242477


##########
datafusion/expr/src/type_coercion/functions.rs:
##########
@@ -372,13 +374,20 @@ fn coerced_from<'a>(
         List(_) if matches!(type_from, FixedSizeList(_, _)) => Some(type_into.clone()),
 
         // Only accept list and largelist with the same number of dimensions unless the type is Null.
-        // List or LargeList with different dimensions should be handled in TypeSignature or other places before this.
+        // List or LargeList with different dimensions should be handled in TypeSignature or other places before this
         List(_) | LargeList(_)
             if datafusion_common::utils::base_type(type_from).eq(&Null)
                 || list_ndims(type_from) == list_ndims(type_into) =>
         {
             Some(type_into.clone())
         }
+        // should be able to coerce wildcard fixed size list to non wildcard fixed size list
+        FixedSizeList(_, _)
+            if matches!(type_from, FixedSizeList(_, FIXED_SIZE_LIST_WILDCARD))
+                && list_ndims(type_from) == list_ndims(type_into) =>

Review Comment:
   Perhaps there should also be a condition for checking coerce-ability of the base types here (and maybe a negative test too), something along the lines of:
    ```rust
   ... && coerced_from(base_type(type_into), base_type(type_from)) == Some(base_type(type_into))
   ```
   
   Though that should probably be the case for the other two list data types as well.



-- 
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] feat: add support for fixed list wildcard in type signature [arrow-datafusion]

Posted by "gruuya (via GitHub)" <gi...@apache.org>.
gruuya commented on code in PR #9312:
URL: https://github.com/apache/arrow-datafusion/pull/9312#discussion_r1501242477


##########
datafusion/expr/src/type_coercion/functions.rs:
##########
@@ -372,13 +374,20 @@ fn coerced_from<'a>(
         List(_) if matches!(type_from, FixedSizeList(_, _)) => Some(type_into.clone()),
 
         // Only accept list and largelist with the same number of dimensions unless the type is Null.
-        // List or LargeList with different dimensions should be handled in TypeSignature or other places before this.
+        // List or LargeList with different dimensions should be handled in TypeSignature or other places before this
         List(_) | LargeList(_)
             if datafusion_common::utils::base_type(type_from).eq(&Null)
                 || list_ndims(type_from) == list_ndims(type_into) =>
         {
             Some(type_into.clone())
         }
+        // should be able to coerce wildcard fixed size list to non wildcard fixed size list
+        FixedSizeList(_, _)
+            if matches!(type_from, FixedSizeList(_, FIXED_SIZE_LIST_WILDCARD))
+                && list_ndims(type_from) == list_ndims(type_into) =>

Review Comment:
   Perhaps there should also be a condition for checking coerce-ability of the base types here (and maybe a negative test too), something along the lines of:
    ```rust
   ... && coerced_from(base_type(type_into), base_type(type_from)) == Some(base_type(type_into))
   ```



-- 
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] feat: add support for fixed list wildcard in type signature [arrow-datafusion]

Posted by "gruuya (via GitHub)" <gi...@apache.org>.
gruuya commented on code in PR #9312:
URL: https://github.com/apache/arrow-datafusion/pull/9312#discussion_r1501357779


##########
datafusion/expr/src/type_coercion/functions.rs:
##########
@@ -372,13 +374,20 @@ fn coerced_from<'a>(
         List(_) if matches!(type_from, FixedSizeList(_, _)) => Some(type_into.clone()),
 
         // Only accept list and largelist with the same number of dimensions unless the type is Null.
-        // List or LargeList with different dimensions should be handled in TypeSignature or other places before this.
+        // List or LargeList with different dimensions should be handled in TypeSignature or other places before this
         List(_) | LargeList(_)
             if datafusion_common::utils::base_type(type_from).eq(&Null)
                 || list_ndims(type_from) == list_ndims(type_into) =>
         {
             Some(type_into.clone())
         }
+        // should be able to coerce wildcard fixed size list to non wildcard fixed size list
+        FixedSizeList(_, _)
+            if matches!(type_from, FixedSizeList(_, FIXED_SIZE_LIST_WILDCARD))
+                && list_ndims(type_from) == list_ndims(type_into) =>

Review Comment:
   Maybe there should even be a check for all nested types, which will cover the base case as well (and the ndims check I think?)
   ```rust
   FixedSizeList(f_into, FIXED_SIZE_LIST_WILDCARD)
       if matches!(type_from, FixedSizeList(f_from, _))
           && coerced_from(f_into, f_from) == Some(f_into) => Some(type_from)
   ```
   (with @jayzhan211 fix too)



-- 
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] feat: add support for fixed list wildcard in type signature [arrow-datafusion]

Posted by "universalmind303 (via GitHub)" <gi...@apache.org>.
universalmind303 commented on PR #9312:
URL: https://github.com/apache/arrow-datafusion/pull/9312#issuecomment-1979365571

   > One last thing that might be missing is handling the non-wildcard scenario, i.e. when someone might want to specify an specific/explicit size for the `FixedSizeList` in the signature.
   
   I just added a test case for that. 


-- 
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] feat: add support for fixed list wildcard in type signature [arrow-datafusion]

Posted by "gruuya (via GitHub)" <gi...@apache.org>.
gruuya commented on PR #9312:
URL: https://github.com/apache/arrow-datafusion/pull/9312#issuecomment-1979284954

   One last thing that might be missing is handling the non-wildcard scenario, i.e. when someone might want to specify an specific/explicit size for the `FixedSizeList` in the signature.


-- 
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