shehabgamin commented on code in PR #15168: URL: https://github.com/apache/datafusion/pull/15168#discussion_r1994917169
########## datafusion/sqllogictest/test_files/spark/math/expm1.slt: ########## @@ -0,0 +1,32 @@ +# 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. + Review Comment: > The `expm1` probably works identically across all Spark versions and is not affected by different configuration settings, but many expressions are affected by settings such as ANSI mode and different date/time formats and timezones. > > How do you think we should handle these different cases with this test approach? In the Sail code base, auxiliary information is passed into `new()` and stored within the struct. For example: https://github.com/lakehq/sail/blob/be54362ce8bd79bfb3e55214c5a1b80c2c3d2492/crates/sail-plan/src/extension/function/datetime/timestamp_now.rs#L9-L32 ``` #[derive(Debug)] pub struct TimestampNow { signature: Signature, timezone: Arc<str>, time_unit: TimeUnit, } impl TimestampNow { pub fn new(timezone: Arc<str>, time_unit: TimeUnit) -> Self { Self { signature: Signature::nullary(Volatility::Stable), timezone, time_unit, } } pub fn timezone(&self) -> &str { &self.timezone } pub fn time_unit(&self) -> &TimeUnit { &self.time_unit } } ``` And then in our `PhysicalExtensionCodec` we can do the following: https://github.com/lakehq/sail/blob/be54362ce8bd79bfb3e55214c5a1b80c2c3d2492/crates/sail-execution/src/codec.rs#L946-L953 ``` if let Some(func) = node.inner().as_any().downcast_ref::<TimestampNow>() { let timezone = func.timezone().to_string(); let time_unit: gen_datafusion_common::TimeUnit = func.time_unit().into(); let time_unit = time_unit.as_str_name().to_string(); UdfKind::TimestampNow(gen::TimestampNowUdf { timezone, time_unit, }) ``` If we decide to not use sqllogictest (per https://github.com/apache/datafusion/pull/15168#discussion_r1994863716) then we will have no problem testing UDFs with auxiliary information. There are already tests in DataFusion core for this type of pattern as well: https://github.com/apache/datafusion/blob/8061485be3b197d40bb35be09f9cf0a282c99bcd/datafusion/core/tests/user_defined/user_defined_scalar_functions.rs#L1265-L1304 -- 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