shehabgamin commented on code in PR #16848: URL: https://github.com/apache/datafusion/pull/16848#discussion_r2230086388
########## datafusion/sqllogictest/test_files/spark/string/luhn_check.slt: ########## @@ -35,3 +35,140 @@ ## PySpark 3.5.5 Result: {'luhn_check(8112189876)': True, 'typeof(luhn_check(8112189876))': 'boolean', 'typeof(8112189876)': 'string'} #query #SELECT luhn_check('8112189876'::string); + Review Comment: All of the commented out tests above this line can be removed since you already implemented them below. Also looks like there may be some duplicate tests below. ########## datafusion/spark/src/function/string/luhn_check.rs: ########## @@ -0,0 +1,145 @@ +// 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 std::{any::Any, sync::Arc}; + +use arrow::array::{Array, AsArray, BooleanArray}; +use arrow::datatypes::DataType; +use arrow::datatypes::DataType::Boolean; +use datafusion_common::utils::take_function_args; +use datafusion_common::{exec_err, Result, ScalarValue}; +use datafusion_expr::{ + ColumnarValue, ScalarFunctionArgs, ScalarUDFImpl, Signature, Volatility, +}; + +/// Spark-compatible `luhn_check` expression +/// <https://spark.apache.org/docs/latest/api/sql/index.html#luhn_check> +#[derive(Debug)] +pub struct SparkLuhnCheck { + signature: Signature, +} + +impl Default for SparkLuhnCheck { + fn default() -> Self { + Self::new() + } +} + +impl SparkLuhnCheck { + pub fn new() -> Self { + Self { + signature: Signature::exact(vec![DataType::Utf8], Volatility::Immutable), Review Comment: `invoke_with_args` allows for `DataType::Utf8View`, `DataType::Utf8`, and `DataType::LargeUtf8`. ```suggestion signature: Signature::one_of( vec![ TypeSignature::Exact(vec![DataType::Utf8]), TypeSignature::Exact(vec![DataType::Utf8View]), TypeSignature::Exact(vec![DataType::LargeUtf8]), ], Volatility::Immutable, ), ``` -- 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-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org