Satyr09 commented on code in PR #5789: URL: https://github.com/apache/datafusion-comet/pull/5789#discussion_r3999316507
########## spark/src/test/resources/sql-tests/expressions/datetime/unix_timestamp_strings.sql: ########## @@ -0,0 +1,58 @@ +-- 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. + +-- Config: spark.sql.legacy.timeParserPolicy=CORRECTED +-- ConfigMatrix: parquet.enable.dictionary=false,true +-- ConfigMatrix: spark.sql.session.timeZone=UTC,America/Los_Angeles + +statement +CREATE TABLE test_unix_ts_strings(s string, fmt string) USING parquet + +statement +INSERT INTO test_unix_ts_strings VALUES + ('1970-01-01 00:00:00', 'yyyy-MM-dd HH:mm:ss'), + ('1969-12-31 23:59:59', 'yyyy-MM-dd HH:mm:ss'), + ('2024-02-29 12:30:45', 'yyyy-MM-dd HH:mm:ss'), + ('2024-03-10 02:30:00', 'yyyy-MM-dd HH:mm:ss'), + ('2024-11-03 01:30:00', 'yyyy-MM-dd HH:mm:ss'), + ('1969-12-31 23:59:59.999999', 'yyyy-MM-dd HH:mm:ss.SSSSSS'), + ('2024/06/15', 'yyyy/MM/dd'), + ('2024-06-15T10:30:45+05:30', "yyyy-MM-dd'T'HH:mm:ssXXX"), + ('1582-10-04', 'yyyy-MM-dd'), + ('0001-01-01', 'yyyy-MM-dd'), + ('9999-12-31', 'yyyy-MM-dd'), + ('not a date', 'yyyy-MM-dd'), + ('2024-02-30', 'yyyy-MM-dd'), + ('', 'yyyy-MM-dd'), + (NULL, 'yyyy-MM-dd'), + ('2024-06-15', NULL), + ('2024-06-15', ''), + (NULL, NULL) + +-- Exercise both the cached literal formatter and the per-row formatter. +query Review Comment: Sure! ########## spark/src/test/scala/org/apache/comet/CometTemporalExpressionSuite.scala: ########## @@ -394,19 +398,27 @@ class CometTemporalExpressionSuite extends CometTestBase with AdaptiveSparkPlanH .createDataFrame(spark.sparkContext.parallelize(data), schema) .createOrReplaceTempView("string_tbl") - // String input should fall back to Spark - checkSparkAnswerAndFallbackReason( - "SELECT ts_str, unix_timestamp(ts_str) from string_tbl order by ts_str", - "unix_timestamp does not support input type: StringType") - - // String input with custom format should also fall back - checkSparkAnswerAndFallbackReason( - "SELECT ts_str, unix_timestamp(ts_str, 'yyyy-MM-dd HH:mm:ss') from string_tbl", - "unix_timestamp does not support input type: StringType") + withSQLConf( + SQLConf.OPTIMIZER_EXCLUDED_RULES.key -> + "org.apache.spark.sql.catalyst.optimizer.ConstantFolding") { + for (allowIncompatible <- Seq("false", "true")) { + withSQLConf( + CometConf.getExprAllowIncompatConfigKey("UnixTimestamp") -> allowIncompatible) { + for (query <- Seq( + "SELECT unix_timestamp(ts_str) FROM string_tbl", + "SELECT unix_timestamp(ts_str, 'yyyy-MM-dd HH:mm:ss') FROM string_tbl", + "SELECT unix_timestamp('2024-06-15', 'yyyy-MM-dd') FROM string_tbl")) { + assertCodegenRan { Review Comment: Aah, thanks for that context. Updated. -- 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]
