@@ -421,6 +421,16 @@ TEST_F(CastExprTest, date) {
421421
422422 setCastIntByTruncate (true );
423423 testCast<std::string, Date>(" date" , input, result);
424+
425+ // Wrong date format case.
426+ std::vector<std::optional<std::string>> inputWrongFormat{
427+ " 1970-01/01" , " 2023/05/10" , " 2023-/05-/10" , " 20150318" };
428+ std::vector<std::optional<Date>> nullResult{
429+ std::nullopt , std::nullopt , std::nullopt , std::nullopt };
430+ testCast<std::string, Date>(
431+ " date" , inputWrongFormat, nullResult, false , true );
432+ testCast<std::string, Date>(
433+ " date" , inputWrongFormat, nullResult, true , false );
424434}
425435
426436TEST_F (CastExprTest, invalidDate) {
@@ -552,6 +562,13 @@ TEST_F(CastExprTest, allowDecimal) {
552562 " int" , {" -." , " 0.0" , " 125.5" , " -128.3" }, {0 , 0 , 125 , -128 }, false , true );
553563}
554564
565+ TEST_F (CastExprTest, sparkSemantic) {
566+ // Allow decimal.
567+ setCastIntAllowDecimalAndByTruncate (true );
568+ testCast<float , bool >(
569+ " bool" , {0.5 , -0.5 , 1 , 0 }, {true , true , true , false }, false , true );
570+ }
571+
555572constexpr vector_size_t kVectorSize = 1'000 ;
556573
557574TEST_F (CastExprTest, mapCast) {
0 commit comments