You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "erenavsarogullari (via GitHub)" <gi...@apache.org> on 2024/03/16 07:14:44 UTC

[PR] Port `ArrayExcept` to `functions-array` subcrate [arrow-datafusion]

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

   ## Which issue does this PR close?
   Closes #9633.
   
   ## What changes are included in this PR?
   This PR aims to do following changes in terms of Epic https://github.com/apache/arrow-datafusion/issues/9285:
   ArrayExcept are ported to functions-array subcrate.
   
   ## Are these changes tested?
   Yes, all `array.slt` based ArrayExcept tests are passed.
   
   ## Are there any user-facing changes?
   No
   


-- 
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] Port `ArrayExcept` to `functions-array` subcrate [arrow-datafusion]

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


-- 
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] Port `ArrayExcept` to `functions-array` subcrate [arrow-datafusion]

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


##########
datafusion/functions-array/src/except.rs:
##########
@@ -0,0 +1,176 @@
+// 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.
+
+//! implementation kernel for array_except function
+
+use crate::utils::check_datatypes;
+use arrow::row::{RowConverter, SortField};
+use arrow_array::cast::AsArray;
+use arrow_array::{Array, ArrayRef, GenericListArray, OffsetSizeTrait};
+use arrow_buffer::OffsetBuffer;
+use arrow_schema::DataType::{FixedSizeList, LargeList, List};
+use arrow_schema::{DataType, Field, FieldRef};
+use datafusion_common::{exec_err, internal_err};
+use datafusion_expr::expr::ScalarFunction;
+use datafusion_expr::Expr;
+use datafusion_expr::{ColumnarValue, ScalarUDFImpl, Signature, Volatility};
+use std::any::Any;
+use std::collections::HashSet;
+use std::sync::Arc;
+
+make_udf_function!(
+    ArrayExcept,
+    array_except,
+    first_array second_array,
+    "returns an array of the elements that appear in the first array but not in the second.",
+    array_except_udf
+);
+
+#[derive(Debug)]
+pub(super) struct ArrayExcept {
+    signature: Signature,
+    aliases: Vec<String>,
+}
+
+impl ArrayExcept {
+    pub fn new() -> Self {
+        Self {
+            signature: Signature::any(2, Volatility::Immutable),
+            aliases: vec!["array_except".to_string(), "list_except".to_string()],
+        }
+    }
+}
+
+impl ScalarUDFImpl for ArrayExcept {
+    fn as_any(&self) -> &dyn Any {
+        self
+    }
+    fn name(&self) -> &str {
+        "array_except"
+    }
+
+    fn signature(&self) -> &Signature {
+        &self.signature
+    }
+
+    fn return_type(&self, arg_types: &[DataType]) -> datafusion_common::Result<DataType> {
+        match &arg_types[0] {

Review Comment:
   The return type is mismatched with the previous one, and it is much more complex, any reason for this change?



-- 
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] Port `ArrayExcept` to `functions-array` subcrate [arrow-datafusion]

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


##########
datafusion/functions-array/src/except.rs:
##########
@@ -0,0 +1,176 @@
+// 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.
+
+//! implementation kernel for array_except function
+
+use crate::utils::check_datatypes;
+use arrow::row::{RowConverter, SortField};
+use arrow_array::cast::AsArray;
+use arrow_array::{Array, ArrayRef, GenericListArray, OffsetSizeTrait};
+use arrow_buffer::OffsetBuffer;
+use arrow_schema::DataType::{FixedSizeList, LargeList, List};
+use arrow_schema::{DataType, Field, FieldRef};
+use datafusion_common::{exec_err, internal_err};
+use datafusion_expr::expr::ScalarFunction;
+use datafusion_expr::Expr;
+use datafusion_expr::{ColumnarValue, ScalarUDFImpl, Signature, Volatility};
+use std::any::Any;
+use std::collections::HashSet;
+use std::sync::Arc;
+
+make_udf_function!(
+    ArrayExcept,
+    array_except,
+    first_array second_array,
+    "returns an array of the elements that appear in the first array but not in the second.",
+    array_except_udf
+);
+
+#[derive(Debug)]
+pub(super) struct ArrayExcept {
+    signature: Signature,
+    aliases: Vec<String>,
+}
+
+impl ArrayExcept {
+    pub fn new() -> Self {
+        Self {
+            signature: Signature::any(2, Volatility::Immutable),
+            aliases: vec!["array_except".to_string(), "list_except".to_string()],
+        }
+    }
+}
+
+impl ScalarUDFImpl for ArrayExcept {
+    fn as_any(&self) -> &dyn Any {
+        self
+    }
+    fn name(&self) -> &str {
+        "array_except"
+    }
+
+    fn signature(&self) -> &Signature {
+        &self.signature
+    }
+
+    fn return_type(&self, arg_types: &[DataType]) -> datafusion_common::Result<DataType> {
+        match &arg_types[0] {

Review Comment:
   @jayzhan211 Thanks for review. You' re right so we can sync with [previous return_type](https://github.com/apache/arrow-datafusion/pull/9634/files#diff-bf6315d00b4b00c2317d6049734c8155fd5b7e1fc6ab8b28381c3e188a6f799bL343)



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