@@ -1766,6 +1766,61 @@ TEST_F(TestConvertArrowSchema, ParquetFlatDecimals) {
17661766 ASSERT_NO_FATAL_FAILURE (CheckFlatSchema (parquet_fields));
17671767}
17681768
1769+ TEST_F (TestConvertArrowSchema, ParquetTimeAdjustedToUTC) {
1770+ // Verify Parquet Time types have the appropriate isAdjustedToUTC value, depending
1771+ // on the return value of ArrowWriterProperties::write_time_adjusted_to_utc()
1772+
1773+ struct FieldConstructionArguments {
1774+ std::string name;
1775+ std::shared_ptr<::arrow::DataType> datatype;
1776+ std::shared_ptr<const LogicalType> logical_type;
1777+ parquet::Type::type physical_type;
1778+ int physical_length;
1779+ };
1780+
1781+ auto make_cases_fcn = [](bool write_time_utc_adjusted) {
1782+ std::vector<FieldConstructionArguments> cases = {
1783+ {" time32" , ::arrow::time32 (::arrow::TimeUnit::MILLI),
1784+ LogicalType::Time (write_time_utc_adjusted, LogicalType::TimeUnit::MILLIS), ParquetType::INT32, -1 },
1785+ {" time64(microsecond)" , ::arrow::time64 (::arrow::TimeUnit::MICRO),
1786+ LogicalType::Time (write_time_utc_adjusted, LogicalType::TimeUnit::MICROS), ParquetType::INT64, -1 },
1787+ {" time64(nanosecond)" , ::arrow::time64 (::arrow::TimeUnit::NANO),
1788+ LogicalType::Time (write_time_utc_adjusted, LogicalType::TimeUnit::NANOS), ParquetType::INT64, -1 }
1789+ }
1790+ return cases;
1791+ };
1792+
1793+ auto make_fields_schema_fcn = [](const FieldConstructionArguments& cases) {
1794+ std::vector<std::shared_ptr<Field>> arrow_fields;
1795+ std::vector<NodePtr> parquet_fields;
1796+ for (const FieldConstructionArguments& c : cases) {
1797+ arrow_fields.push_back (::arrow::field (c.name , c.datatype , false ));
1798+ parquet_fields.push_back (PrimitiveNode::Make (c.name , Repetition::REQUIRED,
1799+ c.logical_type , c.physical_type ,
1800+ c.physical_length ));
1801+ }
1802+ return std::make_pair (arrow_fields, parquet_fields);
1803+ }
1804+
1805+
1806+ ArrowWriterProperties::Builder builder;
1807+
1808+ auto arrow_writer_properties = builder.enable_time_adjusted_to_utc ()->build ();
1809+ EXPECT_TRUE (arrow_writer_properties->write_time_adjusted_to_utc ());
1810+ auto cases = make_cases_fcn (true );
1811+ auto arrow_parquet_fields = make_fields_schema_fcn (cases);
1812+ ASSERT_OK (ConvertSchema (arrow_parquet_fields.first , arrow_writer_properties));
1813+ CheckFlatSchema (arrow_parquet_fields.second );
1814+
1815+ arrow_writer_properties = builder.disable_time_adjusted_to_utc ()->build ();
1816+ EXPECT_FALSE (arrow_writer_properties->write_time_adjusted_to_utc ());
1817+ auto cases = make_cases_fcn (false );
1818+ auto arrow_parquet_fields = make_fields_schema_fcn (cases);
1819+ ASSERT_OK (ConvertSchema (arrow_parquet_fields.first , arrow_writer_properties));
1820+ CheckFlatSchema (arrow_parquet_fields.second );
1821+ }
1822+
1823+
17691824class TestConvertRoundTrip : public ::testing::Test {
17701825 public:
17711826 ::arrow::Status RoundTripSchema (
0 commit comments