ArnavBalyan commented on code in PR #49615:
URL: https://github.com/apache/arrow/pull/49615#discussion_r3011668361


##########
cpp/src/parquet/column_writer.cc:
##########
@@ -2352,7 +2353,13 @@ struct SerializeFunctor<Int64Type, 
::arrow::TimestampType> {
 
     auto MultiplyBy = [&](const int64_t factor) {
       for (int64_t i = 0; i < array.length(); i++) {
-        out[i] = values[i] * factor;
+        if (ARROW_PREDICT_FALSE(::arrow::internal::MultiplyWithOverflowGeneric(
+                values[i], factor, &out[i])) &&
+            array.IsValid(i)) {

Review Comment:
   done thanks



##########
cpp/src/parquet/arrow/arrow_reader_writer_test.cc:
##########
@@ -2178,6 +2178,53 @@ TEST(TestArrowReadWrite, 
ImplicitSecondToMillisecondTimestampCoercion) {
   ASSERT_NO_FATAL_FAILURE(::arrow::AssertTablesEqual(*tx, *to));
 }
 
+TEST(TestArrowReadWrite, TimestampCoercionOverflow) {
+  using ::arrow::ArrayFromVector;
+  using ::arrow::field;
+  using ::arrow::schema;
+
+  auto t_s = ::arrow::timestamp(TimeUnit::SECOND);
+
+  std::vector<int64_t> overflow_values = {9223372036854776LL};
+  std::vector<bool> is_valid = {true};
+
+  std::shared_ptr<Array> a_s;
+  ArrayFromVector<::arrow::TimestampType, int64_t>(t_s, is_valid, 
overflow_values, &a_s);
+
+  auto s = schema({field("timestamp", t_s)});
+  auto table = Table::Make(s, {a_s});
+
+  ASSERT_RAISES(Invalid, WriteTable(*table, ::arrow::default_memory_pool(),
+                                    CreateOutputStream(), table->num_rows()));
+
+  auto coerce_millis =

Review Comment:
   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]

Reply via email to