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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
