alamb commented on code in PR #12459:
URL: https://github.com/apache/datafusion/pull/12459#discussion_r1759532353


##########
datafusion/core/tests/user_defined/array_has.rs:
##########
@@ -0,0 +1,54 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use arrow::datatypes::UInt32Type;
+use arrow::datatypes::{DataType, Field, Schema};
+use arrow::record_batch::RecordBatch;
+use arrow_array::ListArray;
+use datafusion::logical_expr::ScalarUDF;
+use datafusion::prelude::*;
+use datafusion_functions_nested::array_has::ArrayHas;
+use std::sync::Arc;
+
+/// can't go next to the `ArrayHas` struct due to circular dependencies, hence 
this standalone test

Review Comment:
   Since this test isn't a user defined function per se, can we move this test 
to https://github.com/apache/datafusion/tree/main/datafusion/core/tests/sql 
instead ?
   



##########
datafusion/core/tests/user_defined/array_has.rs:
##########
@@ -0,0 +1,54 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use arrow::datatypes::UInt32Type;
+use arrow::datatypes::{DataType, Field, Schema};
+use arrow::record_batch::RecordBatch;
+use arrow_array::ListArray;
+use datafusion::logical_expr::ScalarUDF;
+use datafusion::prelude::*;
+use datafusion_functions_nested::array_has::ArrayHas;
+use std::sync::Arc;
+
+/// can't go next to the `ArrayHas` struct due to circular dependencies, hence 
this standalone test
+#[tokio::test]
+async fn array_has_empty_haystack() {
+    let ctx = SessionContext::new();

Review Comment:
   FWIW I tried to come up with a pure sql reproducer for this and could not:
   
   ```sql
   > create or replace table t as values (make_array([]), (make_array([])), 
(make_array([])));
   0 row(s) fetched.
   Elapsed 0.002 seconds.
   ```
   
   I could't make the query work:
   ```sql
   > select 1 from t where array_has(column1, 1);
   type_coercion
   caused by
   Error during planning: Error during planning: Coercion from [List(Field { 
name: "item", data_type: List(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: {} }), Int64] to the signature 
ArraySignature(ArrayAndElement) failed. No function matches the given name and 
argument types 'array_has(List(Field { name: "item", data_type: List(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: {} }), Int64)'. You might need to add explicit type casts.
        Candidate functions:
        array_has(array, element)
   
   > select 1 from t where array_has(column1, arrow_cast(1, 'UInt64'));
   type_coercion
   caused by
   Error during planning: Error during planning: Coercion from [List(Field { 
name: "item", data_type: List(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: {} }), UInt64] to the signature 
ArraySignature(ArrayAndElement) failed. No function matches the given name and 
argument types 'array_has(List(Field { name: "item", data_type: List(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: {} }), UInt64)'. You might need to add explicit type casts.
        Candidate functions:
        array_has(array, element)
   ```
   
   Any thoughts @jayzhan211  or @Weijun-H ? I think you may be more familiar 
with this code than am I



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to