andygrove commented on code in PR #383: URL: https://github.com/apache/datafusion-comet/pull/383#discussion_r1600745021
########## spark/src/test/scala/org/apache/comet/CometCastSuite.scala: ########## @@ -563,8 +565,54 @@ class CometCastSuite extends CometTestBase with AdaptiveSparkPlanHelper { castTest(generateStrings(numericPattern, 8).toDF("a"), DataTypes.BinaryType) } - ignore("cast StringType to DateType") { + test("cast StringType to DateType") { // https://github.com/apache/datafusion-comet/issues/327 + val validDates = Seq( + "262142-01-01", + "262142-01-01 ", + "262142-01-01T ", + "262142-01-01T 123123123", + "-262143-12-31", + "-262143-12-31 ", + "-262143-12-31T", + "-262143-12-31T ", + "-262143-12-31T 123123123", + "2020", + "2020-1", + "2020-1-1", + "2020-01", + "2020-01-01", + "2020-1-01 ", + "2020-01-1", + "02020-01-01", + "2020-01-01T", + "2020-10-01T 1221213", + "002020-01-01 ", + "0002020-01-01 123344", + "-3638-5") + val invalidDates = Seq( + "0", + "202", + "3/", + "3/3/", + "3/3/2020", + "3#3#2020", + "2020-010-01", + "2020-10-010", + "2020-10-010T", + "--262143-12-31", + "--262143-12-31T 1234 ", + "abc-def-ghi", + "abc-def-ghi jkl", + "2020-mar-20", + "not_a_date", + "T2") + castTest((validDates ++ invalidDates).toDF("a"), DataTypes.DateType) Review Comment: Let's add fuzzing back here, but filter out values that we know that we cannot support. ```suggestion // due to limitations of NaiveDate we only support years between 262143 BC and 262142 AD" // we can't test all possible fuzz dates val unsupportedYearPattern: Regex = "^\\s*[0-9]{5,}".r val fuzzDates = generateStrings(datePattern, 8) .filterNot(str => unsupportedYearPattern.findFirstMatchIn(str).isDefined) castTest((validDates ++ invalidDates ++ fuzzDates).toDF("a"), DataTypes.DateType) ``` -- 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