Repository: apache/arrow
File: cpp/src/parquet/arrow/arrow_reader_writer_test.cc (C++)

Code before:
        // NaN representations aren't guaranteed to be exact on a binary level
        ASSERT_TRUE(actual.is_nan());
      } else {
        ASSERT_EQ(expected.bits(), actual.bits());
      }
    }
  }
}

TEST(TestArrowFileReader, RecordBatchReaderEmptyRowGroups) {
  const int num_columns = 1;
  const int num_rows = 3;
  const int num_chunks = 1;

  std::shared_ptr<Table> table;
  ASSERT_NO_FATAL_FAILURE(MakeDoubleTable(num_columns, num_rows, num_chunks, &table));

  const int64_t row_group_size = num_rows;
  std::shared_ptr<Buffer> buffer;
  ASSERT_NO_FATAL_FAILURE(WriteTableToBuffer(table, row_group_size,
                                             default_arrow_writer_properties(), &buffer));

  auto reader = ParquetFileReader::Open(std::make_shared<BufferReader>(buffer));
  std::unique_ptr<FileReader> file_reader;
  ASSERT_OK_AND_ASSIGN(
      file_reader, FileReader::Make(::arrow::default_memory_pool(), std::move(reader)));
  // This is the important part in this test.
  std::vector<int> row_group_indices = {};
  ASSERT_OK_AND_ASSIGN(auto record_batch_reader,
                       file_reader->GetRecordBatchReader(row_group_indices));
  std::shared_ptr<::arrow::RecordBatch> record_batch;
  ASSERT_OK(record_batch_reader->ReadNext(&record_batch));
  // No read record batch for empty row groups request.
  ASSERT_FALSE(record_batch);
}

TEST(TestArrowFileReader, RecordBatchReaderEmptyInput) {
  const int num_columns = 1;
  // This is the important part in this test.
  const int num_rows = 0;
  const int num_chunks = 1;

  std::shared_ptr<Table> table;
  ASSERT_NO_FATAL_FAILURE(MakeDoubleTable(num_columns, num_rows, num_chunks, &table));

  const int64_t row_group_size = num_rows;
  std::shared_ptr<Buffer> buffer;
  ASSERT_NO_FATAL_FAILURE(WriteTableToBuffer(table, row_group_size,
                                             default_arrow_writer_properties(), &buffer));

  auto reader = ParquetFileReader::Open(std::make_shared<BufferReader>(buffer));

Review comment (suggestion):
```suggestion
  ASSERT_OK_AND_ASSIGN(
      auto file_reader, FileReader::Make(::arrow::default_memory_pool(), std::move(reader)));
```

Code after:
        ASSERT_EQ(expected.bits(), actual.bits());
      }
    }
  }
}

TEST(TestArrowFileReader, RecordBatchReaderEmptyRowGroups) {
  const int num_columns = 1;
  const int num_rows = 3;
  const int num_chunks = 1;

  std::shared_ptr<Table> table;
  ASSERT_NO_FATAL_FAILURE(MakeDoubleTable(num_columns, num_rows, num_chunks, &table));

  const int64_t row_group_size = num_rows;
  std::shared_ptr<Buffer> buffer;
  ASSERT_NO_FATAL_FAILURE(WriteTableToBuffer(table, row_group_size,
                                             default_arrow_writer_properties(), &buffer));

  auto reader = ParquetFileReader::Open(std::make_shared<BufferReader>(buffer));
  ASSERT_OK_AND_ASSIGN(auto file_reader, FileReader::Make(::arrow::default_memory_pool(),
                                                          std::move(reader)));
  // This is the important part in this test.
  std::vector<int> row_group_indices = {};
  ASSERT_OK_AND_ASSIGN(auto record_batch_reader,
                       file_reader->GetRecordBatchReader(row_group_indices));
  std::shared_ptr<::arrow::RecordBatch> record_batch;
  ASSERT_OK(record_batch_reader->ReadNext(&record_batch));
  // No read record batch for empty row groups request.
  ASSERT_FALSE(record_batch);
}

TEST(TestArrowFileReader, RecordBatchReaderEmptyInput) {
  const int num_columns = 1;
  // This is the important part in this test.
  const int num_rows = 0;
  const int num_chunks = 1;

  std::shared_ptr<Table> table;
  ASSERT_NO_FATAL_FAILURE(MakeDoubleTable(num_columns, num_rows, num_chunks, &table));

  const int64_t row_group_size = num_rows;
  std::shared_ptr<Buffer> buffer;
  ASSERT_NO_FATAL_FAILURE(WriteTableToBuffer(table, row_group_size,
                                             default_arrow_writer_properties(), &buffer));

  auto reader = ParquetFileReader::Open(std::make_shared<BufferReader>(buffer));
  ASSERT_OK_AND_ASSIGN(auto file_reader, FileReader::Make(::arrow::default_memory_pool(),
                                                          std::move(reader)));
  ASSERT_OK_AND_ASSIGN(auto record_batch_reader, file_reader->GetRecordBatchReader());
  std::shared_ptr<::arrow::RecordBatch> record_batch;