jorisvandenbossche commented on a change in pull request #10610:
URL: https://github.com/apache/arrow/pull/10610#discussion_r660346805



##########
File path: cpp/src/arrow/compute/kernels/scalar_temporal_test.cc
##########
@@ -177,5 +177,17 @@ TEST(ScalarTemporalTest, 
TestZonedTemporalComponentExtraction) {
     ASSERT_RAISES(NotImplemented, Subsecond(timestamps));
   }
 }
+
+TEST(ScalarTemporalTest, TestLocalizeTimezoneNaiveTimestamp) {
+  std::string timezone = "Asia/Kolkata";
+  const char* times_naive = R"(["1970-01-01T00:00:59", null])";
+  const char* times_utc = R"(["1970-01-01T00:00:59", null])";
+
+  for (auto u : internal::AllTimeUnits()) {
+    auto unit_naive = timestamp(u);
+    auto unit_utc = timestamp(u, timezone);
+    CheckScalarUnary("localize", unit_naive, times_naive, unit_utc, times_utc);

Review comment:
       Can you add a test with some other timezones as well?

##########
File path: docs/source/cpp/compute.rst
##########
@@ -906,48 +906,51 @@ Temporal component extraction
 These functions extract datetime components (year, month, day, etc) from 
timestamp type.
 Note: this is currently not supported for timestamps with timezone information.
 
-+--------------------+------------+-------------------+---------------+--------+
-| Function name      | Arity      | Input types       | Output type   | Notes  
|
-+====================+============+===================+===============+========+
-| year               | Unary      | Temporal          | Int64         |        
|
-+--------------------+------------+-------------------+---------------+--------+
-| month              | Unary      | Temporal          | Int64         |        
|
-+--------------------+------------+-------------------+---------------+--------+
-| day                | Unary      | Temporal          | Int64         |        
|
-+--------------------+------------+-------------------+---------------+--------+
-| day_of_week        | Unary      | Temporal          | Int64         | \(1)   
|
-+--------------------+------------+-------------------+---------------+--------+
-| day_of_year        | Unary      | Temporal          | Int64         |        
|
-+--------------------+------------+-------------------+---------------+--------+
-| iso_year           | Unary      | Temporal          | Int64         | \(2)   
|
-+--------------------+------------+-------------------+---------------+--------+
-| iso_week           | Unary      | Temporal          | Int64         | \(2)   
|
-+--------------------+------------+-------------------+---------------+--------+
-| iso_calendar       | Unary      | Temporal          | Struct        | \(3)   
|
-+--------------------+------------+-------------------+---------------+--------+
-| quarter            | Unary      | Temporal          | Int64         |        
|
-+--------------------+------------+-------------------+---------------+--------+
-| hour               | Unary      | Temporal          | Int64         |        
|
-+--------------------+------------+-------------------+---------------+--------+
-| minute             | Unary      | Temporal          | Int64         |        
|
-+--------------------+------------+-------------------+---------------+--------+
-| second             | Unary      | Temporal          | Int64         |        
|
-+--------------------+------------+-------------------+---------------+--------+
-| millisecond        | Unary      | Temporal          | Int64         |        
|
-+--------------------+------------+-------------------+---------------+--------+
-| microsecond        | Unary      | Temporal          | Int64         |        
|
-+--------------------+------------+-------------------+---------------+--------+
-| nanosecond         | Unary      | Temporal          | Int64         |        
|
-+--------------------+------------+-------------------+---------------+--------+
-| subsecond          | Unary      | Temporal          | Double        |        
|
-+--------------------+------------+-------------------+---------------+--------+
++--------------------+------------+-------------------+---------------+--------+----------------------------------------------+
+| Function name      | Arity      | Input types       | Output type   | Notes  
| Options class                                |
++====================+============+===================+===============+========+==============================================+
+| year               | Unary      | Temporal          | Int64         |        
|                                              |
++--------------------+------------+-------------------+---------------+--------+----------------------------------------------+
+| month              | Unary      | Temporal          | Int64         |        
|                                              |
++--------------------+------------+-------------------+---------------+--------+----------------------------------------------+
+| day                | Unary      | Temporal          | Int64         |        
|                                              |
++--------------------+------------+-------------------+---------------+--------+----------------------------------------------+
+| day_of_week        | Unary      | Temporal          | Int64         | \(1)   
|                                              |
++--------------------+------------+-------------------+---------------+--------+----------------------------------------------+
+| day_of_year        | Unary      | Temporal          | Int64         |        
|                                              |
++--------------------+------------+-------------------+---------------+--------+----------------------------------------------+
+| iso_year           | Unary      | Temporal          | Int64         | \(2)   
|                                              |
++--------------------+------------+-------------------+---------------+--------+----------------------------------------------+
+| iso_week           | Unary      | Temporal          | Int64         | \(2)   
|                                              |
++--------------------+------------+-------------------+---------------+--------+----------------------------------------------+
+| iso_calendar       | Unary      | Temporal          | Struct        | \(3)   
|                                              |
++--------------------+------------+-------------------+---------------+--------+----------------------------------------------+
+| quarter            | Unary      | Temporal          | Int64         |        
|                                              |
++--------------------+------------+-------------------+---------------+--------+----------------------------------------------+
+| hour               | Unary      | Temporal          | Int64         |        
|                                              |
++--------------------+------------+-------------------+---------------+--------+----------------------------------------------+
+| minute             | Unary      | Temporal          | Int64         |        
|                                              |
++--------------------+------------+-------------------+---------------+--------+----------------------------------------------+
+| second             | Unary      | Temporal          | Int64         |        
|                                              |
++--------------------+------------+-------------------+---------------+--------+----------------------------------------------+
+| millisecond        | Unary      | Temporal          | Int64         |        
|                                              |
++--------------------+------------+-------------------+---------------+--------+----------------------------------------------+
+| microsecond        | Unary      | Temporal          | Int64         |        
|                                              |
++--------------------+------------+-------------------+---------------+--------+----------------------------------------------+
+| nanosecond         | Unary      | Temporal          | Int64         |        
|                                              |
++--------------------+------------+-------------------+---------------+--------+----------------------------------------------+
+| subsecond          | Unary      | Temporal          | Double        |        
|                                              |
++--------------------+------------+-------------------+---------------+--------+----------------------------------------------+
+| localize           | Unary      | Temporal          | Temporal      | \(4)   
| :struct:`TemporalLocalizationOptions`        |

Review comment:
       Localize is not a "component extraction", so I would put this in a 
separate table. Maybe under a new subsection below this one as "Timezone 
handling" ?

##########
File path: cpp/src/arrow/compute/api_scalar.h
##########
@@ -735,5 +749,18 @@ Result<Datum> Nanosecond(const Datum& values, ExecContext* 
ctx = NULLPTR);
 /// \note API not yet finalized
 ARROW_EXPORT Result<Datum> Subsecond(const Datum& values, ExecContext* ctx = 
NULLPTR);
 
+/// \brief Localizes timezone naive timestamps to UTC for each element of 
`values`

Review comment:
       This is not only to localize to UTC, but rather to any timezone (that 
the underlying values are converted from that timezone to UTC is more an 
implementation detail to the user)




-- 
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]


Reply via email to