kiszk commented on PR #48215:
URL: https://github.com/apache/arrow/pull/48215#issuecomment-4726381230

   @Vishwanatha-HD The existing ReadFloat16Files test reads pre-generated 
.parquet files, so it only meaningfully validates the platform those files came 
from. Since this is a BE-specific byte-order fix, a write→read round-trip test 
that asserts on the actual Float16 bits would guard against regressions on all 
platforms. 
   Would a value-based round-trip like the following example under 
`cpp/src/parquet/arrow/arrow_reader_writer_test.cc` make the intent explicit?
   
   ```
   TEST(TestArrowReaderAdHoc, Float16RoundTripValues) {
     using ::arrow::util::Float16;
     using ::arrow::HalfFloatArray;
     using ::arrow::HalfFloatType;
   
     // Pick values whose two bytes differ, so a missing byte-swap is 
detectable.
     const std::vector<Float16> values = {
         Float16(+1.0),   // bits 0x3c00
         Float16(-2.0),   // bits 0xc000
         Float16(+0.5),   // bits 0x3800
         Float16(-0.0),   // bits 0x8000
         Float16(65504.0) // bits 0x7bff (max finite)
     };
   
     // Build a HalfFloatArray from the raw bits (native endian).
     ::arrow::HalfFloatBuilder builder;
     ASSERT_OK(builder.Append(values[0].bits()));
     ASSERT_OK(builder.AppendNull());
     for (size_t i = 1; i < values.size(); ++i) {
       ASSERT_OK(builder.Append(values[i].bits()));
     }
     std::shared_ptr<::arrow::Array> array;
     ASSERT_OK(builder.Finish(&array));
   
     auto table = ::arrow::Table::Make(
         ::arrow::schema({::arrow::field("f16", ::arrow::float16())}), {array});
   
     std::shared_ptr<Table> result;
     ASSERT_NO_FATAL_FAILURE(
         DoSimpleRoundtrip(table, /*use_threads=*/false,
                           /*row_group_size=*/table->num_rows(), {}, &result));
   
     ASSERT_EQ(result->num_columns(), 1);
     ASSERT_EQ(result->column(0)->type()->id(), ::arrow::Type::HALF_FLOAT);
     auto chunk = 
checked_pointer_cast<HalfFloatArray>(result->column(0)->chunk(0));
   
     ASSERT_TRUE(chunk->IsNull(1));
     ASSERT_EQ(chunk->Value(0), values[0].bits());
     for (size_t i = 1; i < values.size(); ++i) {
       ASSERT_FALSE(chunk->IsNull(static_cast<int64_t>(i) + 1));
       ASSERT_EQ(chunk->Value(static_cast<int64_t>(i) + 1), values[i].bits());
     }
   }
   ```


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