2020#include < gtest/gtest.h>
2121
2222#include " arrow/compute/api_scalar.h"
23- #include " arrow/util/chrono_internal.h" // for ARROW_USE_STD_CHRONO
2423#include " arrow/compute/cast.h"
2524#include " arrow/compute/kernels/test_util_internal.h"
2625#include " arrow/testing/gtest_util.h"
@@ -870,13 +869,7 @@ TEST_F(ScalarTemporalTest, TestZoned2) {
870869 {"iso_year": 2009, "iso_week": 1, "iso_day_of_week": 1},
871870 {"iso_year": 2011, "iso_week": 52, "iso_day_of_week": 7}, null])" );
872871 auto quarter = " [1, 1, 1, 2, 1, 4, 4, 4, 1, 1, 1, 1, 4, 4, 4, 1, null]" ;
873- // Note: GCC behaves differently for Australia/Broken_Hill around the year 2000 zone
874- // rule transition. The expected hour for 2000-02-29 (index 1) differs because the
875- // offset is wrong (+9:30 instead of +10:30).
876- std::string hour = " [9, 9, 9, 13, 11, 12, 13, 14, 15, 17, 18, 19, 20, 10, 10, 11, null]" ;
877- #if ARROW_USE_STD_CHRONO
878- hour.replace (hour.find (" [9, 9, " ), 6 , " [9, 8, " );
879- #endif
872+ auto hour = " [9, 9, 9, 13, 11, 12, 13, 14, 15, 17, 18, 19, 20, 10, 10, 11, null]" ;
880873 auto minute = " [30, 53, 59, 3, 35, 40, 45, 50, 55, 0, 5, 10, 15, 30, 30, 32, null]" ;
881874
882875 CheckScalarUnary (" year" , unit, times_seconds_precision, int64 (), year);
@@ -897,7 +890,7 @@ TEST_F(ScalarTemporalTest, TestZoned2) {
897890 CheckScalarUnary (" iso_calendar" , ArrayFromJSON (unit, times_seconds_precision),
898891 iso_calendar);
899892 CheckScalarUnary (" quarter" , unit, times_seconds_precision, int64 (), quarter);
900- CheckScalarUnary (" hour" , unit, times_seconds_precision, int64 (), hour. c_str () );
893+ CheckScalarUnary (" hour" , unit, times_seconds_precision, int64 (), hour);
901894 CheckScalarUnary (" minute" , unit, times_seconds_precision, int64 (), minute);
902895 CheckScalarUnary (" second" , unit, times_seconds_precision, int64 (), second);
903896 CheckScalarUnary (" millisecond" , unit, times_seconds_precision, int64 (), zeros);
@@ -2824,32 +2817,26 @@ TEST_F(ScalarTemporalTestMultipleSinceGreaterUnit, CeilZoned) {
28242817 "2020-01-01 01:09:00", "2019-12-31 02:22:00", "2019-12-30 03:22:00", "2009-12-31 04:22:00",
28252818 "2010-01-01 05:35:00", "2010-01-03 06:43:00", "2010-01-04 07:43:00", "2006-01-01 08:43:00",
28262819 "2005-12-31 09:56:00", "2008-12-28 00:09:00", "2008-12-29 00:09:00", "2012-01-01 01:09:00", null])" ;
2827- std::string ceil_15_hour = R"( [
2820+ const char * ceil_15_hour = R"( [
28282821 "1970-01-01 05:30:00", "2000-03-01 04:30:00", "1899-01-01 06:00:00", "2033-05-18 05:30:00",
28292822 "2020-01-01 04:30:00", "2019-12-31 04:30:00", "2019-12-30 04:30:00", "2009-12-31 04:30:00",
28302823 "2010-01-01 19:30:00", "2010-01-03 19:30:00", "2010-01-04 19:30:00", "2006-01-01 19:30:00",
28312824 "2005-12-31 19:30:00", "2008-12-28 04:30:00", "2008-12-29 04:30:00", "2012-01-01 04:30:00", null])" ;
2832- std::string ceil_15_day = R"( [
2825+ const char * ceil_15_day = R"( [
28332826 "1970-01-15 14:30:00", "2000-03-15 13:30:00", "1899-01-15 15:00:00", "2033-05-30 14:30:00",
28342827 "2020-01-15 13:30:00", "2020-01-14 13:30:00", "2019-12-30 13:30:00", "2010-01-14 13:30:00",
28352828 "2010-01-15 13:30:00", "2010-01-15 13:30:00", "2010-01-15 13:30:00", "2006-01-15 13:30:00",
28362829 "2006-01-14 13:30:00", "2008-12-30 13:30:00", "2008-12-30 13:30:00", "2012-01-15 13:30:00", null])" ;
2837- std::string ceil_3_weeks = R"( [
2830+ const char * ceil_3_weeks = R"( [
28382831 "1970-01-18 14:30:00", "2000-03-05 13:30:00", "1899-01-22 15:00:00", "2033-05-29 14:30:00",
28392832 "2020-01-19 13:30:00", "2020-01-19 13:30:00", "2020-01-19 13:30:00", "2010-01-24 13:30:00",
28402833 "2010-01-24 13:30:00", "2010-01-24 13:30:00", "2010-01-24 13:30:00", "2006-01-22 13:30:00",
28412834 "2006-01-22 13:30:00", "2009-01-11 13:30:00", "2009-01-18 13:30:00", "2012-01-22 13:30:00", null])" ;
2842- std::string ceil_3_weeks_sunday = R"( [
2835+ const char * ceil_3_weeks_sunday = R"( [
28432836 "1970-01-24 14:30:00", "2000-03-25 13:30:00", "1899-01-21 15:00:00", "2033-05-28 14:30:00",
28442837 "2020-01-18 13:30:00", "2020-01-18 13:30:00", "2020-01-18 13:30:00", "2010-01-23 13:30:00",
28452838 "2010-01-23 13:30:00", "2010-01-23 13:30:00", "2010-01-23 13:30:00", "2006-01-21 13:30:00",
28462839 "2006-01-21 13:30:00", "2009-01-24 13:30:00", "2009-01-24 13:30:00", "2012-01-21 13:30:00", null])" ;
2847- #if ARROW_USE_STD_CHRONO
2848- ceil_15_hour.replace (ceil_15_hour.find (" 2000-03-01 04:30:00" ), 19 , " 2000-03-01 05:30:00" );
2849- ceil_15_day.replace (ceil_15_day.find (" 2000-03-15 13:30:00" ), 19 , " 2000-03-15 14:30:00" );
2850- ceil_3_weeks.replace (ceil_3_weeks.find (" 2000-03-05 13:30:00" ), 19 , " 2000-03-05 14:30:00" );
2851- ceil_3_weeks_sunday.replace (ceil_3_weeks_sunday.find (" 2000-03-25 13:30:00" ), 19 , " 2000-03-25 14:30:00" );
2852- #endif
28532840 const char * ceil_5_months = R"( [
28542841 "1970-05-31 14:30:00", "2000-05-31 14:30:00", "1899-05-31 14:30:00", "2033-05-31 14:30:00",
28552842 "2020-05-31 14:30:00", "2020-03-31 13:30:00", "2020-03-31 13:30:00", "2010-03-31 13:30:00",
@@ -2874,10 +2861,10 @@ TEST_F(ScalarTemporalTestMultipleSinceGreaterUnit, CeilZoned) {
28742861 CheckScalarUnary (op, unit, times, unit, ceil_15_millisecond, &round_to_15_milliseconds);
28752862 CheckScalarUnary (op, unit, times, unit, ceil_13_second, &round_to_13_seconds);
28762863 CheckScalarUnary (op, unit, times, unit, ceil_13_minute, &round_to_13_minutes);
2877- CheckScalarUnary (op, unit, times, unit, ceil_15_hour. c_str () , &round_to_15_hours);
2878- CheckScalarUnary (op, unit, times, unit, ceil_15_day. c_str () , &round_to_15_days);
2879- CheckScalarUnary (op, unit, times, unit, ceil_3_weeks. c_str () , &round_to_3_weeks);
2880- CheckScalarUnary (op, unit, times, unit, ceil_3_weeks_sunday. c_str () , &round_to_3_weeks_sunday);
2864+ CheckScalarUnary (op, unit, times, unit, ceil_15_hour, &round_to_15_hours);
2865+ CheckScalarUnary (op, unit, times, unit, ceil_15_day, &round_to_15_days);
2866+ CheckScalarUnary (op, unit, times, unit, ceil_3_weeks, &round_to_3_weeks);
2867+ CheckScalarUnary (op, unit, times, unit, ceil_3_weeks_sunday, &round_to_3_weeks_sunday);
28812868 CheckScalarUnary (op, unit, times, unit, ceil_5_months, &round_to_5_months);
28822869 CheckScalarUnary (op, unit, times, unit, ceil_3_quarters, &round_to_3_quarters);
28832870 CheckScalarUnary (op, unit, times, unit, ceil_15_years, &round_to_15_years);
@@ -3220,32 +3207,26 @@ TEST_F(ScalarTemporalTestMultipleSinceGreaterUnit, FloorZoned) {
32203207 "2020-01-01 00:56:00", "2019-12-31 02:09:00", "2019-12-30 03:09:00", "2009-12-31 04:09:00",
32213208 "2010-01-01 05:22:00", "2010-01-03 06:30:00", "2010-01-04 07:30:00", "2006-01-01 08:30:00",
32223209 "2005-12-31 09:43:00", "2008-12-27 23:56:00", "2008-12-28 23:56:00", "2012-01-01 00:56:00", null])" ;
3223- std::string floor_15_hour = R"( [
3210+ const char * floor_15_hour = R"( [
32243211 "1969-12-31 14:30:00", "2000-02-29 13:30:00", "1898-12-31 15:00:00", "2033-05-17 14:30:00",
32253212 "2019-12-31 13:30:00", "2019-12-30 13:30:00", "2019-12-29 13:30:00", "2009-12-30 13:30:00",
32263213 "2010-01-01 04:30:00", "2010-01-03 04:30:00", "2010-01-04 04:30:00", "2006-01-01 04:30:00",
32273214 "2005-12-31 04:30:00", "2008-12-27 13:30:00", "2008-12-28 13:30:00", "2011-12-31 13:30:00", null])" ;
3228- std::string floor_15_day = R"( [
3215+ const char * floor_15_day = R"( [
32293216 "1969-12-31 14:30:00", "2000-02-29 13:30:00", "1898-12-31 15:00:00", "2033-05-15 14:30:00",
32303217 "2019-12-31 13:30:00", "2019-12-30 13:30:00", "2019-12-15 13:30:00", "2009-12-30 13:30:00",
32313218 "2009-12-31 13:30:00", "2009-12-31 13:30:00", "2009-12-31 13:30:00", "2005-12-31 13:30:00",
32323219 "2005-12-30 13:30:00", "2008-12-15 13:30:00", "2008-12-15 13:30:00", "2011-12-31 13:30:00", null])" ;
3233- std::string floor_3_weeks = R"( [
3220+ const char * floor_3_weeks = R"( [
32343221 "1969-12-28 14:30:00", "2000-02-13 13:30:00", "1899-01-01 15:00:00", "2033-05-08 14:30:00",
32353222 "2019-12-29 13:30:00", "2019-12-29 13:30:00", "2019-12-29 13:30:00", "2010-01-03 13:30:00",
32363223 "2010-01-03 13:30:00", "2010-01-03 13:30:00", "2010-01-03 13:30:00", "2006-01-01 13:30:00",
32373224 "2006-01-01 13:30:00", "2008-12-21 13:30:00", "2008-12-28 13:30:00", "2012-01-01 13:30:00", null])" ;
3238- std::string floor_3_weeks_sunday = R"( [
3225+ const char * floor_3_weeks_sunday = R"( [
32393226 "1970-01-03 14:30:00", "2000-03-04 13:30:00", "1898-12-31 15:00:00", "2033-05-07 14:30:00",
32403227 "2019-12-28 13:30:00", "2019-12-28 13:30:00", "2019-12-28 13:30:00", "2010-01-02 13:30:00",
32413228 "2010-01-02 13:30:00", "2010-01-02 13:30:00", "2010-01-02 13:30:00", "2005-12-31 13:30:00",
32423229 "2005-12-31 13:30:00", "2009-01-03 13:30:00", "2009-01-03 13:30:00", "2011-12-31 13:30:00", null])" ;
3243- #if ARROW_USE_STD_CHRONO
3244- floor_15_hour.replace (floor_15_hour.find (" 2000-02-29 13:30:00" ), 19 , " 2000-02-29 14:30:00" );
3245- floor_15_day.replace (floor_15_day.find (" 2000-02-29 13:30:00" ), 19 , " 2000-02-29 14:30:00" );
3246- floor_3_weeks.replace (floor_3_weeks.find (" 2000-02-13 13:30:00" ), 19 , " 2000-02-13 14:30:00" );
3247- floor_3_weeks_sunday.replace (floor_3_weeks_sunday.find (" 2000-03-04 13:30:00" ), 19 , " 2000-03-04 14:30:00" );
3248- #endif
32493230 const char * floor_5_months = R"( [
32503231 "1969-12-31 14:30:00", "1999-12-31 13:30:00", "1898-12-31 15:00:00", "2032-12-31 13:30:00",
32513232 "2019-12-31 13:30:00", "2019-10-31 13:30:00", "2019-10-31 13:30:00", "2009-10-31 13:30:00",
@@ -3272,10 +3253,10 @@ TEST_F(ScalarTemporalTestMultipleSinceGreaterUnit, FloorZoned) {
32723253 &round_to_15_milliseconds);
32733254 CheckScalarUnary (op, unit, times, unit, floor_13_second, &round_to_13_seconds);
32743255 CheckScalarUnary (op, unit, times, unit, floor_13_minute, &round_to_13_minutes);
3275- CheckScalarUnary (op, unit, times, unit, floor_15_hour. c_str () , &round_to_15_hours);
3276- CheckScalarUnary (op, unit, times, unit, floor_15_day. c_str () , &round_to_15_days);
3277- CheckScalarUnary (op, unit, times, unit, floor_3_weeks. c_str () , &round_to_3_weeks);
3278- CheckScalarUnary (op, unit, times, unit, floor_3_weeks_sunday. c_str () , &round_to_3_weeks_sunday);
3256+ CheckScalarUnary (op, unit, times, unit, floor_15_hour, &round_to_15_hours);
3257+ CheckScalarUnary (op, unit, times, unit, floor_15_day, &round_to_15_days);
3258+ CheckScalarUnary (op, unit, times, unit, floor_3_weeks, &round_to_3_weeks);
3259+ CheckScalarUnary (op, unit, times, unit, floor_3_weeks_sunday, &round_to_3_weeks_sunday);
32793260 CheckScalarUnary (op, unit, times, unit, floor_5_months, &round_to_5_months);
32803261 CheckScalarUnary (op, unit, times, unit, floor_3_quarters, &round_to_3_quarters);
32813262 CheckScalarUnary (op, unit, times, unit, floor_15_years, &round_to_15_years);
@@ -3659,32 +3640,26 @@ TEST_F(ScalarTemporalTestMultipleSinceGreaterUnit, RoundZoned) {
36593640 "2020-01-01 01:09:00", "2019-12-31 02:09:00", "2019-12-30 03:09:00", "2009-12-31 04:22:00",
36603641 "2010-01-01 05:22:00", "2010-01-03 06:30:00", "2010-01-04 07:30:00", "2006-01-01 08:43:00",
36613642 "2005-12-31 09:43:00", "2008-12-27 23:56:00", "2008-12-28 23:56:00", "2012-01-01 00:56:00", null])" ;
3662- std::string round_15_hour = R"( [
3643+ const char * round_15_hour = R"( [
36633644 "1970-01-01 05:30:00", "2000-03-01 04:30:00", "1899-01-01 06:00:00", "2033-05-18 05:30:00",
36643645 "2020-01-01 04:30:00", "2019-12-31 04:30:00", "2019-12-30 04:30:00", "2009-12-31 04:30:00",
36653646 "2010-01-01 04:30:00", "2010-01-03 04:30:00", "2010-01-04 04:30:00", "2006-01-01 04:30:00",
36663647 "2005-12-31 04:30:00", "2008-12-28 04:30:00", "2008-12-29 04:30:00", "2012-01-01 04:30:00", null])" ;
3667- std::string round_15_day = R"( [
3648+ const char * round_15_day = R"( [
36683649 "1969-12-31 14:30:00", "2000-02-29 13:30:00", "1898-12-31 15:00:00", "2033-05-15 14:30:00",
36693650 "2019-12-31 13:30:00", "2019-12-30 13:30:00", "2019-12-30 13:30:00", "2009-12-30 13:30:00",
36703651 "2009-12-31 13:30:00", "2009-12-31 13:30:00", "2009-12-31 13:30:00", "2005-12-31 13:30:00",
36713652 "2005-12-30 13:30:00", "2008-12-30 13:30:00", "2008-12-30 13:30:00", "2011-12-31 13:30:00", null])" ;
3672- std::string round_3_weeks = R"( [
3653+ const char * round_3_weeks = R"( [
36733654 "1969-12-28 14:30:00", "2000-03-05 13:30:00", "1899-01-01 15:00:00", "2033-05-08 14:30:00",
36743655 "2019-12-29 13:30:00", "2019-12-29 13:30:00", "2019-12-29 13:30:00", "2010-01-03 13:30:00",
36753656 "2010-01-03 13:30:00", "2010-01-03 13:30:00", "2010-01-03 13:30:00", "2006-01-01 13:30:00",
36763657 "2006-01-01 13:30:00", "2008-12-21 13:30:00", "2008-12-28 13:30:00", "2012-01-01 13:30:00",null])" ;
3677- std::string round_3_weeks_sunday = R"( [
3658+ const char * round_3_weeks_sunday = R"( [
36783659 "1970-01-03 14:30:00", "2000-03-04 13:30:00", "1898-12-31 15:00:00", "2033-05-28 14:30:00",
36793660 "2019-12-28 13:30:00", "2019-12-28 13:30:00", "2019-12-28 13:30:00", "2010-01-02 13:30:00",
36803661 "2010-01-02 13:30:00", "2010-01-02 13:30:00", "2010-01-02 13:30:00", "2005-12-31 13:30:00",
36813662 "2005-12-31 13:30:00", "2009-01-03 13:30:00", "2009-01-03 13:30:00", "2011-12-31 13:30:00", null])" ;
3682- #if ARROW_USE_STD_CHRONO
3683- round_15_hour.replace (round_15_hour.find (" 2000-03-01 04:30:00" ), 19 , " 2000-03-01 05:30:00" );
3684- round_15_day.replace (round_15_day.find (" 2000-02-29 13:30:00" ), 19 , " 2000-02-29 14:30:00" );
3685- round_3_weeks.replace (round_3_weeks.find (" 2000-03-05 13:30:00" ), 19 , " 2000-03-05 14:30:00" );
3686- round_3_weeks_sunday.replace (round_3_weeks_sunday.find (" 2000-03-04 13:30:00" ), 19 , " 2000-03-04 14:30:00" );
3687- #endif
36883663 const char * round_5_months = R"( [
36893664 "1969-12-31 14:30:00", "1999-12-31 13:30:00", "1898-12-31 15:00:00", "2033-05-31 14:30:00",
36903665 "2019-12-31 13:30:00", "2019-10-31 13:30:00", "2019-10-31 13:30:00", "2009-10-31 13:30:00",
@@ -3711,10 +3686,10 @@ TEST_F(ScalarTemporalTestMultipleSinceGreaterUnit, RoundZoned) {
37113686 &round_to_15_milliseconds);
37123687 CheckScalarUnary (op, unit, times, unit, round_13_second, &round_to_13_seconds);
37133688 CheckScalarUnary (op, unit, times, unit, round_13_minute, &round_to_13_minutes);
3714- CheckScalarUnary (op, unit, times, unit, round_15_hour. c_str () , &round_to_15_hours);
3715- CheckScalarUnary (op, unit, times, unit, round_15_day. c_str () , &round_to_15_days);
3716- CheckScalarUnary (op, unit, times, unit, round_3_weeks. c_str () , &round_to_3_weeks);
3717- CheckScalarUnary (op, unit, times, unit, round_3_weeks_sunday. c_str () , &round_to_3_weeks_sunday);
3689+ CheckScalarUnary (op, unit, times, unit, round_15_hour, &round_to_15_hours);
3690+ CheckScalarUnary (op, unit, times, unit, round_15_day, &round_to_15_days);
3691+ CheckScalarUnary (op, unit, times, unit, round_3_weeks, &round_to_3_weeks);
3692+ CheckScalarUnary (op, unit, times, unit, round_3_weeks_sunday, &round_to_3_weeks_sunday);
37183693 CheckScalarUnary (op, unit, times, unit, round_5_months, &round_to_5_months);
37193694 CheckScalarUnary (op, unit, times, unit, round_3_quarters, &round_to_3_quarters);
37203695 CheckScalarUnary (op, unit, times, unit, round_15_years, &round_to_15_years);
0 commit comments