TechWizard9999 commented on code in PR #399: URL: https://github.com/apache/datafusion-spark/pull/399#discussion_r4676495742
########## crates/sqllogictest/test_files/datetime/add_months.slt: ########## @@ -2,60 +2,73 @@ # SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership # SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements -# `add_months` has no `invoke_with_args` yet, so the records that call it are marked -# `skipif evaluate` until https://github.com/apache/datafusion-spark/issues/312 is fixed. - -skipif evaluate query D SELECT add_months('2016-07-30'::date, 1::int); ---- 2016-08-30 -skipif evaluate query D SELECT add_months('2016-07-30'::date, 0::int); ---- 2016-07-30 -skipif evaluate query D SELECT add_months('2016-07-30'::date, 10000::int); ---- 2849-11-30 # Test integer overflow -skipif evaluate query error SELECT add_months('2016-07-30'::date, 2147483647::int); ---- DataFusion error: Arrow error: Compute error: Date arithmetic overflow: 17012 + 2147483647 months -skipif evaluate query D SELECT add_months('2016-07-30'::date, -5::int); ---- 2016-02-29 # Test with NULL values -skipif evaluate query D SELECT add_months(NULL::date, 1::int); ---- NULL -skipif evaluate query D SELECT add_months('2016-07-30'::date, NULL::int); ---- NULL -skipif evaluate query D SELECT add_months(NULL::date, NULL::int); ---- NULL +# Column arguments, with the day clamped to the end of a shorter month +query D +SELECT add_months(d, m) FROM VALUES + ('2016-07-30'::date, 1::int), + ('2016-08-31'::date, 1::int), + ('2024-01-31'::date, 1::int), + (NULL::date, 1::int), + ('2016-07-30'::date, NULL::int) + AS t(d, m); +---- +2016-08-30 +2016-09-30 +2024-02-29 +NULL +NULL + +# Scalar date with a column of months Review Comment: Added the column test. Thanks. -- 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]
