andygrove commented on code in PR #21639: URL: https://github.com/apache/datafusion/pull/21639#discussion_r3100694356
########## datafusion/sqllogictest/test_files/spark/datetime/monthname.slt: ########## @@ -0,0 +1,110 @@ +# 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. + +# Scalar date input +query T +SELECT monthname('2024-03-15'::DATE); +---- +Mar + +# All 12 months +query T +SELECT monthname('2024-01-15'::DATE); +---- +Jan + +query T +SELECT monthname('2024-02-15'::DATE); +---- +Feb + +query T +SELECT monthname('2024-03-15'::DATE); +---- +Mar + +query T +SELECT monthname('2024-04-15'::DATE); +---- +Apr + +query T +SELECT monthname('2024-05-15'::DATE); +---- +May + +query T +SELECT monthname('2024-06-15'::DATE); +---- +Jun + +query T +SELECT monthname('2024-07-15'::DATE); +---- +Jul + +query T +SELECT monthname('2024-08-15'::DATE); +---- +Aug + +query T +SELECT monthname('2024-09-15'::DATE); +---- +Sep + +query T +SELECT monthname('2024-10-15'::DATE); +---- +Oct + +query T +SELECT monthname('2024-11-15'::DATE); +---- +Nov + +query T +SELECT monthname('2024-12-15'::DATE); +---- +Dec + +# NULL handling +query T +SELECT monthname(NULL::DATE); +---- +NULL + +# Array input +query T +SELECT monthname(d) FROM (VALUES ('2024-01-01'::DATE), ('2024-06-15'::DATE), ('2024-12-31'::DATE), (NULL::DATE)) AS t(d); +---- +Jan +Jun +Dec +NULL + +# Error: wrong argument type (string without cast) +statement error Failed to coerce arguments to satisfy a call to 'monthname' function +SELECT monthname('not-a-date'); Review Comment: I think Spark returns NULL in this case if ANSI mode is disabled, which is the default prior to Spark 4. -- 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]
